blob: 46fb0c5b97566ddfcecf84aa261401d5f3efd12e [file] [log] [blame]
Colin Cross1f7f3bd2016-07-27 10:12:38 -07001bootstrap_go_package {
2 name: "soong-art",
3 pkgPath: "android/soong/art",
4 deps: [
5 "blueprint",
6 "blueprint-pathtools",
Colin Cross84b69332017-11-01 14:23:17 -07007 "blueprint-proptools",
Colin Cross1f7f3bd2016-07-27 10:12:38 -07008 "soong",
9 "soong-android",
Alex Lightda948ce2018-12-06 17:05:41 +000010 "soong-apex",
Colin Cross1f7f3bd2016-07-27 10:12:38 -070011 "soong-cc",
12 ],
13 srcs: [
14 "art.go",
15 "codegen.go",
16 "makevars.go",
17 ],
18 pluginFor: ["soong_build"],
19}
20
Andreas Gampe896583e2018-06-15 13:31:58 -070021art_clang_tidy_errors = [
Andreas Gampedfcd82c2018-10-16 20:22:37 -070022 "android-cloexec-dup",
23 "android-cloexec-open",
Andreas Gampe6cd83902018-10-03 20:03:03 -070024 "bugprone-argument-comment",
Andreas Gampe322c0892018-09-18 13:50:29 -070025 "bugprone-lambda-function-name",
26 "bugprone-unused-raii", // Protect scoped things like MutexLock.
Andreas Gampeafaf7f82018-10-16 11:32:38 -070027 "bugprone-unused-return-value",
Andreas Gampe322c0892018-09-18 13:50:29 -070028 "bugprone-virtual-near-miss",
Andreas Gampe8351aac2018-09-10 12:37:49 -070029 "modernize-use-bool-literals",
Andreas Gampe322c0892018-09-18 13:50:29 -070030 "modernize-use-nullptr",
Andreas Gampec55bb392018-09-21 00:02:02 +000031 "modernize-use-using",
Andreas Gampe322c0892018-09-18 13:50:29 -070032 "performance-faster-string-find",
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070033 "performance-for-range-copy",
Andreas Gampe322c0892018-09-18 13:50:29 -070034 "performance-implicit-conversion-in-loop",
Andreas Gampe44b31742018-10-01 19:30:57 -070035 "performance-noexcept-move-constructor",
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070036 "performance-unnecessary-copy-initialization",
37 "performance-unnecessary-value-param",
Andreas Gampebd39d142018-07-19 11:14:42 -070038 "misc-unused-using-decls",
Andreas Gampe896583e2018-06-15 13:31:58 -070039]
40// Should be: strings.Join(art_clang_tidy_errors, ",").
Andreas Gampedfcd82c2018-10-16 20:22:37 -070041art_clang_tidy_errors_str = "android-cloexec-dup"
42 + ",android-cloexec-open"
43 + ",bugprone-argument-comment"
Andreas Gampe6cd83902018-10-03 20:03:03 -070044 + ",bugprone-lambda-function-name"
Andreas Gampe322c0892018-09-18 13:50:29 -070045 + ",bugprone-unused-raii"
Andreas Gampeafaf7f82018-10-16 11:32:38 -070046 + ",bugprone-unused-return-value"
Andreas Gampe322c0892018-09-18 13:50:29 -070047 + ",bugprone-virtual-near-miss"
Andreas Gampe6142e582018-09-18 16:49:15 -070048 + ",modernize-redundant-void-arg"
Andreas Gampe8351aac2018-09-10 12:37:49 -070049 + ",modernize-use-bool-literals"
Andreas Gampe322c0892018-09-18 13:50:29 -070050 + ",modernize-use-nullptr"
Andreas Gampec55bb392018-09-21 00:02:02 +000051 + ",modernize-use-using"
Andreas Gampe322c0892018-09-18 13:50:29 -070052 + ",performance-faster-string-find"
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070053 + ",performance-for-range-copy"
Andreas Gampe322c0892018-09-18 13:50:29 -070054 + ",performance-implicit-conversion-in-loop"
Andreas Gampe44b31742018-10-01 19:30:57 -070055 + ",performance-noexcept-move-constructor"
Andreas Gampe6f4cf6e2018-06-19 17:10:48 -070056 + ",performance-unnecessary-copy-initialization"
57 + ",performance-unnecessary-value-param"
Andreas Gampebd39d142018-07-19 11:14:42 -070058 + ",misc-unused-using-decls"
Andreas Gampe896583e2018-06-15 13:31:58 -070059
60art_clang_tidy_disabled = [
61 "-google-default-arguments",
62 // We have local stores that are only used for debug checks.
63 "-clang-analyzer-deadcode.DeadStores",
64 // We are OK with some static globals and that they can, in theory, throw.
65 "-cert-err58-cpp",
66 // We have lots of C-style variadic functions, and are OK with them. JNI ensures
67 // that working around this warning would be extra-painful.
68 "-cert-dcl50-cpp",
Andreas Gampe322c0892018-09-18 13:50:29 -070069 // "Modernization" we don't agree with.
70 "-modernize-use-auto",
71 "-modernize-return-braced-init-list",
72 "-modernize-use-default-member-init",
73 "-modernize-pass-by-value",
Andreas Gampe896583e2018-06-15 13:31:58 -070074]
75
Colin Cross1f7f3bd2016-07-27 10:12:38 -070076art_global_defaults {
77 // Additional flags are computed by art.go
78
79 name: "art_defaults",
Colin Cross1f7f3bd2016-07-27 10:12:38 -070080 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -070081 // Base set of cflags used by all things ART.
82 "-fno-rtti",
83 "-ggdb3",
84 "-Wall",
85 "-Werror",
86 "-Wextra",
87 "-Wstrict-aliasing",
88 "-fstrict-aliasing",
89 "-Wunreachable-code",
90 "-Wredundant-decls",
91 "-Wshadow",
92 "-Wunused",
93 "-fvisibility=protected",
94
95 // Warn about thread safety violations with clang.
96 "-Wthread-safety",
97 "-Wthread-safety-negative",
98
99 // Warn if switch fallthroughs aren't annotated.
100 "-Wimplicit-fallthrough",
101
102 // Enable float equality warnings.
103 "-Wfloat-equal",
104
105 // Enable warning of converting ints to void*.
106 "-Wint-to-void-pointer-cast",
107
108 // Enable warning of wrong unused annotations.
109 "-Wused-but-marked-unused",
110
111 // Enable warning for deprecated language features.
112 "-Wdeprecated",
113
114 // Enable warning for unreachable break & return.
115 "-Wunreachable-code-break",
116 "-Wunreachable-code-return",
117
David Srbecky56de89a2018-10-01 15:32:20 +0100118 // Disable warning for use of offsetof on non-standard layout type.
119 // We use it to implement OFFSETOF_MEMBER - see macros.h.
120 "-Wno-invalid-offsetof",
121
David Sehrae3bcac2017-02-03 15:19:00 -0800122 // Enable thread annotations for std::mutex, etc.
123 "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700124 ],
125
126 target: {
127 android: {
128 cflags: [
129 "-DART_TARGET",
130
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700131 // To use oprofile_android --callgraph, uncomment this and recompile with
132 // mmma -j art
133 // "-fno-omit-frame-pointer",
134 // "-marm",
135 // "-mapcs",
136 ],
137 include_dirs: [
138 // We optimize Thread::Current() with a direct TLS access. This requires access to a
139 // private Bionic header.
140 "bionic/libc/private",
141 ],
142 },
Dan Willemsen057f1e42017-10-03 14:11:48 -0700143 linux: {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700144 cflags: [
145 // Enable missing-noreturn only on non-Mac. As lots of things are not implemented for
146 // Apple, it's a pain.
147 "-Wmissing-noreturn",
148 ],
149 },
150 host: {
151 cflags: [
152 // Bug: 15446488. We don't omit the frame pointer to work around
153 // clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
154 "-fno-omit-frame-pointer",
Aart Bikf6052572017-07-20 16:47:45 -0700155 // The build assumes that all our x86/x86_64 hosts (such as buildbots and developer
156 // desktops) support at least sse4.2/popcount. This firstly implies that the ART
157 // runtime binary itself may exploit these features. Secondly, this implies that
158 // the ART runtime passes these feature flags to dex2oat and JIT by calling the
159 // method InstructionSetFeatures::FromCppDefines(). Since invoking dex2oat directly
160 // does not pick up these flags, cross-compiling from a x86/x86_64 host to a
161 // x86/x86_64 target should not be affected.
162 "-msse4.2",
163 "-mpopcnt",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700164 ],
165 },
166 },
167
168 codegen: {
169 arm: {
170 cflags: ["-DART_ENABLE_CODEGEN_arm"],
171 },
172 arm64: {
173 cflags: ["-DART_ENABLE_CODEGEN_arm64"],
174 },
175 mips: {
176 cflags: ["-DART_ENABLE_CODEGEN_mips"],
177 },
178 mips64: {
179 cflags: ["-DART_ENABLE_CODEGEN_mips64"],
180 },
181 x86: {
182 cflags: ["-DART_ENABLE_CODEGEN_x86"],
183 },
184 x86_64: {
185 cflags: ["-DART_ENABLE_CODEGEN_x86_64"],
186 },
187 },
188
189 include_dirs: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700190 "external/vixl/src",
Andreas Gampe27bd4dd2017-08-23 11:27:08 -0700191 ],
Andreas Gampe61501212016-11-03 16:48:51 -0700192
Andreas Gampe896583e2018-06-15 13:31:58 -0700193 tidy_checks: art_clang_tidy_errors + art_clang_tidy_disabled,
George Burgess IV7fb46652017-06-16 15:35:33 -0700194
195 tidy_flags: [
196 // The static analyzer treats DCHECK as always enabled; we sometimes get
197 // false positives when we use DCHECKs with code that relies on NDEBUG.
198 "-extra-arg=-UNDEBUG",
George Burgess IVdd8aa322017-06-21 16:34:35 -0700199 // clang-tidy complains about functions like:
200 // void foo() { CHECK(kIsFooEnabled); /* do foo... */ }
201 // not being marked noreturn if kIsFooEnabled is false.
202 "-extra-arg=-Wno-missing-noreturn",
Andreas Gampe020020f2018-07-10 12:34:23 -0700203 // Because tidy doesn't like our flow checks for compile-time configuration and thinks that
204 // the following code is dead (it is, but not for all configurations), disable unreachable
205 // code detection in Clang for tidy builds. It is still on for regular build steps, so we
206 // will still get the "real" errors.
207 "-extra-arg=-Wno-unreachable-code",
Andreas Gampe896583e2018-06-15 13:31:58 -0700208 // Use art_clang_tidy_errors for build errors.
209 "-warnings-as-errors=" + art_clang_tidy_errors_str,
George Burgess IV7fb46652017-06-16 15:35:33 -0700210 ],
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700211}
212
Colin Crossbe332ed2016-09-21 13:23:53 -0700213art_debug_defaults {
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700214 name: "art_debug_defaults",
215 cflags: [
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700216 "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
217 "-DVIXL_DEBUG",
218 "-UNDEBUG",
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700219 ],
220 asflags: [
221 "-UNDEBUG",
222 ],
Colin Crossc5644062016-08-30 15:41:08 -0700223 target: {
224 // This has to be duplicated for android and host to make sure it
225 // comes after the -Wframe-larger-than warnings inserted by art.go
226 // target-specific properties
227 android: {
228 cflags: ["-Wno-frame-larger-than="],
229 },
230 host: {
231 cflags: ["-Wno-frame-larger-than="],
232 },
233 },
Colin Cross1f7f3bd2016-07-27 10:12:38 -0700234}