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