1cc_defaults {
2    name: "llvm-defaults",
3    defaults: ["llvm-defaults-no-generated-headers"],
4    header_libs: ["llvm-headers"],
5    tidy_checks: [
6        "-google-build-*",
7        "-google-global-*",
8    ],
9    sanitize: {
10        hwaddress: false, // code size b/112437884
11    },
12}
13
14// This module defines all of the defaults used to compiled llvm, except for
15// the generated headers.  It is necessary to avoid a circular dependency
16// from the tblgen tool used to generate the headers to the generated headers.
17llvm_defaults {
18    name: "llvm-defaults-no-generated-headers",
19
20    host_supported: true,
21
22    cflags: [
23        "-D_GNU_SOURCE",
24        "-D__STDC_LIMIT_MACROS",
25        "-D__STDC_CONSTANT_MACROS",
26        "-D__STDC_FORMAT_MACROS",
27        "-fomit-frame-pointer",
28        "-Wall",
29        "-W",
30        "-Wno-cast-qual",
31        "-Wno-sign-compare",
32        "-Wno-unused-parameter",
33        "-Wno-maybe-uninitialized",
34        "-Wno-missing-field-initializers",
35        "-Wno-implicit-fallthrough",
36        "-Wwrite-strings",
37        "-Werror",
38        "-Dsprintf=sprintf",
39    ],
40
41    cppflags: [
42        "-Wno-sign-promo",
43        "-std=c++11",
44    ],
45
46    tidy_checks: [
47        "-google-build-*",
48        "-google-global-*",
49    ],
50
51    header_libs: ["llvm-headers-no-generated-headers"],
52
53    target: {
54        android: {
55            cflags: [
56                "-finline-functions",
57            ],
58        },
59        linux: {
60            cppflags: [
61                "-Woverloaded-virtual",
62            ],
63        },
64        host: {
65            cppflags: [
66                "-fno-rtti",
67                "-fno-exceptions",
68            ],
69        },
70        windows: {
71            // Disable certain warnings for use with mingw.
72            // We also must undefine WIN32_LEAN_AND_MEAN, since it is being passed globally
73            // on the command line, and LLVM defines this internally itself.
74            cflags: [
75                "-Wno-array-bounds",
76                "-Wno-comment",
77                "-UWIN32_LEAN_AND_MEAN",
78            ],
79
80            host_ldlibs: ["-luuid"],
81        },
82        linux_glibc: {
83            // Add on ncurses to have support for terminfo
84            host_ldlibs: [
85                "-lncurses",
86                "-lgcc_s",
87            ],
88        },
89        darwin: {
90            cppflags: [
91                "-Wno-deprecated-declarations",
92                "-Woverloaded-virtual",
93            ],
94
95            // Add on ncurses to have support for terminfo
96            host_ldlibs: [
97                "-lncurses",
98            ],
99        },
100    },
101}
102
103cc_library_headers {
104    name: "llvm-headers-no-generated-headers",
105    vendor_available: true,
106    host_supported: true,
107    export_include_dirs: ["include"],
108    target: {
109        android: {
110            export_include_dirs: ["device/include"],
111        },
112        host: {
113            export_include_dirs: ["host/include"],
114        },
115        linux_bionic: {
116            enabled: true,
117        },
118        windows: {
119            enabled: true,
120        },
121    },
122}
123
124cc_library_headers {
125    name: "llvm-headers",
126    vendor_available: true,
127    host_supported: true,
128    header_libs: ["llvm-headers-no-generated-headers"],
129    export_header_lib_headers: ["llvm-headers-no-generated-headers"],
130    generated_headers: [
131        "llvm-gen-attributes",
132        "llvm-gen-intrinsics",
133    ],
134    export_generated_headers: [
135        "llvm-gen-attributes",
136        "llvm-gen-intrinsics",
137    ],
138    target: {
139        windows: {
140            enabled: true,
141        },
142    },
143}
144
145llvm_tblgen {
146    name: "llvm-gen-attributes",
147    in: "include/llvm/IR/Attributes.td",
148    outs: ["llvm/IR/Attributes.inc"],
149}
150
151llvm_tblgen {
152    name: "llvm-gen-intrinsics",
153    in: "include/llvm/IR/Intrinsics.td",
154    outs: ["llvm/IR/Intrinsics.gen"],
155}
156
157force_build_llvm_components_defaults {
158    name: "force_build_llvm_components",
159    // Host build disabled by soong/llvm.go unless FORCE_BUILD_LLVM_COMPONENTS
160    // environment variable is set
161}
162
163// LLVM shared library build
164
165llvm_arm_static_libraries = [
166    "libLLVMARMCodeGen",
167    "libLLVMARMAsmParser",
168    "libLLVMARMAsmPrinter",
169    "libLLVMARMInfo",
170    "libLLVMARMDesc",
171    "libLLVMARMDisassembler",
172]
173
174llvm_x86_static_libraries = [
175    "libLLVMX86CodeGen",
176    "libLLVMX86Info",
177    "libLLVMX86Desc",
178    "libLLVMX86AsmParser",
179    "libLLVMX86AsmPrinter",
180    "libLLVMX86Utils",
181    "libLLVMX86Disassembler",
182]
183
184llvm_mips_static_libraries = [
185    "libLLVMMipsCodeGen",
186    "libLLVMMipsInfo",
187    "libLLVMMipsDesc",
188    "libLLVMMipsAsmParser",
189    "libLLVMMipsAsmPrinter",
190    "libLLVMMipsDisassembler",
191]
192
193llvm_aarch64_static_libraries = [
194    "libLLVMAArch64CodeGen",
195    "libLLVMAArch64Info",
196    "libLLVMAArch64Desc",
197    "libLLVMAArch64AsmParser",
198    "libLLVMAArch64AsmPrinter",
199    "libLLVMAArch64Utils",
200    "libLLVMAArch64Disassembler",
201]
202
203cc_library {
204    host_supported: true,
205    name: "libLLVM_android",
206    vendor_available: true,
207    defaults: [
208        "llvm-defaults",
209        "force_build_llvm_components",
210    ],
211
212    whole_static_libs: [
213        // pre static libraries
214        "libLLVMLinker",
215        "libLLVMipo",
216        "libLLVMDebugInfoDWARF",
217        "libLLVMDebugInfoPDB",
218        "libLLVMSymbolize",
219        "libLLVMIRReader",
220        "libLLVMBitWriter",
221        "libLLVMBitReader",
222
223        // post static libraries
224        "libLLVMLTO",
225        "libLLVMAsmPrinter",
226        "libLLVMSelectionDAG",
227        "libLLVMCodeGen",
228        "libLLVMDebugInfoCodeView",
229        "libLLVMObject",
230        "libLLVMScalarOpts",
231        "libLLVMInstCombine",
232        "libLLVMInstrumentation",
233        "libLLVMTransformObjCARC",
234        "libLLVMTransformUtils",
235        "libLLVMAnalysis",
236        "libLLVMTarget",
237        "libLLVMGlobalISel",
238        "libLLVMMCDisassembler",
239        "libLLVMMC",
240        "libLLVMMCParser",
241        "libLLVMCore",
242        "libLLVMAsmParser",
243        "libLLVMOption",
244        "libLLVMSupport",
245        "libLLVMVectorize",
246        "libLLVMProfileData",
247        "libLLVMProfileDataCoverage",
248        "libLLVMLibDriver",
249        "libLLVMExecutionEngine",
250        "libLLVMRuntimeDyld",
251        "libLLVMMCJIT",
252        "libLLVMOrcJIT",
253    ],
254
255    export_include_dirs: ["include"],
256
257    target: {
258        host: {
259            // Host build pulls in all ARM, Mips, X86 components.
260           whole_static_libs: llvm_arm_static_libraries +
261                llvm_aarch64_static_libraries +
262                llvm_mips_static_libraries +
263                llvm_x86_static_libraries,
264            export_include_dirs: ["host/include"],
265        },
266        windows: {
267            enabled: true,
268            host_ldlibs: [
269                "-limagehlp",
270                "-lpsapi",
271                "-lole32",
272                "-lversion",
273            ],
274        },
275        android: {
276            export_include_dirs: ["device/include"],
277        },
278        android_arm: {
279            whole_static_libs: llvm_arm_static_libraries,
280        },
281        android_x86: {
282            whole_static_libs: llvm_x86_static_libraries +
283                llvm_arm_static_libraries +
284                llvm_aarch64_static_libraries,
285        },
286        android_x86_64: {
287            whole_static_libs: llvm_x86_static_libraries +
288                llvm_arm_static_libraries +
289                llvm_aarch64_static_libraries,
290        },
291        android_mips: {
292            whole_static_libs: llvm_mips_static_libraries,
293        },
294        android_mips64: {
295            whole_static_libs: llvm_mips_static_libraries,
296        },
297        android_arm64: {
298            whole_static_libs: llvm_aarch64_static_libraries +
299                llvm_arm_static_libraries,
300        },
301    },
302}
303
304subdirs = [
305    "soong",
306    "lib",
307    "tools/*",
308    "utils/*",
309]
310