OSDN Git Service

Extra warnings suppression for Chromium
[android-x86/external-swiftshader.git] / src / Reactor / BUILD.gn
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
15 import("../swiftshader.gni")
16
17 declare_args() {
18   # Currently, Subzero is not used by default
19   # LLVM is still the default backend
20   use_swiftshader_with_subzero = is_win || is_linux
21 }
22
23 # Need a separate config to ensure the warnings are added to the end.
24 config("swiftshader_subzero_common_private_config") {
25   defines = [
26     "ALLOW_DUMP=0",
27     "ALLOW_TIMERS=0",
28     "ALLOW_LLVM_CL=0",
29     "ALLOW_LLVM_IR=0",
30     "ALLOW_LLVM_IR_AS_INPUT=0",
31     "ALLOW_MINIMAL_BUILD=0",
32     "ALLOW_WASM=0",
33     "ICE_THREAD_LOCAL_HACK=0",
34   ]
35
36   if (is_win) {
37     defines += [ "SUBZERO_USE_MICROSOFT_ABI" ]
38   }
39
40   if (target_cpu == "x64") {
41     defines += [
42       "SZTARGET=X8664",
43       "SUBZERO_TARGET=X8664",
44     ]
45   } else {
46     defines += [
47       "SZTARGET=X8632",
48       "SUBZERO_TARGET=X8632",
49     ]
50   }
51
52   include_dirs = [
53     "../../third_party/subzero",
54     "../../third_party/subzero/pnacl-llvm/include/",
55     "../../third_party/llvm-subzero/include/",
56   ]
57
58   if (is_win) {
59     include_dirs += [ "../../third_party/llvm-subzero/build/Windows/include/" ]
60   } else if (is_linux) {
61     include_dirs += [ "../../third_party/llvm-subzero/build/Linux/include/" ]
62   } else if (is_mac) {
63     include_dirs += [ "../../third_party/llvm-subzero/build/MacOS/include/" ]
64   }
65 }
66
67 config("swiftshader_subzero_private_config") {
68   cflags = []
69
70   if (is_win) {
71     cflags += [
72       "/wd4005",
73       "/wd4018",
74       "/wd4141",
75       "/wd4146",
76       "/wd4245",  # conversion from int to unsigned int (llvm)
77       "/wd4267",
78       "/wd4291",
79       "/wd4310",
80       "/wd4334",
81       "/wd4389",
82       "/wd4701",
83       "/wd4702",
84       "/wd4703",
85       "/wd4706",
86       "/wd4800",
87     ]
88
89     if (!is_debug) {
90       cflags += [ "/wd4718" ]
91     }
92
93     if (is_clang) {
94       if (is_debug) {
95         cflags += [ "-Wno-sign-compare" ]
96       }
97     }
98   } else if (is_linux || is_mac) {
99     cflags += [ "-Wno-macro-redefined" ]
100   }
101
102   if (is_clang) {
103     cflags += [ "-Wno-header-hygiene" ]
104   }
105 }
106
107 config("swiftshader_reactor_with_subzero_private_config") {
108   cflags = []
109
110   if (is_win) {
111     cflags += [
112       "/wd4141",
113       "/wd4146",
114       "/wd4245",  # conversion from int to unsigned int (llvm)
115       "/wd4267",
116       "/wd4291",
117       "/wd4309",
118       "/wd4702",
119       "/wd4800",
120     ]
121
122     if (use_swiftshader_with_subzero) {
123       cflags += [
124         "/wd4018",  # signed/unsigned mismatch (llvm)
125         "/wd4310",  # cast truncates constant value (llvm)
126       ]
127     }
128
129     if (is_clang) {
130       if (is_debug) {
131         cflags += [ "-Wno-sign-compare" ]
132       }
133     }
134   }
135
136   if (is_clang) {
137     cflags += [ "-Wno-header-hygiene" ]
138   }
139 }
140
141 config("swiftshader_reactor_private_config") {
142   if (is_win) {
143     cflags = [
144       "/wd4201",  # nameless struct/union
145       "/wd4245",  # conversion from int to unsigned int (llvm)
146     ]
147   } else {
148     cflags = [
149       "-Wno-unused-local-typedef",
150       "-msse2",
151     ]
152
153     defines = [
154       "__STDC_CONSTANT_MACROS",
155       "__STDC_LIMIT_MACROS",
156     ]
157   }
158 }
159
160 if (use_swiftshader_with_subzero) {
161   swiftshader_source_set("swiftshader_subzero") {
162     subzero_dir = "../../third_party/subzero"
163     subzero_llvm_dir = "../../third_party/llvm-subzero"
164
165     sources = [
166       "$subzero_dir/src/IceAssembler.cpp",
167       "$subzero_dir/src/IceCfg.cpp",
168       "$subzero_dir/src/IceCfgNode.cpp",
169       "$subzero_dir/src/IceClFlags.cpp",
170       "$subzero_dir/src/IceELFObjectWriter.cpp",
171       "$subzero_dir/src/IceELFSection.cpp",
172       "$subzero_dir/src/IceFixups.cpp",
173       "$subzero_dir/src/IceGlobalContext.cpp",
174       "$subzero_dir/src/IceGlobalInits.cpp",
175       "$subzero_dir/src/IceInst.cpp",
176       "$subzero_dir/src/IceInstrumentation.cpp",
177       "$subzero_dir/src/IceIntrinsics.cpp",
178       "$subzero_dir/src/IceLiveness.cpp",
179       "$subzero_dir/src/IceLoopAnalyzer.cpp",
180       "$subzero_dir/src/IceMangling.cpp",
181       "$subzero_dir/src/IceMemory.cpp",
182       "$subzero_dir/src/IceOperand.cpp",
183       "$subzero_dir/src/IceRNG.cpp",
184       "$subzero_dir/src/IceRangeSpec.cpp",
185       "$subzero_dir/src/IceRegAlloc.cpp",
186       "$subzero_dir/src/IceRevision.cpp",
187       "$subzero_dir/src/IceSwitchLowering.cpp",
188       "$subzero_dir/src/IceTargetLowering.cpp",
189       "$subzero_dir/src/IceTargetLoweringX86.cpp",
190       "$subzero_dir/src/IceThreading.cpp",
191       "$subzero_dir/src/IceTimerTree.cpp",
192       "$subzero_dir/src/IceTypes.cpp",
193       "$subzero_dir/src/IceVariableSplitting.cpp",
194       "$subzero_llvm_dir/lib/Demangle/ItaniumDemangle.cpp",
195       "$subzero_llvm_dir/lib/Support/APInt.cpp",
196       "$subzero_llvm_dir/lib/Support/Atomic.cpp",
197       "$subzero_llvm_dir/lib/Support/CommandLine.cpp",
198       "$subzero_llvm_dir/lib/Support/ConvertUTF.cpp",
199       "$subzero_llvm_dir/lib/Support/ConvertUTFWrapper.cpp",
200       "$subzero_llvm_dir/lib/Support/Debug.cpp",
201       "$subzero_llvm_dir/lib/Support/Errno.cpp",
202       "$subzero_llvm_dir/lib/Support/ErrorHandling.cpp",
203       "$subzero_llvm_dir/lib/Support/FoldingSet.cpp",
204       "$subzero_llvm_dir/lib/Support/Hashing.cpp",
205       "$subzero_llvm_dir/lib/Support/Host.cpp",
206       "$subzero_llvm_dir/lib/Support/ManagedStatic.cpp",
207       "$subzero_llvm_dir/lib/Support/MemoryBuffer.cpp",
208       "$subzero_llvm_dir/lib/Support/Mutex.cpp",
209       "$subzero_llvm_dir/lib/Support/NativeFormatting.cpp",
210       "$subzero_llvm_dir/lib/Support/Path.cpp",
211       "$subzero_llvm_dir/lib/Support/Process.cpp",
212       "$subzero_llvm_dir/lib/Support/Program.cpp",
213       "$subzero_llvm_dir/lib/Support/Regex.cpp",
214       "$subzero_llvm_dir/lib/Support/Signals.cpp",
215       "$subzero_llvm_dir/lib/Support/SmallPtrSet.cpp",
216       "$subzero_llvm_dir/lib/Support/SmallVector.cpp",
217       "$subzero_llvm_dir/lib/Support/StringExtras.cpp",
218       "$subzero_llvm_dir/lib/Support/StringMap.cpp",
219       "$subzero_llvm_dir/lib/Support/StringRef.cpp",
220       "$subzero_llvm_dir/lib/Support/StringSaver.cpp",
221       "$subzero_llvm_dir/lib/Support/TargetParser.cpp",
222       "$subzero_llvm_dir/lib/Support/Threading.cpp",
223       "$subzero_llvm_dir/lib/Support/Timer.cpp",
224       "$subzero_llvm_dir/lib/Support/Triple.cpp",
225       "$subzero_llvm_dir/lib/Support/Twine.cpp",
226       "$subzero_llvm_dir/lib/Support/circular_raw_ostream.cpp",
227       "$subzero_llvm_dir/lib/Support/raw_os_ostream.cpp",
228       "$subzero_llvm_dir/lib/Support/raw_ostream.cpp",
229       "$subzero_llvm_dir/lib/Support/regcomp.c",
230       "$subzero_llvm_dir/lib/Support/regerror.c",
231       "$subzero_llvm_dir/lib/Support/regexec.c",
232       "$subzero_llvm_dir/lib/Support/regfree.c",
233       "$subzero_llvm_dir/lib/Support/regstrlcpy.c",
234     ]
235
236     if (target_cpu == "x64") {
237       sources += [
238         "$subzero_dir/src/IceInstX8664.cpp",
239         "$subzero_dir/src/IceTargetLoweringX8664.cpp",
240       ]
241     } else {
242       sources += [
243         "$subzero_dir/src/IceInstX8632.cpp",
244         "$subzero_dir/src/IceTargetLoweringX8632.cpp",
245       ]
246     }
247
248     configs = [
249       ":swiftshader_subzero_common_private_config",
250       ":swiftshader_subzero_private_config",
251     ]
252   }
253 }
254
255 swiftshader_source_set("swiftshader_reactor") {
256   deps = [
257     "../OpenGL/common:swiftshader_opengl_common",
258   ]
259
260   sources = [
261     "Routine.cpp",
262   ]
263
264   if (use_swiftshader_with_subzero) {
265     deps += [ ":swiftshader_subzero" ]
266
267     sources += [
268       "Optimizer.cpp",
269       "SubzeroReactor.cpp",
270     ]
271
272     configs = [
273       ":swiftshader_subzero_common_private_config",
274       ":swiftshader_reactor_with_subzero_private_config",
275     ]
276   } else {
277     deps += [ "../../third_party/LLVM:swiftshader_llvm" ]
278
279     sources += [
280       "LLVMReactor.cpp",
281       "LLVMRoutine.cpp",
282       "LLVMRoutineManager.cpp",
283     ]
284
285     configs = [ ":swiftshader_reactor_private_config" ]
286
287     include_dirs = [
288       "..",
289       "../Common",
290       "../../third_party/LLVM/include/",
291     ]
292   }
293 }