blob: d2545a401d096dfc1a97710a27a29b2415fed1a2 [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-open",
Andreas Gampe322c0892018-09-18 13:50:29 -070032 "bugprone-lambda-function-name",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070033 "bugprone-unused-raii", // Protect scoped things like MutexLock.
Andreas Gampe322c0892018-09-18 13:50:29 -070034 "bugprone-virtual-near-miss",
Andreas Gampe8351aac2018-09-10 12:37:49 -070035 "modernize-use-bool-literals",
Chih-Hung Hsiehc5f41cd2022-01-12 21:14:17 -080036 "performance-implicit-conversion-in-loop",
37 "performance-unnecessary-copy-initialization",
38]
39
40art_clang_tidy_allowed = [
41 // Many files have these warnings. Move them to art_clang_tidy_errors
42 // when all files are free of these warnings.
43 "android-cloexec-dup",
44 "bugprone-argument-comment",
45 "bugprone-unused-return-value",
46 "misc-unused-using-decls",
Andreas Gampe322c0892018-09-18 13:50:29 -070047 "modernize-use-nullptr",
Andreas Gampec55bb392018-09-21 00:02:02 +000048 "modernize-use-using",
Andreas Gampe322c0892018-09-18 13:50:29 -070049 "performance-faster-string-find",
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070050 "performance-for-range-copy",
Andreas Gampe44b31742018-10-01 19:30:57 -070051 "performance-noexcept-move-constructor",
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070052 "performance-unnecessary-value-param",
Andreas Gampe896583e2018-06-15 13:31:58 -070053]
Andreas Gampe896583e2018-06-15 13:31:58 -070054
55art_clang_tidy_disabled = [
56 "-google-default-arguments",
57 // We have local stores that are only used for debug checks.
58 "-clang-analyzer-deadcode.DeadStores",
59 // We are OK with some static globals and that they can, in theory, throw.
60 "-cert-err58-cpp",
61 // We have lots of C-style variadic functions, and are OK with them. JNI ensures
62 // that working around this warning would be extra-painful.
63 "-cert-dcl50-cpp",
Andreas Gampe322c0892018-09-18 13:50:29 -070064 // "Modernization" we don't agree with.
65 "-modernize-use-auto",
66 "-modernize-return-braced-init-list",
67 "-modernize-use-default-member-init",
68 "-modernize-pass-by-value",
Andreas Gampe896583e2018-06-15 13:31:58 -070069]
70
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +010071soong_config_module_type_import {
72 from: "art/build/SoongConfig.bp",
73 module_types: [
74 "art_module_art_global_defaults",
75 "art_module_cc_defaults",
76 "art_module_java_defaults",
Martin Stjernholm41e56c22021-10-14 00:28:12 +010077 "art_module_genrule_defaults",
78 "art_module_prebuilt_defaults",
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +010079 ],
80}
81
82art_module_art_global_defaults {
Colin Cross1f7f3bd2016-07-27 10:12:38 -070083 // Additional flags are computed by art.go
84
85 name: "art_defaults",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +010086
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +010087 // Disable all ART Soong modules by default when ART prebuilts are in use.
88 // TODO(b/172480617): Clean up when sources are gone from the platform tree
89 // and we no longer need to support sources present when prebuilts are used.
90 enabled: false,
91 soong_config_variables: {
92 source_build: {
93 enabled: true,
94 },
95 },
96
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +010097 // This is the default visibility for the //art package, but we repeat it
98 // here so that it gets merged with other visibility rules in modules
99 // extending these defaults.
100 visibility: ["//art:__subpackages__"],
101
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700102 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700103 // Base set of cflags used by all things ART.
104 "-fno-rtti",
105 "-ggdb3",
106 "-Wall",
107 "-Werror",
108 "-Wextra",
109 "-Wstrict-aliasing",
110 "-fstrict-aliasing",
111 "-Wunreachable-code",
112 "-Wredundant-decls",
113 "-Wshadow",
114 "-Wunused",
115 "-fvisibility=protected",
116
117 // Warn about thread safety violations with clang.
118 "-Wthread-safety",
Colin Cross62f62f32019-11-05 15:55:45 -0800119 // TODO(b/144045034): turn on -Wthread-safety-negative
120 //"-Wthread-safety-negative",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700121
122 // Warn if switch fallthroughs aren't annotated.
123 "-Wimplicit-fallthrough",
124
125 // Enable float equality warnings.
126 "-Wfloat-equal",
127
128 // Enable warning of converting ints to void*.
129 "-Wint-to-void-pointer-cast",
130
131 // Enable warning of wrong unused annotations.
132 "-Wused-but-marked-unused",
133
134 // Enable warning for deprecated language features.
135 "-Wdeprecated",
136
137 // Enable warning for unreachable break & return.
138 "-Wunreachable-code-break",
139 "-Wunreachable-code-return",
140
David Srbecky56de89a2018-10-01 15:32:20 +0100141 // Disable warning for use of offsetof on non-standard layout type.
142 // We use it to implement OFFSETOF_MEMBER - see macros.h.
143 "-Wno-invalid-offsetof",
144
Yi Kong39402542019-03-24 02:47:16 -0700145 // Enable inconsistent-missing-override warning. This warning is disabled by default in
146 // Android.
147 "-Winconsistent-missing-override",
148
David Sehrae3bcac2017-02-03 15:19:00 -0800149 // Enable thread annotations for std::mutex, etc.
150 "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700151 ],
152
jaishankbf7ce252019-06-10 16:16:47 +0530153 arch: {
154 x86: {
155 avx2: {
156 cflags: [
157 "-mavx2",
158 "-mfma",
159 ],
160 },
161 },
162 x86_64: {
163 avx2: {
164 cflags: [
165 "-mavx2",
166 "-mfma",
167 ],
168 },
169 },
170 },
171
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700172 target: {
173 android: {
174 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700175 // To use oprofile_android --callgraph, uncomment this and recompile with
176 // mmma -j art
177 // "-fno-omit-frame-pointer",
178 // "-marm",
179 // "-mapcs",
180 ],
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700181 },
Dan Willemsen057f1e42017-10-03 14:11:48 -0700182 linux: {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700183 cflags: [
184 // Enable missing-noreturn only on non-Mac. As lots of things are not implemented for
185 // Apple, it's a pain.
186 "-Wmissing-noreturn",
187 ],
188 },
Andreas Gampea47a6e82019-07-24 09:46:16 -0700189 linux_bionic: {
Calin Juravle542e3932019-12-09 19:54:18 -0800190 strip: {
Calin Juravle3bdb9772019-12-10 11:31:53 -0800191 // Do not strip art libs when building for linux-bionic.
192 // Otherwise we can't get any symbols out of crashes.
Calin Juravle542e3932019-12-09 19:54:18 -0800193 none: true,
194 },
Andreas Gampea47a6e82019-07-24 09:46:16 -0700195 },
David Srbeckyd53f6062019-03-22 14:55:21 +0000196 darwin: {
197 enabled: false,
198 },
Martin Stjernholm1dc77ab2021-05-10 17:44:05 +0100199 windows: {
200 // When the module is enabled globally in the soong_config_variables
201 // stanza above, it may get enabled on windows too for some module
202 // types. Hence we need to disable it explicitly.
203 // TODO(b/172480617): Clean up with that.
204 enabled: false,
205 },
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700206 host: {
207 cflags: [
208 // Bug: 15446488. We don't omit the frame pointer to work around
209 // clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
210 "-fno-omit-frame-pointer",
Yi Kong57c6a722021-09-23 16:17:12 +0800211 ],
212 },
213 // The build assumes that all our x86/x86_64 hosts (such as buildbots and developer
214 // desktops) support at least sse4.2/popcount. This firstly implies that the ART
215 // runtime binary itself may exploit these features. Secondly, this implies that
216 // the ART runtime passes these feature flags to dex2oat and JIT by calling the
217 // method InstructionSetFeatures::FromCppDefines(). Since invoking dex2oat directly
218 // does not pick up these flags, cross-compiling from a x86/x86_64 host to a
219 // x86/x86_64 target should not be affected.
220 linux_x86: {
221 cflags: [
222 "-msse4.2",
223 "-mpopcnt",
224 ],
225 },
226 linux_x86_64: {
227 cflags: [
Aart Bikf6052572017-07-20 16:47:45 -0700228 "-msse4.2",
229 "-mpopcnt",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700230 ],
231 },
232 },
233
234 codegen: {
235 arm: {
236 cflags: ["-DART_ENABLE_CODEGEN_arm"],
237 },
238 arm64: {
239 cflags: ["-DART_ENABLE_CODEGEN_arm64"],
240 },
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700241 x86: {
242 cflags: ["-DART_ENABLE_CODEGEN_x86"],
243 },
244 x86_64: {
245 cflags: ["-DART_ENABLE_CODEGEN_x86_64"],
246 },
247 },
248
Chih-Hung Hsiehc5f41cd2022-01-12 21:14:17 -0800249 tidy_checks: art_clang_tidy_errors + art_clang_tidy_allowed + art_clang_tidy_disabled,
250
Nikita Ioffe08417352019-03-28 12:47:38 +0000251 tidy_checks_as_errors: art_clang_tidy_errors,
George Burgess IV7fb46652017-06-16 15:35:33 -0700252
253 tidy_flags: [
254 // The static analyzer treats DCHECK as always enabled; we sometimes get
255 // false positives when we use DCHECKs with code that relies on NDEBUG.
256 "-extra-arg=-UNDEBUG",
George Burgess IVdd8aa322017-06-21 16:34:35 -0700257 // clang-tidy complains about functions like:
258 // void foo() { CHECK(kIsFooEnabled); /* do foo... */ }
259 // not being marked noreturn if kIsFooEnabled is false.
260 "-extra-arg=-Wno-missing-noreturn",
Andreas Gampe020020f2018-07-10 12:34:23 -0700261 // Because tidy doesn't like our flow checks for compile-time configuration and thinks that
262 // the following code is dead (it is, but not for all configurations), disable unreachable
263 // code detection in Clang for tidy builds. It is still on for regular build steps, so we
264 // will still get the "real" errors.
265 "-extra-arg=-Wno-unreachable-code",
George Burgess IV7fb46652017-06-16 15:35:33 -0700266 ],
Nicolas Geoffrayec388c02021-03-03 22:09:06 +0000267
Martin Stjernholmf726d202021-10-28 03:52:25 +0100268 min_sdk_version: "31",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700269}
270
Collin Fijalkovich07ff2832020-08-25 10:43:12 -0700271// Used to generate binaries that can be backed by transparent hugepages.
272cc_defaults {
273 name: "art_hugepage_defaults",
274 arch: {
275 arm64: {
276 ldflags: ["-z max-page-size=0x200000"],
277 },
278 x86_64: {
279 ldflags: ["-z max-page-size=0x200000"],
280 },
281 },
282}
283
Colin Crossbe332ed2016-09-21 13:23:53 -0700284art_debug_defaults {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700285 name: "art_debug_defaults",
Martin Stjernholm9dca9192021-10-28 03:01:13 +0100286 defaults: ["art_defaults"],
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100287 visibility: ["//art:__subpackages__"],
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700288 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700289 "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
290 "-DVIXL_DEBUG",
291 "-UNDEBUG",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700292 ],
293 asflags: [
294 "-UNDEBUG",
295 ],
Colin Crossc5644062016-08-30 15:41:08 -0700296 target: {
297 // This has to be duplicated for android and host to make sure it
298 // comes after the -Wframe-larger-than warnings inserted by art.go
299 // target-specific properties
300 android: {
301 cflags: ["-Wno-frame-larger-than="],
302 },
303 host: {
304 cflags: ["-Wno-frame-larger-than="],
305 },
306 },
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700307}
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100308
309// A version of conscrypt only for enabling the "-hostdex" version to test ART on host.
310java_library {
Victor Changd20e51d2020-05-05 16:01:19 +0100311 // We need our own name to not clash with the conscrypt library.
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100312 name: "conscrypt-host",
313 installable: true,
314 hostdex: true,
Paul Duffinb283f372021-04-19 18:08:23 +0100315 static_libs: ["conscrypt-for-host"],
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100316
317 // Tests and build files rely on this file to be installed as "conscrypt-hostdex",
318 // therefore set a stem. Without it, the file would be installed as
319 // "conscrypt-host-hostdex".
320 stem: "conscrypt",
321 sdk_version: "core_platform",
322 target: {
323 hostdex: {
324 required: ["libjavacrypto"],
325 },
Yo Chiange492f7e2020-08-07 04:22:18 +0000326 darwin: {
327 // required module "libjavacrypto" is disabled on darwin
328 enabled: false,
329 },
Nicolas Geoffrayf6c37842020-03-31 14:00:47 +0100330 },
331}
Victor Changd20e51d2020-05-05 16:01:19 +0100332
333// A version of core-icu4j only for enabling the "-hostdex" version to test ART on host.
334java_library {
335 // We need our own name to not clash with the core-icu4j library.
336 name: "core-icu4j-host",
337 installable: true,
338 hostdex: true,
Paul Duffin79578112021-04-20 11:36:08 +0100339 static_libs: ["core-icu4j-for-host"],
Victor Changd20e51d2020-05-05 16:01:19 +0100340
341 // Tests and build files rely on this file to be installed as "core-icu4j-hostdex",
342 // therefore set a stem. Without it, the file would be installed as
343 // "core-icu4j-host-hostdex".
344 stem: "core-icu4j",
345 sdk_version: "core_platform",
346 target: {
347 hostdex: {
348 required: ["libicu_jni"],
349 },
350 },
351}
Martin Stjernholm41e56c22021-10-14 00:28:12 +0100352
353// Defaults for different module types to enable them only when building ART
354// from sources. TODO(b/172480617): Clean up when sources are gone from the
355// platform tree and we no longer need to support sources present when prebuilts
356// are used.
Chih-Hung Hsiehc5f41cd2022-01-12 21:14:17 -0800357
Martin Stjernholm41e56c22021-10-14 00:28:12 +0100358art_module_cc_defaults {
359 name: "art_module_source_build_defaults",
360 defaults_visibility: [
361 "//art:__subpackages__",
362 "//libcore:__subpackages__",
363 "//libnativehelper:__subpackages__",
364 ],
365 enabled: false,
366 soong_config_variables: {
367 source_build: {
368 enabled: true,
369 },
370 },
371 target: {
372 windows: {
373 // Windows is disabled by default, but if we set enabled:true
374 // globally above we need to disable it explicitly.
375 enabled: false,
376 },
377 },
378}
Chih-Hung Hsiehc5f41cd2022-01-12 21:14:17 -0800379
Martin Stjernholm41e56c22021-10-14 00:28:12 +0100380art_module_java_defaults {
381 name: "art_module_source_build_java_defaults",
382 defaults_visibility: [
383 "//art:__subpackages__",
384 "//libcore:__subpackages__",
385 "//libnativehelper:__subpackages__",
386 ],
387 enabled: false,
388 soong_config_variables: {
389 source_build: {
390 enabled: true,
391 },
392 },
393 target: {
394 windows: {
395 enabled: false,
396 },
397 },
398}
Chih-Hung Hsiehc5f41cd2022-01-12 21:14:17 -0800399
Martin Stjernholm41e56c22021-10-14 00:28:12 +0100400art_module_genrule_defaults {
401 name: "art_module_source_build_genrule_defaults",
402 defaults_visibility: [
403 "//art:__subpackages__",
404 "//libcore:__subpackages__",
405 "//libnativehelper:__subpackages__",
406 ],
407 enabled: false,
408 soong_config_variables: {
409 source_build: {
410 enabled: true,
411 },
412 },
413 target: {
414 windows: {
415 enabled: false,
416 },
417 },
418}
Chih-Hung Hsiehc5f41cd2022-01-12 21:14:17 -0800419
Martin Stjernholm41e56c22021-10-14 00:28:12 +0100420art_module_prebuilt_defaults {
421 name: "art_module_source_build_prebuilt_defaults",
422 defaults_visibility: [
423 "//art:__subpackages__",
424 "//libcore:__subpackages__",
425 "//libnativehelper:__subpackages__",
426 ],
427 enabled: false,
428 soong_config_variables: {
429 source_build: {
430 enabled: true,
431 },
432 },
433 target: {
434 windows: {
435 enabled: false,
436 },
437 },
438}