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 | 5b36fbc | 2021-01-21 14:00:46 -0500 | [diff] [blame] | 18 | import("//build/config/sysroot.gni") |
Nicolas Capens | 282aa41 | 2020-11-16 11:37:29 -0500 | [diff] [blame] | 19 | import("src/Reactor/reactor.gni") |
Nicolas Capens | d51e216 | 2017-06-05 13:59:55 -0400 | [diff] [blame] | 20 | |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 21 | config("swiftshader_config") { |
Alexis Hetu | 0def102 | 2017-08-16 17:15:48 -0400 | [diff] [blame] | 22 | defines = [] |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 23 | |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 24 | if (is_win) { |
| 25 | cflags = [ |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 26 | "/GS", # Detects some buffer overruns |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 27 | "/Zc:wchar_t", |
Reid Kleckner | d19db3d | 2017-11-29 10:45:53 -0800 | [diff] [blame] | 28 | "/EHs-c-", # Disable C++ exceptions |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 29 | "/nologo", |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 30 | "/Gd", # Default calling convention |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 31 | # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8 |
| 32 | "/D_ENABLE_EXTENDED_ALIGNED_STORAGE", |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 33 | ] |
| 34 | |
Peter Collingbourne | 8e67eb9 | 2018-01-24 18:42:02 -0800 | [diff] [blame] | 35 | if (!use_custom_libcxx) { |
| 36 | # Disable EH usage in STL headers. |
| 37 | # libc++ uses a predefined macro to control whether to use exceptions, so |
| 38 | # defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also |
| 39 | # breaks libc++ because it depends on MSVC headers that only provide |
| 40 | # certain declarations if _HAS_EXCEPTIONS is 1. |
| 41 | defines += [ |
| 42 | "_HAS_EXCEPTIONS=0", |
| 43 | ] |
| 44 | } |
| 45 | |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 46 | defines += [ |
| 47 | "_CRT_SECURE_NO_DEPRECATE", |
| 48 | "NOMINMAX", |
| 49 | "_WINDLL", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 50 | "NO_SANITIZE_FUNCTION=", |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 51 | ] |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 52 | |
Robert Liao | e8d42ae | 2017-08-14 10:51:58 -0700 | [diff] [blame] | 53 | if (!is_debug) { |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 54 | defines += [ "ANGLE_DISABLE_TRACE" ] |
| 55 | } |
Jamie Madill | 9746f8b | 2019-09-05 13:17:09 -0400 | [diff] [blame] | 56 | |
| 57 | # Diable some MSVC warnings. |
| 58 | if (!is_clang) { |
| 59 | cflags += [ |
Jonah Ryan-Davis | 5fc197d | 2020-01-15 13:08:17 -0500 | [diff] [blame] | 60 | "/wd4065", # switch statement contains 'default' but no 'case' labels |
Jamie Madill | 9746f8b | 2019-09-05 13:17:09 -0400 | [diff] [blame] | 61 | "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts of signed shorts. |
| 62 | ] |
| 63 | } |
Nicolas Capens | b3e5c44 | 2021-01-20 06:16:24 +0000 | [diff] [blame] | 64 | |
| 65 | cflags_cc = [ "/std:c++17" ] |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 66 | } else { |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 67 | cflags = [ |
Alexis Hetu | 2c0546d | 2017-05-24 11:16:26 -0400 | [diff] [blame] | 68 | "-fno-exceptions", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 69 | "-fno-operator-names", |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 70 | ] |
Nicolas Capens | b3e5c44 | 2021-01-20 06:16:24 +0000 | [diff] [blame] | 71 | cflags_cc = [ "-std=c++17" ] |
Nicolas Capens | 3fe96b7 | 2021-01-22 11:32:21 -0500 | [diff] [blame] | 72 | # On macOS for the ARM architecture, some C++17 features require version 10.14, |
| 73 | # while Chrome must support 10.11 (El Capitan). However, the first 'Apple Silicon' |
| 74 | # devices launched with macOS 11.0 (Big Sur). |
| 75 | # TODO(b/174843857): Remove once Chrome demands macOS 10.14. |
| 76 | if (is_mac && current_cpu == "arm64") { |
Nicolas Capens | 5b36fbc | 2021-01-21 14:00:46 -0500 | [diff] [blame] | 77 | cflags += [ |
| 78 | "-isysroot", |
| 79 | rebase_path(sysroot, root_build_dir), |
Nicolas Capens | 3fe96b7 | 2021-01-22 11:32:21 -0500 | [diff] [blame] | 80 | "-mmacosx-version-min=10.14.0", |
Nicolas Capens | 5b36fbc | 2021-01-21 14:00:46 -0500 | [diff] [blame] | 81 | ] |
| 82 | } |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 83 | |
| 84 | defines += [ |
| 85 | "__STDC_CONSTANT_MACROS", |
| 86 | "__STDC_LIMIT_MACROS", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 87 | "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 88 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 89 | |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 90 | if (is_debug) { |
| 91 | cflags += [ |
| 92 | "-g", |
| 93 | "-g3", |
| 94 | ] |
| 95 | } else { # Release |
| 96 | # All Release builds use function/data sections to make the shared libraries smaller |
| 97 | cflags += [ |
| 98 | "-ffunction-sections", |
| 99 | "-fdata-sections", |
| 100 | "-fomit-frame-pointer", |
| 101 | "-Os", |
| 102 | ] |
| 103 | |
| 104 | defines += [ |
| 105 | "ANGLE_DISABLE_TRACE", |
| 106 | "NDEBUG", |
| 107 | ] |
| 108 | } |
| 109 | |
Antonio Maiorano | 8478560 | 2020-02-21 15:37:37 -0500 | [diff] [blame] | 110 | if (current_cpu == "x64") { # 64 bit version |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 111 | cflags += [ |
| 112 | "-m64", |
| 113 | "-fPIC", |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 114 | "-march=x86-64", |
| 115 | "-mtune=generic", |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 116 | ] |
Antonio Maiorano | 8478560 | 2020-02-21 15:37:37 -0500 | [diff] [blame] | 117 | } else if (current_cpu == "x86") { # 32 bit version |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 118 | cflags += [ |
| 119 | "-m32", |
| 120 | "-msse2", |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 121 | "-mfpmath=sse", |
| 122 | "-march=pentium4", |
| 123 | "-mtune=generic", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 124 | ] |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 125 | } else if (target_cpu == "mipsel" && current_cpu == target_cpu) { |
| 126 | cflags += [ |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 127 | "-EL", |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 128 | "-fPIC", |
| 129 | "-mhard-float", |
| 130 | "-mfp32", |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 131 | "-mxgot", |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 132 | ] |
Milko Leporis | 0506982 | 2018-12-18 16:04:15 +0100 | [diff] [blame] | 133 | if (mips_arch_variant == "r1") { |
| 134 | cflags += [ |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 135 | "-march=mips32", |
Milko Leporis | 0506982 | 2018-12-18 16:04:15 +0100 | [diff] [blame] | 136 | ] |
| 137 | } else { |
| 138 | cflags += [ |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 139 | "-march=mips32r2", |
Milko Leporis | 0506982 | 2018-12-18 16:04:15 +0100 | [diff] [blame] | 140 | ] |
| 141 | } |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 142 | } else if (target_cpu == "mips64el" && current_cpu == target_cpu) { |
| 143 | cflags += [ |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 144 | "-EL", |
| 145 | "-arch=mips64r2", |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 146 | "-mabi=64", |
| 147 | "-fPIC", |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 148 | "-mxgot", |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 149 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 150 | } |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 151 | |
Hidehiko Abe | fe878de | 2020-09-11 16:12:25 +0900 | [diff] [blame] | 152 | if (is_linux || is_chromeos) { |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 153 | ldflags = [ "-Wl,--gc-sections" ] |
| 154 | |
Antonio Maiorano | 8478560 | 2020-02-21 15:37:37 -0500 | [diff] [blame] | 155 | if (current_cpu == "mipsel") { |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 156 | ldflags += [ |
| 157 | "-Wl,--hash-style=sysv", |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 158 | ] |
Milko Leporis | 0506982 | 2018-12-18 16:04:15 +0100 | [diff] [blame] | 159 | if (mips_arch_variant == "r1") { |
| 160 | ldflags += [ |
| 161 | "-mips32", |
| 162 | ] |
| 163 | } else { |
| 164 | ldflags += [ |
| 165 | "-mips32r2", |
| 166 | ] |
| 167 | } |
Antonio Maiorano | 8478560 | 2020-02-21 15:37:37 -0500 | [diff] [blame] | 168 | } else if (current_cpu == "mips64el") { |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 169 | ldflags += [ |
| 170 | "-Wl,--hash-style=sysv", |
| 171 | "-mips64r2", |
| 172 | ] |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 173 | } else { |
| 174 | ldflags += [ "-Wl,--hash-style=both" ] |
| 175 | } |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 176 | |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 177 | # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532) |
Antonio Maiorano | 8478560 | 2020-02-21 15:37:37 -0500 | [diff] [blame] | 178 | if (use_gold && (current_cpu == "x86" || current_cpu == "mipsel")) { |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 179 | ldflags += [ "-Wl,--icf=none" ] |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 180 | } |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 181 | } |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 182 | } |
| 183 | } |
| 184 | |
Corentin Wallez | 57eb063 | 2017-10-24 15:17:18 -0400 | [diff] [blame] | 185 | source_set("vertex_routine_fuzzer") { |
| 186 | sources = [ |
| 187 | "tests/fuzzers/VertexRoutineFuzzer.cpp" |
| 188 | ] |
Corentin Wallez | 6e27fea | 2017-10-27 13:40:18 -0400 | [diff] [blame] | 189 | if (is_win) { |
| 190 | cflags = [ |
| 191 | "/wd4201", # nameless struct/union |
| 192 | "/wd4065", # switch statement contains 'default' but no 'case' labels |
| 193 | "/wd5030", # attribute is not recognized |
| 194 | ] |
| 195 | } |
Corentin Wallez | 57eb063 | 2017-10-24 15:17:18 -0400 | [diff] [blame] | 196 | include_dirs = [ |
| 197 | "src/", |
| 198 | ] |
| 199 | deps = [ |
| 200 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static", |
| 201 | ] |
| 202 | } |
| 203 | |
Alexis Hetu | 68f564d | 2016-07-06 17:43:22 -0400 | [diff] [blame] | 204 | group("swiftshader") { |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 205 | data_deps = [ |
| 206 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2", |
| 207 | "src/OpenGL/libEGL:swiftshader_libEGL", |
| 208 | ] |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 209 | } |
| 210 | |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 211 | if (build_with_chromium) { |
| 212 | group("swiftshader_tests") { |
| 213 | testonly = true |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 214 | |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 215 | data_deps = [ |
| 216 | "tests/GLESUnitTests:swiftshader_unittests", |
David 'Digit' Turner | c9fa9fe | 2019-08-13 19:05:01 +0200 | [diff] [blame] | 217 | "tests/SystemUnitTests:swiftshader_system_unittests", |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 218 | ] |
Nicolas Capens | 282aa41 | 2020-11-16 11:37:29 -0500 | [diff] [blame] | 219 | |
| 220 | if (supports_llvm) { |
| 221 | data_deps += [ "tests/ReactorUnitTests:swiftshader_reactor_llvm_unittests" ] |
| 222 | } |
| 223 | |
| 224 | if (supports_subzero) { |
| 225 | data_deps += [ "tests/ReactorUnitTests:swiftshader_reactor_subzero_unittests" ] |
| 226 | } |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 227 | } |
David 'Digit' Turner | c9fa9fe | 2019-08-13 19:05:01 +0200 | [diff] [blame] | 228 | } |