xref: /aosp_15_r20/external/llvm/Android.bp (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1package {
2    default_applicable_licenses: ["external_llvm_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18//
19// large-scale-change included anything that looked like it might be a license
20// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
21//
22// Please consider removing redundant or irrelevant files from 'license_text:'.
23//
24// large-scale-change filtered out the below license kinds as false-positives:
25//   SPDX-license-identifier-GPL
26//   SPDX-license-identifier-GPL-3.0
27// See: http://go/android-license-faq
28license {
29    name: "external_llvm_license",
30    visibility: [":__subpackages__"],
31    license_kinds: [
32        "SPDX-license-identifier-Apache-2.0",
33        "SPDX-license-identifier-BSD",
34        "SPDX-license-identifier-MIT",
35        "SPDX-license-identifier-NCSA",
36        "legacy_permissive",
37        "legacy_unencumbered",
38    ],
39    license_text: [
40        "LICENSE.TXT",
41        "NOTICE",
42    ],
43}
44
45cc_defaults {
46    name: "llvm-defaults",
47    defaults: ["llvm-defaults-no-generated-headers"],
48    header_libs: ["llvm-headers"],
49    tidy_checks: [
50        "-google-build-*",
51        "-google-global-*",
52    ],
53    sanitize: {
54        hwaddress: false, // code size b/112437884
55    },
56    arch: {
57        riscv64: {
58            enabled: false,
59        },
60    },
61}
62
63// This module defines all of the defaults used to compiled llvm, except for
64// the generated headers.  It is necessary to avoid a circular dependency
65// from the tblgen tool used to generate the headers to the generated headers.
66llvm_defaults {
67    name: "llvm-defaults-no-generated-headers",
68
69    host_supported: true,
70    // TODO(b/153609531): remove when no longer needed.
71    native_bridge_supported: true,
72
73    cpp_std: "c++11",
74
75    // Optimize for size. It is only used by Renderscript, which is deprecated and is rarely
76    // used.
77    optimize_for_size: true,
78
79    cflags: [
80        "-D_GNU_SOURCE",
81        "-D__STDC_LIMIT_MACROS",
82        "-D__STDC_CONSTANT_MACROS",
83        "-D__STDC_FORMAT_MACROS",
84        "-fomit-frame-pointer",
85        "-Wno-cast-qual",
86        "-Wno-sign-compare",
87        "-Wno-unused-parameter",
88        "-Wno-maybe-uninitialized",
89        "-Wno-missing-field-initializers",
90        "-Wno-implicit-fallthrough",
91        "-Wno-deprecated-declarations",
92        "-Wwrite-strings",
93        "-Dsprintf=sprintf",
94    ],
95
96    cppflags: [
97        "-Wno-sign-promo",
98    ],
99
100    tidy_checks: [
101        "-google-build-*",
102        "-google-global-*",
103    ],
104
105    header_libs: ["llvm-headers-no-generated-headers"],
106
107    target: {
108        android: {
109            cflags: [
110                "-finline-functions",
111            ],
112        },
113        linux: {
114            cppflags: [
115                "-Woverloaded-virtual",
116            ],
117        },
118        host: {
119            cppflags: [
120                "-fno-rtti",
121                "-fno-exceptions",
122            ],
123        },
124        windows: {
125            // Disable certain warnings for use with mingw.
126            // We also must undefine WIN32_LEAN_AND_MEAN, since it is being passed globally
127            // on the command line, and LLVM defines this internally itself.
128            cflags: [
129                "-Wno-array-bounds",
130                "-Wno-comment",
131                "-UWIN32_LEAN_AND_MEAN",
132            ],
133
134            host_ldlibs: ["-luuid"],
135        },
136        linux_glibc: {
137            host_ldlibs: [
138                "-lgcc_s",
139            ],
140        },
141        darwin: {
142            cppflags: [
143                "-Wno-deprecated-declarations",
144                "-Woverloaded-virtual",
145            ],
146        },
147    },
148}
149
150cc_library_headers {
151    name: "llvm-headers-no-generated-headers",
152    vendor_available: true,
153    product_available: true,
154    host_supported: true,
155    // TODO(b/153609531): remove when no longer needed.
156    native_bridge_supported: true,
157    export_include_dirs: ["include"],
158    target: {
159        android: {
160            export_include_dirs: ["device/include"],
161        },
162        host: {
163            export_include_dirs: ["host/include"],
164        },
165        linux_bionic: {
166            enabled: true,
167        },
168        windows: {
169            enabled: true,
170        },
171    },
172}
173
174cc_library_headers {
175    name: "llvm-headers",
176    vendor_available: true,
177    product_available: true,
178    host_supported: true,
179    // TODO(b/153609531): remove when no longer needed.
180    native_bridge_supported: true,
181    header_libs: ["llvm-headers-no-generated-headers"],
182    export_header_lib_headers: ["llvm-headers-no-generated-headers"],
183    generated_headers: [
184        "llvm-gen-attributes",
185        "llvm-gen-intrinsics",
186    ],
187    export_generated_headers: [
188        "llvm-gen-attributes",
189        "llvm-gen-intrinsics",
190    ],
191    target: {
192        windows: {
193            enabled: true,
194        },
195    },
196}
197
198llvm_tblgen {
199    name: "llvm-gen-attributes",
200    in: "include/llvm/IR/Attributes.td",
201    outs: ["llvm/IR/Attributes.inc"],
202}
203
204llvm_tblgen {
205    name: "llvm-gen-intrinsics",
206    in: "include/llvm/IR/Intrinsics.td",
207    outs: ["llvm/IR/Intrinsics.gen"],
208}
209
210force_build_llvm_components_defaults {
211    name: "force_build_llvm_components",
212    // Host build disabled by soong/llvm.go unless FORCE_BUILD_LLVM_COMPONENTS
213    // environment variable is set
214}
215
216// LLVM shared library build
217
218llvm_arm_static_libraries = [
219    "libLLVMARMCodeGen",
220    "libLLVMARMAsmParser",
221    "libLLVMARMAsmPrinter",
222    "libLLVMARMInfo",
223    "libLLVMARMDesc",
224    "libLLVMARMDisassembler",
225]
226
227llvm_x86_static_libraries = [
228    "libLLVMX86CodeGen",
229    "libLLVMX86Info",
230    "libLLVMX86Desc",
231    "libLLVMX86AsmParser",
232    "libLLVMX86AsmPrinter",
233    "libLLVMX86Utils",
234    "libLLVMX86Disassembler",
235]
236
237llvm_mips_static_libraries = [
238    "libLLVMMipsCodeGen",
239    "libLLVMMipsInfo",
240    "libLLVMMipsDesc",
241    "libLLVMMipsAsmParser",
242    "libLLVMMipsAsmPrinter",
243    "libLLVMMipsDisassembler",
244]
245
246llvm_aarch64_static_libraries = [
247    "libLLVMAArch64CodeGen",
248    "libLLVMAArch64Info",
249    "libLLVMAArch64Desc",
250    "libLLVMAArch64AsmParser",
251    "libLLVMAArch64AsmPrinter",
252    "libLLVMAArch64Utils",
253    "libLLVMAArch64Disassembler",
254]
255
256cc_library {
257    host_supported: true,
258    name: "libLLVM_android",
259    vendor_available: true,
260    product_available: true,
261    defaults: [
262        "llvm-defaults",
263        "force_build_llvm_components",
264    ],
265
266    whole_static_libs: [
267        // pre static libraries
268        "libLLVMLinker",
269        "libLLVMipo",
270        "libLLVMDebugInfoDWARF",
271        "libLLVMDebugInfoPDB",
272        "libLLVMSymbolize",
273        "libLLVMIRReader",
274        "libLLVMBitWriter",
275        "libLLVMBitReader",
276
277        // post static libraries
278        "libLLVMLTO",
279        "libLLVMAsmPrinter",
280        "libLLVMSelectionDAG",
281        "libLLVMCodeGen",
282        "libLLVMDebugInfoCodeView",
283        "libLLVMObject",
284        "libLLVMScalarOpts",
285        "libLLVMInstCombine",
286        "libLLVMInstrumentation",
287        "libLLVMTransformObjCARC",
288        "libLLVMTransformUtils",
289        "libLLVMAnalysis",
290        "libLLVMTarget",
291        "libLLVMGlobalISel",
292        "libLLVMMCDisassembler",
293        "libLLVMMC",
294        "libLLVMMCParser",
295        "libLLVMCore",
296        "libLLVMAsmParser",
297        "libLLVMOption",
298        "libLLVMSupport",
299        "libLLVMVectorize",
300        "libLLVMProfileData",
301        "libLLVMProfileDataCoverage",
302        "libLLVMLibDriver",
303        "libLLVMExecutionEngine",
304        "libLLVMRuntimeDyld",
305        "libLLVMMCJIT",
306        "libLLVMOrcJIT",
307    ],
308
309    export_include_dirs: ["include"],
310
311    target: {
312        host: {
313            // Host build pulls in all ARM, Mips, X86 components.
314            whole_static_libs: llvm_arm_static_libraries +
315                llvm_aarch64_static_libraries +
316                llvm_mips_static_libraries +
317                llvm_x86_static_libraries,
318            export_include_dirs: ["host/include"],
319        },
320        windows: {
321            enabled: true,
322            host_ldlibs: [
323                "-limagehlp",
324                "-lpsapi",
325                "-lole32",
326                "-lversion",
327            ],
328        },
329        android: {
330            export_include_dirs: ["device/include"],
331        },
332        android_arm: {
333            whole_static_libs: llvm_arm_static_libraries +
334                llvm_aarch64_static_libraries,
335        },
336        android_x86: {
337            whole_static_libs: llvm_x86_static_libraries +
338                llvm_arm_static_libraries +
339                llvm_aarch64_static_libraries,
340        },
341        android_x86_64: {
342            whole_static_libs: llvm_x86_static_libraries +
343                llvm_arm_static_libraries +
344                llvm_aarch64_static_libraries,
345        },
346        android_arm64: {
347            whole_static_libs: llvm_aarch64_static_libraries +
348                llvm_arm_static_libraries,
349        },
350    },
351}
352
353subdirs = [
354    "soong",
355    "lib",
356    "tools/*",
357    "utils/*",
358]
359