blob: 56c78ce9cdc4c49d5e3032e55b82be381f6ba566 [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
Alexis Hetu2ddef882017-03-14 15:11:15 -040029 ]
30
Peter Collingbourne8e67eb92018-01-24 18:42:02 -080031 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 Hetu2ddef882017-03-14 15:11:15 -040042 defines += [
43 "_CRT_SECURE_NO_DEPRECATE",
44 "NOMINMAX",
45 "_WINDLL",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040046 "NO_SANITIZE_FUNCTION=",
Alexis Hetu03b67af2016-08-31 17:25:40 -040047 ]
Alexis Hetuc55dd842017-08-08 08:31:13 -040048
Robert Liaoe8d42ae2017-08-14 10:51:58 -070049 if (!is_debug) {
Alexis Hetuc55dd842017-08-08 08:31:13 -040050 defines += [ "ANGLE_DISABLE_TRACE" ]
51 }
Alexis Hetu03b67af2016-08-31 17:25:40 -040052 } else {
Alexis Hetua11d03e2017-01-27 11:38:59 -050053 cflags = [
54 "-std=c++11",
Alexis Hetu2c0546d2017-05-24 11:16:26 -040055 "-fno-exceptions",
Alexis Hetua11d03e2017-01-27 11:38:59 -050056 "-fno-operator-names",
Alexis Hetu2ddef882017-03-14 15:11:15 -040057 ]
58
59 defines += [
60 "__STDC_CONSTANT_MACROS",
61 "__STDC_LIMIT_MACROS",
Nicolas Capens506cc5e2017-07-24 11:30:55 -040062 "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))",
Alexis Hetua11d03e2017-01-27 11:38:59 -050063 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -040064
Alexis Hetuc55dd842017-08-08 08:31:13 -040065 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 Hetud6d10f92016-11-22 13:47:04 -050085 if (target_cpu == "x64") { # 64 bit version
Alexis Hetu91f10e32016-06-07 19:53:42 -040086 cflags += [
87 "-m64",
88 "-fPIC",
Nicolas Capens0424edc2018-01-03 14:06:30 -050089 "-march=x86-64",
90 "-mtune=generic",
Alexis Hetu91f10e32016-06-07 19:53:42 -040091 ]
Stephen Lanhamfe796492018-09-07 11:59:54 -070092 } else if (target_cpu == "x86") { # 32 bit version
Alexis Hetua11d03e2017-01-27 11:38:59 -050093 cflags += [
94 "-m32",
95 "-msse2",
Nicolas Capens0424edc2018-01-03 14:06:30 -050096 "-mfpmath=sse",
97 "-march=pentium4",
98 "-mtune=generic",
Alexis Hetua11d03e2017-01-27 11:38:59 -050099 ]
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200100 } else if (target_cpu == "mipsel" && current_cpu == target_cpu) {
101 cflags += [
102 "-march=mipsel",
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200103 "-fPIC",
104 "-mhard-float",
105 "-mfp32",
106 ]
Milko Leporis05069822018-12-18 16:04:15 +0100107 if (mips_arch_variant == "r1") {
108 cflags += [
109 "-mcpu=mips32",
110 ]
111 } else {
112 cflags += [
113 "-mcpu=mips32r2",
114 ]
115 }
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100116 } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
117 cflags += [
118 "-march=mips64el",
119 "-mcpu=mips64r2",
120 "-mabi=64",
121 "-fPIC",
122 ]
Alexis Hetu91f10e32016-06-07 19:53:42 -0400123 }
Alexis Hetua11d03e2017-01-27 11:38:59 -0500124
Alexis Hetub1031c82017-01-30 13:46:08 -0500125 if (is_linux) {
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200126 ldflags = [ "-Wl,--gc-sections" ]
127
128 if (target_cpu == "mipsel") {
129 ldflags += [
130 "-Wl,--hash-style=sysv",
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200131 ]
Milko Leporis05069822018-12-18 16:04:15 +0100132 if (mips_arch_variant == "r1") {
133 ldflags += [
134 "-mips32",
135 ]
136 } else {
137 ldflags += [
138 "-mips32r2",
139 ]
140 }
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100141 } else if (target_cpu == "mips64el") {
142 ldflags += [
143 "-Wl,--hash-style=sysv",
144 "-mips64r2",
145 ]
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200146 } else {
147 ldflags += [ "-Wl,--hash-style=both" ]
148 }
Alexis Hetu9441b072017-08-02 08:40:37 -0400149
Nicolas Capens0f7d4272017-06-05 13:24:09 -0400150 # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532)
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200151 if (use_gold && (target_cpu == "x86" || target_cpu == "mipsel")) {
Alexis Hetu9441b072017-08-02 08:40:37 -0400152 ldflags += [ "-Wl,--icf=none" ]
Nicolas Capens0f7d4272017-06-05 13:24:09 -0400153 }
Alexis Hetub1031c82017-01-30 13:46:08 -0500154 }
Alexis Hetu91f10e32016-06-07 19:53:42 -0400155 }
156}
157
Corentin Wallez57eb0632017-10-24 15:17:18 -0400158source_set("vertex_routine_fuzzer") {
159 sources = [
160 "tests/fuzzers/VertexRoutineFuzzer.cpp"
161 ]
Corentin Wallez6e27fea2017-10-27 13:40:18 -0400162 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 Wallez57eb0632017-10-24 15:17:18 -0400169 include_dirs = [
170 "src/",
171 ]
172 deps = [
173 "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static",
174 ]
175}
176
Alexis Hetu68f564d2016-07-06 17:43:22 -0400177group("swiftshader") {
Alexis Hetu996663b2016-09-21 13:47:42 -0400178 data_deps = [
179 "src/OpenGL/libGLESv2:swiftshader_libGLESv2",
180 "src/OpenGL/libEGL:swiftshader_libEGL",
181 ]
Alexis Hetua6e99c02016-11-16 13:53:57 -0500182}
183
184group("swiftshader_tests") {
185 testonly = true
186
187 data_deps = [
Alexis Hetud16a5042018-10-17 10:10:23 -0400188 "tests/GLESUnitTests:swiftshader_unittests",
Alexis Hetua6e99c02016-11-16 13:53:57 -0500189 ]
Alexis Hetud6d10f92016-11-22 13:47:04 -0500190}