blob: 8ff16313c7d1e3254f4ac1d739428d5afcb65f72 [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
Antonio Maiorano84785602020-02-21 15:37:37 -050095 if (current_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 ]
Antonio Maiorano84785602020-02-21 15:37:37 -0500102 } else if (current_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 += [
Jiaxun Yang55275c32020-02-09 14:52:42 +0800112 "-EL",
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200113 "-fPIC",
114 "-mhard-float",
115 "-mfp32",
Jiaxun Yang55275c32020-02-09 14:52:42 +0800116 "-mxgot",
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200117 ]
Milko Leporis05069822018-12-18 16:04:15 +0100118 if (mips_arch_variant == "r1") {
119 cflags += [
Jiaxun Yang55275c32020-02-09 14:52:42 +0800120 "-march=mips32",
Milko Leporis05069822018-12-18 16:04:15 +0100121 ]
122 } else {
123 cflags += [
Jiaxun Yang55275c32020-02-09 14:52:42 +0800124 "-march=mips32r2",
Milko Leporis05069822018-12-18 16:04:15 +0100125 ]
126 }
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100127 } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
128 cflags += [
Jiaxun Yang55275c32020-02-09 14:52:42 +0800129 "-EL",
130 "-arch=mips64r2",
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100131 "-mabi=64",
132 "-fPIC",
Jiaxun Yang55275c32020-02-09 14:52:42 +0800133 "-mxgot",
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100134 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -0400135 }
Alexis Hetua11d03e2017-01-27 11:38:59 -0500136
Alexis Hetub1031c82017-01-30 13:46:08 -0500137 if (is_linux) {
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200138 ldflags = [ "-Wl,--gc-sections" ]
139
Antonio Maiorano84785602020-02-21 15:37:37 -0500140 if (current_cpu == "mipsel") {
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200141 ldflags += [
142 "-Wl,--hash-style=sysv",
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200143 ]
Milko Leporis05069822018-12-18 16:04:15 +0100144 if (mips_arch_variant == "r1") {
145 ldflags += [
146 "-mips32",
147 ]
148 } else {
149 ldflags += [
150 "-mips32r2",
151 ]
152 }
Antonio Maiorano84785602020-02-21 15:37:37 -0500153 } else if (current_cpu == "mips64el") {
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100154 ldflags += [
155 "-Wl,--hash-style=sysv",
156 "-mips64r2",
157 ]
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200158 } else {
159 ldflags += [ "-Wl,--hash-style=both" ]
160 }
Alexis Hetu9441b072017-08-02 08:40:37 -0400161
Nicolas Capens0f7d4272017-06-05 13:24:09 -0400162 # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
Antonio Maiorano84785602020-02-21 15:37:37 -0500163 if (use_gold && (current_cpu == "x86" || current_cpu == "mipsel")) {
Alexis Hetu9441b072017-08-02 08:40:37 -0400164 ldflags += [ "-Wl,--icf=none" ]
Nicolas Capens0f7d4272017-06-05 13:24:09 -0400165 }
Alexis Hetub1031c82017-01-30 13:46:08 -0500166 }
Alexis Hetu91f10e32016-06-07 19:53:42 -0400167 }
168}
169
Corentin Wallez57eb0632017-10-24 15:17:18 -0400170source_set("vertex_routine_fuzzer") {
171 sources = [
172 "tests/fuzzers/VertexRoutineFuzzer.cpp"
173 ]
Corentin Wallez6e27fea2017-10-27 13:40:18 -0400174 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 Wallez57eb0632017-10-24 15:17:18 -0400181 include_dirs = [
182 "src/",
183 ]
184 deps = [
185 "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static",
186 ]
187}
188
Alexis Hetu68f564d2016-07-06 17:43:22 -0400189group("swiftshader") {
Alexis Hetu996663b2016-09-21 13:47:42 -0400190 data_deps = [
191 "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
192 "src/OpenGL/libEGL:swiftshader_libEGL",
193 ]
Alexis Hetua6e99c02016-11-16 13:53:57 -0500194}
195
Jamie Madillbbd8c422019-08-28 17:08:17 -0400196if (build_with_chromium) {
197 group("swiftshader_tests") {
198 testonly = true
Alexis Hetua6e99c02016-11-16 13:53:57 -0500199
Jamie Madillbbd8c422019-08-28 17:08:17 -0400200 data_deps = [
201 "tests/GLESUnitTests:swiftshader_unittests",
David 'Digit' Turnerc9fa9fe2019-08-13 19:05:01 +0200202 "tests/SystemUnitTests:swiftshader_system_unittests",
Jamie Madillbbd8c422019-08-28 17:08:17 -0400203 ]
204 }
David 'Digit' Turnerc9fa9fe2019-08-13 19:05:01 +0200205}