aboutsummaryrefslogtreecommitdiff
path: root/Android.bp
blob: cbc59cb04a2dfdfae822ba346b1281e7d768269c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
package {
    default_applicable_licenses: ["external_llvm_license"],
}

// Added automatically by a large-scale-change that took the approach of
// 'apply every license found to every target'. While this makes sure we respect
// every license restriction, it may not be entirely correct.
//
// e.g. GPL in an MIT project might only apply to the contrib/ directory.
//
// Please consider splitting the single license below into multiple licenses,
// taking care not to lose any license_kind information, and overriding the
// default license using the 'licenses: [...]' property on targets as needed.
//
// For unused files, consider creating a 'fileGroup' with "//visibility:private"
// to attach the license to, and including a comment whether the files may be
// used in the current project.
//
// large-scale-change included anything that looked like it might be a license
// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
//
// Please consider removing redundant or irrelevant files from 'license_text:'.
//
// large-scale-change filtered out the below license kinds as false-positives:
//   SPDX-license-identifier-GPL
//   SPDX-license-identifier-GPL-3.0
// See: http://go/android-license-faq
license {
    name: "external_llvm_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "SPDX-license-identifier-Apache-2.0",
        "SPDX-license-identifier-BSD",
        "SPDX-license-identifier-MIT",
        "SPDX-license-identifier-NCSA",
        "legacy_permissive",
        "legacy_unencumbered",
    ],
    license_text: [
        "LICENSE.TXT",
        "NOTICE",
    ],
}

cc_defaults {
    name: "llvm-defaults",
    defaults: ["llvm-defaults-no-generated-headers"],
    header_libs: ["llvm-headers"],
    tidy_checks: [
        "-google-build-*",
        "-google-global-*",
    ],
    sanitize: {
        hwaddress: false, // code size b/112437884
    },
}

// This module defines all of the defaults used to compiled llvm, except for
// the generated headers.  It is necessary to avoid a circular dependency
// from the tblgen tool used to generate the headers to the generated headers.
llvm_defaults {
    name: "llvm-defaults-no-generated-headers",

    host_supported: true,
    // TODO(b/153609531): remove when no longer needed.
    native_bridge_supported: true,

    cflags: [
        "-D_GNU_SOURCE",
        "-D__STDC_LIMIT_MACROS",
        "-D__STDC_CONSTANT_MACROS",
        "-D__STDC_FORMAT_MACROS",
        "-fomit-frame-pointer",
        "-Wall",
        "-W",
        "-Wno-cast-qual",
        "-Wno-sign-compare",
        "-Wno-unused-parameter",
        "-Wno-maybe-uninitialized",
        "-Wno-missing-field-initializers",
        "-Wno-implicit-fallthrough",
        "-Wwrite-strings",
        "-Werror",
        "-Dsprintf=sprintf",
    ],

    cppflags: [
        "-Wno-sign-promo",
        "-std=c++11",
    ],

    tidy_checks: [
        "-google-build-*",
        "-google-global-*",
    ],

    header_libs: ["llvm-headers-no-generated-headers"],

    target: {
        android: {
            cflags: [
                "-finline-functions",
            ],
        },
        linux: {
            cppflags: [
                "-Woverloaded-virtual",
            ],
        },
        host: {
            cppflags: [
                "-fno-rtti",
                "-fno-exceptions",
            ],
        },
        windows: {
            // Disable certain warnings for use with mingw.
            // We also must undefine WIN32_LEAN_AND_MEAN, since it is being passed globally
            // on the command line, and LLVM defines this internally itself.
            cflags: [
                "-Wno-array-bounds",
                "-Wno-comment",
                "-UWIN32_LEAN_AND_MEAN",
            ],

            host_ldlibs: ["-luuid"],
        },
        linux_glibc: {
            host_ldlibs: [
                "-lgcc_s",
            ],
        },
        darwin: {
            cppflags: [
                "-Wno-deprecated-declarations",
                "-Woverloaded-virtual",
            ],
        },
    },
}

cc_library_headers {
    name: "llvm-headers-no-generated-headers",
    vendor_available: true,
    product_available: true,
    host_supported: true,
    // TODO(b/153609531): remove when no longer needed.
    native_bridge_supported: true,
    export_include_dirs: ["include"],
    target: {
        android: {
            export_include_dirs: ["device/include"],
        },
        host: {
            export_include_dirs: ["host/include"],
        },
        linux_bionic: {
            enabled: true,
        },
        windows: {
            enabled: true,
        },
    },
}

cc_library_headers {
    name: "llvm-headers",
    vendor_available: true,
    product_available: true,
    host_supported: true,
    // TODO(b/153609531): remove when no longer needed.
    native_bridge_supported: true,
    header_libs: ["llvm-headers-no-generated-headers"],
    export_header_lib_headers: ["llvm-headers-no-generated-headers"],
    generated_headers: [
        "llvm-gen-attributes",
        "llvm-gen-intrinsics",
    ],
    export_generated_headers: [
        "llvm-gen-attributes",
        "llvm-gen-intrinsics",
    ],
    target: {
        windows: {
            enabled: true,
        },
    },
}

llvm_tblgen {
    name: "llvm-gen-attributes",
    in: "include/llvm/IR/Attributes.td",
    outs: ["llvm/IR/Attributes.inc"],
}

llvm_tblgen {
    name: "llvm-gen-intrinsics",
    in: "include/llvm/IR/Intrinsics.td",
    outs: ["llvm/IR/Intrinsics.gen"],
}

force_build_llvm_components_defaults {
    name: "force_build_llvm_components",
    // Host build disabled by soong/llvm.go unless FORCE_BUILD_LLVM_COMPONENTS
    // environment variable is set
}

// LLVM shared library build

llvm_arm_static_libraries = [
    "libLLVMARMCodeGen",
    "libLLVMARMAsmParser",
    "libLLVMARMAsmPrinter",
    "libLLVMARMInfo",
    "libLLVMARMDesc",
    "libLLVMARMDisassembler",
]

llvm_x86_static_libraries = [
    "libLLVMX86CodeGen",
    "libLLVMX86Info",
    "libLLVMX86Desc",
    "libLLVMX86AsmParser",
    "libLLVMX86AsmPrinter",
    "libLLVMX86Utils",
    "libLLVMX86Disassembler",
]

llvm_mips_static_libraries = [
    "libLLVMMipsCodeGen",
    "libLLVMMipsInfo",
    "libLLVMMipsDesc",
    "libLLVMMipsAsmParser",
    "libLLVMMipsAsmPrinter",
    "libLLVMMipsDisassembler",
]

llvm_aarch64_static_libraries = [
    "libLLVMAArch64CodeGen",
    "libLLVMAArch64Info",
    "libLLVMAArch64Desc",
    "libLLVMAArch64AsmParser",
    "libLLVMAArch64AsmPrinter",
    "libLLVMAArch64Utils",
    "libLLVMAArch64Disassembler",
]

cc_library {
    host_supported: true,
    name: "libLLVM_android",
    vendor_available: true,
    product_available: true,
    defaults: [
        "llvm-defaults",
        "force_build_llvm_components",
    ],

    whole_static_libs: [
        // pre static libraries
        "libLLVMLinker",
        "libLLVMipo",
        "libLLVMDebugInfoDWARF",
        "libLLVMDebugInfoPDB",
        "libLLVMSymbolize",
        "libLLVMIRReader",
        "libLLVMBitWriter",
        "libLLVMBitReader",

        // post static libraries
        "libLLVMLTO",
        "libLLVMAsmPrinter",
        "libLLVMSelectionDAG",
        "libLLVMCodeGen",
        "libLLVMDebugInfoCodeView",
        "libLLVMObject",
        "libLLVMScalarOpts",
        "libLLVMInstCombine",
        "libLLVMInstrumentation",
        "libLLVMTransformObjCARC",
        "libLLVMTransformUtils",
        "libLLVMAnalysis",
        "libLLVMTarget",
        "libLLVMGlobalISel",
        "libLLVMMCDisassembler",
        "libLLVMMC",
        "libLLVMMCParser",
        "libLLVMCore",
        "libLLVMAsmParser",
        "libLLVMOption",
        "libLLVMSupport",
        "libLLVMVectorize",
        "libLLVMProfileData",
        "libLLVMProfileDataCoverage",
        "libLLVMLibDriver",
        "libLLVMExecutionEngine",
        "libLLVMRuntimeDyld",
        "libLLVMMCJIT",
        "libLLVMOrcJIT",
    ],

    export_include_dirs: ["include"],

    target: {
        host: {
            // Host build pulls in all ARM, Mips, X86 components.
           whole_static_libs: llvm_arm_static_libraries +
                llvm_aarch64_static_libraries +
                llvm_mips_static_libraries +
                llvm_x86_static_libraries,
            export_include_dirs: ["host/include"],
        },
        windows: {
            enabled: true,
            host_ldlibs: [
                "-limagehlp",
                "-lpsapi",
                "-lole32",
                "-lversion",
            ],
        },
        android: {
            export_include_dirs: ["device/include"],
        },
        android_arm: {
            whole_static_libs: llvm_arm_static_libraries +
                llvm_aarch64_static_libraries,
        },
        android_x86: {
            whole_static_libs: llvm_x86_static_libraries +
                llvm_arm_static_libraries +
                llvm_aarch64_static_libraries,
        },
        android_x86_64: {
            whole_static_libs: llvm_x86_static_libraries +
                llvm_arm_static_libraries +
                llvm_aarch64_static_libraries,
        },
        android_arm64: {
            whole_static_libs: llvm_aarch64_static_libraries +
                llvm_arm_static_libraries,
        },
    },
}

subdirs = [
    "soong",
    "lib",
    "tools/*",
    "utils/*",
]