blob: 21858db13037225d477dba4e7fe33753ad63a36c [file] [log] [blame]
Bob Badour9150de62021-02-26 03:22:24 -08001package {
2 // See: http://go/android-license-faq
3 // A large-scale-change added 'default_applicable_licenses' to import
4 // all of the 'license_kinds' from "art_license"
5 // to get the below license kinds:
6 // SPDX-license-identifier-Apache-2.0
7 default_applicable_licenses: ["art_license"],
8}
9
Colin Cross1f7f3bd2016-07-27 10:12:38 -070010bootstrap_go_package {
11 name: "soong-art",
12 pkgPath: "android/soong/art",
13 deps: [
14 "blueprint",
15 "blueprint-pathtools",
Colin Cross84b69332017-11-01 14:23:17 -070016 "blueprint-proptools",
Colin Cross1f7f3bd2016-07-27 10:12:38 -070017 "soong",
18 "soong-android",
Alex Lightda948ce2018-12-06 17:05:41 +000019 "soong-apex",
Colin Cross1f7f3bd2016-07-27 10:12:38 -070020 "soong-cc",
21 ],
22 srcs: [
23 "art.go",
24 "codegen.go",
25 "makevars.go",
26 ],
27 pluginFor: ["soong_build"],
28}
29
Andreas Gampe896583e2018-06-15 13:31:58 -070030art_clang_tidy_errors = [
Andreas Gampedfcd82c2018-10-16 20:22:37 -070031 "android-cloexec-dup",
32 "android-cloexec-open",
Andreas Gampe6cd83902018-10-03 20:03:03 -070033 "bugprone-argument-comment",
Andreas Gampe322c0892018-09-18 13:50:29 -070034 "bugprone-lambda-function-name",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070035 "bugprone-unused-raii", // Protect scoped things like MutexLock.
Andreas Gampeafaf7f82018-10-16 11:32:38 -070036 "bugprone-unused-return-value",
Andreas Gampe322c0892018-09-18 13:50:29 -070037 "bugprone-virtual-near-miss",
Andreas Gampe8351aac2018-09-10 12:37:49 -070038 "modernize-use-bool-literals",
Andreas Gampe322c0892018-09-18 13:50:29 -070039 "modernize-use-nullptr",
Andreas Gampec55bb392018-09-21 00:02:02 +000040 "modernize-use-using",
Andreas Gampe322c0892018-09-18 13:50:29 -070041 "performance-faster-string-find",
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070042 "performance-for-range-copy",
Andreas Gampe322c0892018-09-18 13:50:29 -070043 "performance-implicit-conversion-in-loop",
Andreas Gampe44b31742018-10-01 19:30:57 -070044 "performance-noexcept-move-constructor",
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070045 "performance-unnecessary-copy-initialization",
46 "performance-unnecessary-value-param",
Andreas Gampebd39d142018-07-19 11:14:42 -070047 "misc-unused-using-decls",
Andreas Gampe896583e2018-06-15 13:31:58 -070048]
Andreas Gampe896583e2018-06-15 13:31:58 -070049
50art_clang_tidy_disabled = [
51 "-google-default-arguments",
52 // We have local stores that are only used for debug checks.
53 "-clang-analyzer-deadcode.DeadStores",
54 // We are OK with some static globals and that they can, in theory, throw.
55 "-cert-err58-cpp",
56 // We have lots of C-style variadic functions, and are OK with them. JNI ensures
57 // that working around this warning would be extra-painful.
58 "-cert-dcl50-cpp",
Andreas Gampe322c0892018-09-18 13:50:29 -070059 // "Modernization" we don't agree with.
60 "-modernize-use-auto",
61 "-modernize-return-braced-init-list",
62 "-modernize-use-default-member-init",
63 "-modernize-pass-by-value",
Andreas Gampe896583e2018-06-15 13:31:58 -070064]
65
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +010066soong_config_module_type_import {
67 from: "art/build/SoongConfig.bp",
68 module_types: [
69 "art_module_art_global_defaults",
70 "art_module_cc_defaults",
71 "art_module_java_defaults",
72 ],
73}
74
75art_module_art_global_defaults {
Colin Cross1f7f3bd2016-07-27 10:12:38 -070076 // Additional flags are computed by art.go
77
78 name: "art_defaults",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +010079
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +010080 // Disable all ART Soong modules by default when ART prebuilts are in use.
81 // TODO(b/172480617): Clean up when sources are gone from the platform tree
82 // and we no longer need to support sources present when prebuilts are used.
83 enabled: false,
84 soong_config_variables: {
85 source_build: {
86 enabled: true,
87 },
88 },
89
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +010090 // This is the default visibility for the //art package, but we repeat it
91 // here so that it gets merged with other visibility rules in modules
92 // extending these defaults.
93 visibility: ["//art:__subpackages__"],
94
Colin Cross1f7f3bd2016-07-27 10:12:38 -070095 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -070096 // Base set of cflags used by all things ART.
97 "-fno-rtti",
98 "-ggdb3",
99 "-Wall",
100 "-Werror",
101 "-Wextra",
102 "-Wstrict-aliasing",
103 "-fstrict-aliasing",
104 "-Wunreachable-code",
105 "-Wredundant-decls",
106 "-Wshadow",
107 "-Wunused",
108 "-fvisibility=protected",
109
110 // Warn about thread safety violations with clang.
111 "-Wthread-safety",
Colin Cross62f62f32019-11-05 15:55:45 -0800112 // TODO(b/144045034): turn on -Wthread-safety-negative
113 //"-Wthread-safety-negative",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700114
115 // Warn if switch fallthroughs aren't annotated.
116 "-Wimplicit-fallthrough",
117
118 // Enable float equality warnings.
119 "-Wfloat-equal",
120
121 // Enable warning of converting ints to void*.
122 "-Wint-to-void-pointer-cast",
123
124 // Enable warning of wrong unused annotations.
125 "-Wused-but-marked-unused",
126
127 // Enable warning for deprecated language features.
128 "-Wdeprecated",
129
130 // Enable warning for unreachable break & return.
131 "-Wunreachable-code-break",
132 "-Wunreachable-code-return",
133
David Srbecky56de89a2018-10-01 15:32:20 +0100134 // Disable warning for use of offsetof on non-standard layout type.
135 // We use it to implement OFFSETOF_MEMBER - see macros.h.
136 "-Wno-invalid-offsetof",
137
Yi Kong39402542019-03-24 02:47:16 -0700138 // Enable inconsistent-missing-override warning. This warning is disabled by default in
139 // Android.
140 "-Winconsistent-missing-override",
141
David Sehrae3bcac2017-02-03 15:19:00 -0800142 // Enable thread annotations for std::mutex, etc.
143 "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700144 ],
145
jaishankbf7ce252019-06-10 16:16:47 +0530146 arch: {
147 x86: {
148 avx2: {
149 cflags: [
150 "-mavx2",
151 "-mfma",
152 ],
153 },
154 },
155 x86_64: {
156 avx2: {
157 cflags: [
158 "-mavx2",
159 "-mfma",
160 ],
161 },
162 },
163 },
164
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700165 target: {
166 android: {
167 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700168 // To use oprofile_android --callgraph, uncomment this and recompile with
169 // mmma -j art
170 // "-fno-omit-frame-pointer",
171 // "-marm",
172 // "-mapcs",
173 ],
Paul Duffin34ac9f72019-07-18 13:03:24 +0100174 header_libs: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700175 // We optimize Thread::Current() with a direct TLS access. This requires access to a
Christopher Ferrisfd64e562019-09-25 17:58:26 -0700176 // platform specific Bionic header.
177 "bionic_libc_platform_headers",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700178 ],
179 },
Dan Willemsen057f1e42017-10-03 14:11:48 -0700180 linux: {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700181 cflags: [
182 // Enable missing-noreturn only on non-Mac. As lots of things are not implemented for
183 // Apple, it's a pain.
184 "-Wmissing-noreturn",
185 ],
186 },
Andreas Gampea47a6e82019-07-24 09:46:16 -0700187 linux_bionic: {
188 header_libs: [
189 // We optimize Thread::Current() with a direct TLS access. This requires access to a
Christopher Ferrisfd64e562019-09-25 17:58:26 -0700190 // platform specific Bionic header.
191 "bionic_libc_platform_headers",
Andreas Gampea47a6e82019-07-24 09:46:16 -0700192 ],
Calin Juravle542e3932019-12-09 19:54:18 -0800193 strip: {
Calin Juravle3bdb9772019-12-10 11:31:53 -0800194 // Do not strip art libs when building for linux-bionic.
195 // Otherwise we can't get any symbols out of crashes.
Calin Juravle542e3932019-12-09 19:54:18 -0800196 none: true,
197 },
Andreas Gampea47a6e82019-07-24 09:46:16 -0700198 },
David Srbeckyd53f6062019-03-22 14:55:21 +0000199 darwin: {
200 enabled: false,
201 },
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100202 windows: {
203 // When the module is enabled globally in the soong_config_variables
204 // stanza above, it may get enabled on windows too for some module
205 // types. Hence we need to disable it explicitly.
206 // TODO(b/172480617): Clean up with that.
207 enabled: false,
208 },
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700209 host: {
210 cflags: [
211 // Bug: 15446488. We don't omit the frame pointer to work around
212 // clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
213 "-fno-omit-frame-pointer",
Aart Bikf6052572017-07-20 16:47:45 -0700214 // The build assumes that all our x86/x86_64 hosts (such as buildbots and developer
215 // desktops) support at least sse4.2/popcount. This firstly implies that the ART
216 // runtime binary itself may exploit these features. Secondly, this implies that
217 // the ART runtime passes these feature flags to dex2oat and JIT by calling the
218 // method InstructionSetFeatures::FromCppDefines(). Since invoking dex2oat directly
219 // does not pick up these flags, cross-compiling from a x86/x86_64 host to a
220 // x86/x86_64 target should not be affected.
221 "-msse4.2",
222 "-mpopcnt",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700223 ],
224 },
225 },
226
227 codegen: {
228 arm: {
229 cflags: ["-DART_ENABLE_CODEGEN_arm"],
230 },
231 arm64: {
232 cflags: ["-DART_ENABLE_CODEGEN_arm64"],
233 },
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700234 x86: {
235 cflags: ["-DART_ENABLE_CODEGEN_x86"],
236 },
237 x86_64: {
238 cflags: ["-DART_ENABLE_CODEGEN_x86_64"],
239 },
240 },
241
Andreas Gampe896583e2018-06-15 13:31:58 -0700242 tidy_checks: art_clang_tidy_errors + art_clang_tidy_disabled,
Nikita Ioffe08417352019-03-28 12:47:38 +0000243 tidy_checks_as_errors: art_clang_tidy_errors,
George Burgess IV7fb46652017-06-16 15:35:33 -0700244
245 tidy_flags: [
246 // The static analyzer treats DCHECK as always enabled; we sometimes get
247 // false positives when we use DCHECKs with code that relies on NDEBUG.
248 "-extra-arg=-UNDEBUG",
George Burgess IVdd8aa322017-06-21 16:34:35 -0700249 // clang-tidy complains about functions like:
250 // void foo() { CHECK(kIsFooEnabled); /* do foo... */ }
251 // not being marked noreturn if kIsFooEnabled is false.
252 "-extra-arg=-Wno-missing-noreturn",
Andreas Gampe020020f2018-07-10 12:34:23 -0700253 // Because tidy doesn't like our flow checks for compile-time configuration and thinks that
254 // the following code is dead (it is, but not for all configurations), disable unreachable
255 // code detection in Clang for tidy builds. It is still on for regular build steps, so we
256 // will still get the "real" errors.
257 "-extra-arg=-Wno-unreachable-code",
George Burgess IV7fb46652017-06-16 15:35:33 -0700258 ],
Nicolas Geoffrayec388c02021-03-03 22:09:06 +0000259
260 min_sdk_version: "S",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700261}
262
Collin Fijalkovich07ff2832020-08-25 10:43:12 -0700263// Used to generate binaries that can be backed by transparent hugepages.
264cc_defaults {
265 name: "art_hugepage_defaults",
266 arch: {
267 arm64: {
268 ldflags: ["-z max-page-size=0x200000"],
269 },
270 x86_64: {
271 ldflags: ["-z max-page-size=0x200000"],
272 },
273 },
274}
275
Yi Kongf579b062020-10-24 22:54:39 +0800276cc_defaults {
277 name: "art_pgo_defaults",
278 visibility: ["//art:__subpackages__"],
279 pgo: {
280 sampling: true,
281 },
282 target: {
283 android_arm64: {
284 pgo: {
285 profile_file: "art/art_arm_arm64.profdata",
286 },
287 },
288 android_arm: {
289 pgo: {
290 profile_file: "art/art_arm_arm64.profdata",
291 },
292 },
293 android_x86_64: {
294 pgo: {
295 profile_file: "art/art_x86_x86_64.profdata",
296 },
297 },
298 android_x86: {
299 pgo: {
300 profile_file: "art/art_x86_x86_64.profdata",
301 },
302 },
303 },
304}
305
Colin Crossbe332ed2016-09-21 13:23:53 -0700306art_debug_defaults {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700307 name: "art_debug_defaults",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100308 visibility: ["//art:__subpackages__"],
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700309 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700310 "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
311 "-DVIXL_DEBUG",
312 "-UNDEBUG",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700313 ],
314 asflags: [
315 "-UNDEBUG",
316 ],
Colin Crossc5644062016-08-30 15:41:08 -0700317 target: {
318 // This has to be duplicated for android and host to make sure it
319 // comes after the -Wframe-larger-than warnings inserted by art.go
320 // target-specific properties
321 android: {
322 cflags: ["-Wno-frame-larger-than="],
323 },
324 host: {
325 cflags: ["-Wno-frame-larger-than="],
326 },
327 },
Nicolas Geoffrayec388c02021-03-03 22:09:06 +0000328
329 min_sdk_version: "S",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700330}
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100331
Martin Stjernholm90b26612021-03-03 09:49:27 +0000332// Use this to enable a cc_* module only when building ART from sources.
333// TODO(b/172480617): Clean up when sources are gone from the platform tree and
334// we no longer need to support sources present when prebuilts are used.
335art_module_cc_defaults {
336 name: "art_module_source_build_defaults",
337 defaults_visibility: [
338 "//art:__subpackages__",
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100339 "//libcore:__subpackages__",
Martin Stjernholm90b26612021-03-03 09:49:27 +0000340 "//libnativehelper:__subpackages__",
341 ],
342
343 enabled: false,
344 soong_config_variables: {
345 source_build: {
346 enabled: true,
347 },
348 },
349 target: {
350 windows: {
351 // Windows is disabled by default, but if we set enabled:true
352 // globally above we need to disable it explicitly.
353 enabled: false,
354 },
355 },
356}
357
Martin Stjernholm8e0f6aa2021-03-30 21:22:18 +0100358// Use this to enable a java_* module only when building ART from sources.
359// TODO(b/172480617): Clean up when sources are gone from the platform tree and
360// we no longer need to support sources present when prebuilts are used.
361art_module_java_defaults {
362 name: "art_module_source_build_java_defaults",
363 defaults_visibility: [
364 "//art:__subpackages__",
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100365 "//libcore:__subpackages__",
Martin Stjernholm8e0f6aa2021-03-30 21:22:18 +0100366 "//libnativehelper:__subpackages__",
367 ],
368
369 enabled: false,
370 soong_config_variables: {
371 source_build: {
372 enabled: true,
373 },
374 },
375 target: {
376 windows: {
377 // Windows is disabled by default, but if we set enabled:true
378 // globally above we need to disable it explicitly.
379 enabled: false,
380 },
381 },
382}
383
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100384// A version of conscrypt only for enabling the "-hostdex" version to test ART on host.
385java_library {
Victor Changd20e51d2020-05-05 16:01:19 +0100386 // We need our own name to not clash with the conscrypt library.
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100387 name: "conscrypt-host",
388 installable: true,
389 hostdex: true,
Paul Duffinb283f372021-04-19 18:08:23 +0100390 static_libs: ["conscrypt-for-host"],
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100391
392 // Tests and build files rely on this file to be installed as "conscrypt-hostdex",
393 // therefore set a stem. Without it, the file would be installed as
394 // "conscrypt-host-hostdex".
395 stem: "conscrypt",
396 sdk_version: "core_platform",
397 target: {
398 hostdex: {
399 required: ["libjavacrypto"],
400 },
Yo Chiange492f7e2020-08-07 04:22:18 +0000401 darwin: {
402 // required module "libjavacrypto" is disabled on darwin
403 enabled: false,
404 },
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100405 },
406}
Victor Changd20e51d2020-05-05 16:01:19 +0100407
408// A version of core-icu4j only for enabling the "-hostdex" version to test ART on host.
409java_library {
410 // We need our own name to not clash with the core-icu4j library.
411 name: "core-icu4j-host",
412 installable: true,
413 hostdex: true,
Paul Duffin79578112021-04-20 11:36:08 +0100414 static_libs: ["core-icu4j-for-host"],
Victor Changd20e51d2020-05-05 16:01:19 +0100415
416 // Tests and build files rely on this file to be installed as "core-icu4j-hostdex",
417 // therefore set a stem. Without it, the file would be installed as
418 // "core-icu4j-host-hostdex".
419 stem: "core-icu4j",
420 sdk_version: "core_platform",
421 target: {
422 hostdex: {
423 required: ["libicu_jni"],
424 },
425 },
426}