blob: eba67888edad8458d0cd42837da2793278a6de85 [file] [log] [blame]
Alexis Hetu91f10e32016-06-07 19:53:42 -04001# 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 Collingbourne8e67eb92018-01-24 18:42:02 -080015import("//build/config/c++/c++.gni")
Nicolas Capensd51e2162017-06-05 13:59:55 -040016import("//build/config/compiler/compiler.gni")
Milko Leporis05069822018-12-18 16:04:15 +010017import("//build/config/mips.gni")
Nicolas Capensd51e2162017-06-05 13:59:55 -040018
Alexis Hetu91f10e32016-06-07 19:53:42 -040019config("swiftshader_config") {
Alexis Hetu0def1022017-08-16 17:15:48 -040020 defines = []
Alexis Hetu2ddef882017-03-14 15:11:15 -040021
Alexis Hetu03b67af2016-08-31 17:25:40 -040022 if (is_win) {
23 cflags = [
Alexis Hetud6d10f92016-11-22 13:47:04 -050024 "/GS", # Detects some buffer overruns
Alexis Hetu03b67af2016-08-31 17:25:40 -040025 "/Zc:wchar_t",
Reid Klecknerd19db3d2017-11-29 10:45:53 -080026 "/EHs-c-", # Disable C++ exceptions
Alexis Hetu03b67af2016-08-31 17:25:40 -040027 "/nologo",
Alexis Hetud6d10f92016-11-22 13:47:04 -050028 "/Gd", # Default calling convention
Jamie Madillbbd8c422019-08-28 17:08:17 -040029 # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8
30 "/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
Alexis Hetu2ddef882017-03-14 15:11:15 -040031 ]
32
Peter Collingbourne8e67eb92018-01-24 18:42:02 -080033 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 Hetu2ddef882017-03-14 15:11:15 -040044 defines += [
45 "_CRT_SECURE_NO_DEPRECATE",
46 "NOMINMAX",
47 "_WINDLL",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040048 "NO_SANITIZE_FUNCTION=",
Alexis Hetu03b67af2016-08-31 17:25:40 -040049 ]
Alexis Hetuc55dd842017-08-08 08:31:13 -040050
Robert Liaoe8d42ae2017-08-14 10:51:58 -070051 if (!is_debug) {
Alexis Hetuc55dd842017-08-08 08:31:13 -040052 defines += [ "ANGLE_DISABLE_TRACE" ]
53 }
Jamie Madill9746f8b2019-09-05 13:17:09 -040054
55 # Diable some MSVC warnings.
56 if (!is_clang) {
57 cflags += [
Jonah Ryan-Davis5fc197d2020-01-15 13:08:17 -050058 "/wd4065", # switch statement contains 'default' but no 'case' labels
Jamie Madill9746f8b2019-09-05 13:17:09 -040059 "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts of signed shorts.
60 ]
61 }
Alexis Hetu03b67af2016-08-31 17:25:40 -040062 } else {
Alexis Hetua11d03e2017-01-27 11:38:59 -050063 cflags = [
Ben Clayton3cc0aea2020-01-08 19:09:25 +000064 "-std=c++14",
Alexis Hetu2c0546d2017-05-24 11:16:26 -040065 "-fno-exceptions",
Alexis Hetua11d03e2017-01-27 11:38:59 -050066 "-fno-operator-names",
Alexis Hetu2ddef882017-03-14 15:11:15 -040067 ]
68
69 defines += [
70 "__STDC_CONSTANT_MACROS",
71 "__STDC_LIMIT_MACROS",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040072 "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
Alexis Hetua11d03e2017-01-27 11:38:59 -050073 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040074
Alexis Hetuc55dd842017-08-08 08:31:13 -040075 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
Alexis Hetud6d10f92016-11-22 13:47:04 -050095 if (target_cpu == "x64") { # 64 bit version
Alexis Hetu91f10e32016-06-07 19:53:42 -040096 cflags += [
97 "-m64",
98 "-fPIC",
Nicolas Capens0424edc2018-01-03 14:06:30 -050099 "-march=x86-64",
100 "-mtune=generic",
Alexis Hetu91f10e32016-06-07 19:53:42 -0400101 ]
Stephen Lanhamfe796492018-09-07 11:59:54 -0700102 } else if (target_cpu == "x86") { # 32 bit version
Alexis Hetua11d03e2017-01-27 11:38:59 -0500103 cflags += [
104 "-m32",
105 "-msse2",
Nicolas Capens0424edc2018-01-03 14:06:30 -0500106 "-mfpmath=sse",
107 "-march=pentium4",
108 "-mtune=generic",
Alexis Hetua11d03e2017-01-27 11:38:59 -0500109 ]
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200110 } else if (target_cpu == "mipsel" && current_cpu == target_cpu) {
111 cflags += [
112 "-march=mipsel",
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200113 "-fPIC",
114 "-mhard-float",
115 "-mfp32",
116 ]
Milko Leporis05069822018-12-18 16:04:15 +0100117 if (mips_arch_variant == "r1") {
118 cflags += [
119 "-mcpu=mips32",
120 ]
121 } else {
122 cflags += [
123 "-mcpu=mips32r2",
124 ]
125 }
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100126 } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
127 cflags += [
128 "-march=mips64el",
129 "-mcpu=mips64r2",
130 "-mabi=64",
131 "-fPIC",
132 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -0400133 }
Alexis Hetua11d03e2017-01-27 11:38:59 -0500134
Alexis Hetub1031c82017-01-30 13:46:08 -0500135 if (is_linux) {
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200136 ldflags = [ "-Wl,--gc-sections" ]
137
138 if (target_cpu == "mipsel") {
139 ldflags += [
140 "-Wl,--hash-style=sysv",
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200141 ]
Milko Leporis05069822018-12-18 16:04:15 +0100142 if (mips_arch_variant == "r1") {
143 ldflags += [
144 "-mips32",
145 ]
146 } else {
147 ldflags += [
148 "-mips32r2",
149 ]
150 }
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100151 } else if (target_cpu == "mips64el") {
152 ldflags += [
153 "-Wl,--hash-style=sysv",
154 "-mips64r2",
155 ]
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200156 } else {
157 ldflags += [ "-Wl,--hash-style=both" ]
158 }
Alexis Hetu9441b072017-08-02 08:40:37 -0400159
Nicolas Capens0f7d4272017-06-05 13:24:09 -0400160 # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200161 if (use_gold && (target_cpu == "x86" || target_cpu == "mipsel")) {
Alexis Hetu9441b072017-08-02 08:40:37 -0400162 ldflags += [ "-Wl,--icf=none" ]
Nicolas Capens0f7d4272017-06-05 13:24:09 -0400163 }
Alexis Hetub1031c82017-01-30 13:46:08 -0500164 }
Alexis Hetu91f10e32016-06-07 19:53:42 -0400165 }
166}
167
Corentin Wallez57eb0632017-10-24 15:17:18 -0400168source_set("vertex_routine_fuzzer") {
169 sources = [
170 "tests/fuzzers/VertexRoutineFuzzer.cpp"
171 ]
Corentin Wallez6e27fea2017-10-27 13:40:18 -0400172 if (is_win) {
173 cflags = [
174 "/wd4201", # nameless struct/union
175 "/wd4065", # switch statement contains 'default' but no 'case' labels
176 "/wd5030", # attribute is not recognized
177 ]
178 }
Corentin Wallez57eb0632017-10-24 15:17:18 -0400179 include_dirs = [
180 "src/",
181 ]
182 deps = [
183 "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static",
184 ]
185}
186
Alexis Hetu68f564d2016-07-06 17:43:22 -0400187group("swiftshader") {
Alexis Hetu996663b2016-09-21 13:47:42 -0400188 data_deps = [
189 "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
190 "src/OpenGL/libEGL:swiftshader_libEGL",
191 ]
Alexis Hetua6e99c02016-11-16 13:53:57 -0500192}
193
Jamie Madillbbd8c422019-08-28 17:08:17 -0400194if (build_with_chromium) {
195 group("swiftshader_tests") {
196 testonly = true
Alexis Hetua6e99c02016-11-16 13:53:57 -0500197
Jamie Madillbbd8c422019-08-28 17:08:17 -0400198 data_deps = [
199 "tests/GLESUnitTests:swiftshader_unittests",
David 'Digit' Turnerc9fa9fe2019-08-13 19:05:01 +0200200 "tests/SystemUnitTests:swiftshader_system_unittests",
Jamie Madillbbd8c422019-08-28 17:08:17 -0400201 ]
202 }
David 'Digit' Turnerc9fa9fe2019-08-13 19:05:01 +0200203}