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