Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 1 | # Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Peter Collingbourne | 8e67eb9 | 2018-01-24 18:42:02 -0800 | [diff] [blame] | 15 | import("//build/config/c++/c++.gni") |
Nicolas Capens | d51e216 | 2017-06-05 13:59:55 -0400 | [diff] [blame] | 16 | import("//build/config/compiler/compiler.gni") |
Milko Leporis | 0506982 | 2018-12-18 16:04:15 +0100 | [diff] [blame] | 17 | import("//build/config/mips.gni") |
Nicolas Capens | d51e216 | 2017-06-05 13:59:55 -0400 | [diff] [blame] | 18 | |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 19 | config("swiftshader_config") { |
Alexis Hetu | 0def102 | 2017-08-16 17:15:48 -0400 | [diff] [blame] | 20 | defines = [] |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 21 | |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 22 | if (is_win) { |
| 23 | cflags = [ |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 24 | "/GS", # Detects some buffer overruns |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 25 | "/Zc:wchar_t", |
Reid Kleckner | d19db3d | 2017-11-29 10:45:53 -0800 | [diff] [blame] | 26 | "/EHs-c-", # Disable C++ exceptions |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 27 | "/nologo", |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 28 | "/Gd", # Default calling convention |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 29 | ] |
| 30 | |
Peter Collingbourne | 8e67eb9 | 2018-01-24 18:42:02 -0800 | [diff] [blame] | 31 | if (!use_custom_libcxx) { |
| 32 | # Disable EH usage in STL headers. |
| 33 | # libc++ uses a predefined macro to control whether to use exceptions, so |
| 34 | # defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also |
| 35 | # breaks libc++ because it depends on MSVC headers that only provide |
| 36 | # certain declarations if _HAS_EXCEPTIONS is 1. |
| 37 | defines += [ |
| 38 | "_HAS_EXCEPTIONS=0", |
| 39 | ] |
| 40 | } |
| 41 | |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 42 | defines += [ |
| 43 | "_CRT_SECURE_NO_DEPRECATE", |
| 44 | "NOMINMAX", |
| 45 | "_WINDLL", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 46 | "NO_SANITIZE_FUNCTION=", |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 47 | ] |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 48 | |
Robert Liao | e8d42ae | 2017-08-14 10:51:58 -0700 | [diff] [blame] | 49 | if (!is_debug) { |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 50 | defines += [ "ANGLE_DISABLE_TRACE" ] |
| 51 | } |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 52 | } else { |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 53 | cflags = [ |
| 54 | "-std=c++11", |
Alexis Hetu | 2c0546d | 2017-05-24 11:16:26 -0400 | [diff] [blame] | 55 | "-fno-exceptions", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 56 | "-fno-operator-names", |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 57 | ] |
| 58 | |
| 59 | defines += [ |
| 60 | "__STDC_CONSTANT_MACROS", |
| 61 | "__STDC_LIMIT_MACROS", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 62 | "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 63 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 64 | |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 65 | if (is_debug) { |
| 66 | cflags += [ |
| 67 | "-g", |
| 68 | "-g3", |
| 69 | ] |
| 70 | } else { # Release |
| 71 | # All Release builds use function/data sections to make the shared libraries smaller |
| 72 | cflags += [ |
| 73 | "-ffunction-sections", |
| 74 | "-fdata-sections", |
| 75 | "-fomit-frame-pointer", |
| 76 | "-Os", |
| 77 | ] |
| 78 | |
| 79 | defines += [ |
| 80 | "ANGLE_DISABLE_TRACE", |
| 81 | "NDEBUG", |
| 82 | ] |
| 83 | } |
| 84 | |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 85 | if (target_cpu == "x64") { # 64 bit version |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 86 | cflags += [ |
| 87 | "-m64", |
| 88 | "-fPIC", |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 89 | "-march=x86-64", |
| 90 | "-mtune=generic", |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 91 | ] |
Stephen Lanham | fe79649 | 2018-09-07 11:59:54 -0700 | [diff] [blame] | 92 | } else if (target_cpu == "x86") { # 32 bit version |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 93 | cflags += [ |
| 94 | "-m32", |
| 95 | "-msse2", |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 96 | "-mfpmath=sse", |
| 97 | "-march=pentium4", |
| 98 | "-mtune=generic", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 99 | ] |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 100 | } else if (target_cpu == "mipsel" && current_cpu == target_cpu) { |
| 101 | cflags += [ |
| 102 | "-march=mipsel", |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 103 | "-fPIC", |
| 104 | "-mhard-float", |
| 105 | "-mfp32", |
| 106 | ] |
Milko Leporis | 0506982 | 2018-12-18 16:04:15 +0100 | [diff] [blame] | 107 | if (mips_arch_variant == "r1") { |
| 108 | cflags += [ |
| 109 | "-mcpu=mips32", |
| 110 | ] |
| 111 | } else { |
| 112 | cflags += [ |
| 113 | "-mcpu=mips32r2", |
| 114 | ] |
| 115 | } |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 116 | } else if (target_cpu == "mips64el" && current_cpu == target_cpu) { |
| 117 | cflags += [ |
| 118 | "-march=mips64el", |
| 119 | "-mcpu=mips64r2", |
| 120 | "-mabi=64", |
| 121 | "-fPIC", |
| 122 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 123 | } |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 124 | |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 125 | if (is_linux) { |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 126 | ldflags = [ "-Wl,--gc-sections" ] |
| 127 | |
| 128 | if (target_cpu == "mipsel") { |
| 129 | ldflags += [ |
| 130 | "-Wl,--hash-style=sysv", |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 131 | ] |
Milko Leporis | 0506982 | 2018-12-18 16:04:15 +0100 | [diff] [blame] | 132 | if (mips_arch_variant == "r1") { |
| 133 | ldflags += [ |
| 134 | "-mips32", |
| 135 | ] |
| 136 | } else { |
| 137 | ldflags += [ |
| 138 | "-mips32r2", |
| 139 | ] |
| 140 | } |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 141 | } else if (target_cpu == "mips64el") { |
| 142 | ldflags += [ |
| 143 | "-Wl,--hash-style=sysv", |
| 144 | "-mips64r2", |
| 145 | ] |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 146 | } else { |
| 147 | ldflags += [ "-Wl,--hash-style=both" ] |
| 148 | } |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 149 | |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 150 | # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532) |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 151 | if (use_gold && (target_cpu == "x86" || target_cpu == "mipsel")) { |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 152 | ldflags += [ "-Wl,--icf=none" ] |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 153 | } |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 154 | } |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | |
Corentin Wallez | 57eb063 | 2017-10-24 15:17:18 -0400 | [diff] [blame] | 158 | source_set("vertex_routine_fuzzer") { |
| 159 | sources = [ |
| 160 | "tests/fuzzers/VertexRoutineFuzzer.cpp" |
| 161 | ] |
Corentin Wallez | 6e27fea | 2017-10-27 13:40:18 -0400 | [diff] [blame] | 162 | if (is_win) { |
| 163 | cflags = [ |
| 164 | "/wd4201", # nameless struct/union |
| 165 | "/wd4065", # switch statement contains 'default' but no 'case' labels |
| 166 | "/wd5030", # attribute is not recognized |
| 167 | ] |
| 168 | } |
Corentin Wallez | 57eb063 | 2017-10-24 15:17:18 -0400 | [diff] [blame] | 169 | include_dirs = [ |
| 170 | "src/", |
| 171 | ] |
| 172 | deps = [ |
| 173 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static", |
| 174 | ] |
| 175 | } |
| 176 | |
Alexis Hetu | 68f564d | 2016-07-06 17:43:22 -0400 | [diff] [blame] | 177 | group("swiftshader") { |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 178 | data_deps = [ |
| 179 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2", |
| 180 | "src/OpenGL/libEGL:swiftshader_libEGL", |
| 181 | ] |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | group("swiftshader_tests") { |
| 185 | testonly = true |
| 186 | |
| 187 | data_deps = [ |
Alexis Hetu | d16a504 | 2018-10-17 10:10:23 -0400 | [diff] [blame] | 188 | "tests/GLESUnitTests:swiftshader_unittests", |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 189 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 190 | } |