Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 1 | // Copyright 2016 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 15 | package config |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "strings" |
| 19 | |
| 20 | "android/soong/android" |
Ramy Medhat | 9a90fe5 | 2020-04-13 13:21:23 -0400 | [diff] [blame] | 21 | "android/soong/remoteexec" |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 22 | ) |
| 23 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 24 | var ( |
Leo Li | 8756b37 | 2017-05-22 16:11:34 -0700 | [diff] [blame] | 25 | // Flags used by lots of devices. Putting them in package static variables |
| 26 | // will save bytes in build.ninja so they aren't repeated for every file |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 27 | commonGlobalCflags = []string{ |
| 28 | "-DANDROID", |
| 29 | "-fmessage-length=0", |
| 30 | "-W", |
| 31 | "-Wall", |
| 32 | "-Wno-unused", |
| 33 | "-Winit-self", |
| 34 | "-Wpointer-arith", |
George Burgess IV | fb81db2 | 2020-02-22 19:28:56 -0800 | [diff] [blame] | 35 | "-Wunreachable-code-loop-increment", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 36 | |
Colin Cross | 7278afc | 2017-11-02 22:38:32 -0700 | [diff] [blame] | 37 | // Make paths in deps files relative |
| 38 | "-no-canonical-prefixes", |
| 39 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 40 | "-DNDEBUG", |
| 41 | "-UDEBUG", |
Colin Cross | 7278afc | 2017-11-02 22:38:32 -0700 | [diff] [blame] | 42 | |
| 43 | "-fno-exceptions", |
| 44 | "-Wno-multichar", |
| 45 | |
| 46 | "-O2", |
| 47 | "-g", |
cmtice | 5e13f86 | 2021-04-22 03:17:16 +0000 | [diff] [blame] | 48 | "-fdebug-default-version=5", |
Yi Kong | 110cd5f | 2020-11-04 01:44:15 +0800 | [diff] [blame] | 49 | "-fdebug-info-for-profiling", |
Colin Cross | 7278afc | 2017-11-02 22:38:32 -0700 | [diff] [blame] | 50 | |
| 51 | "-fno-strict-aliasing", |
Dan Willemsen | 5d980c8 | 2019-08-27 19:37:10 -0700 | [diff] [blame] | 52 | |
| 53 | "-Werror=date-time", |
Elliott Hughes | 2cdbdf1 | 2019-12-03 18:13:00 -0800 | [diff] [blame] | 54 | "-Werror=pragma-pack", |
| 55 | "-Werror=pragma-pack-suspicious-include", |
Christopher Di Bella | 23a991c | 2020-11-11 22:41:32 +0000 | [diff] [blame] | 56 | "-Werror=string-plus-int", |
George Burgess IV | fb81db2 | 2020-02-22 19:28:56 -0800 | [diff] [blame] | 57 | "-Werror=unreachable-code-loop-increment", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Colin Cross | 6f6a428 | 2016-10-17 14:19:06 -0700 | [diff] [blame] | 60 | commonGlobalConlyflags = []string{} |
Elliott Hughes | 5a0401a | 2016-10-07 13:12:58 -0700 | [diff] [blame] | 61 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 62 | deviceGlobalCflags = []string{ |
Colin Cross | 133dbe7 | 2017-11-02 22:55:19 -0700 | [diff] [blame] | 63 | "-ffunction-sections", |
Colin Cross | ea3141d | 2017-11-06 14:02:02 -0800 | [diff] [blame] | 64 | "-fdata-sections", |
| 65 | "-fno-short-enums", |
Colin Cross | 133dbe7 | 2017-11-02 22:55:19 -0700 | [diff] [blame] | 66 | "-funwind-tables", |
| 67 | "-fstack-protector-strong", |
| 68 | "-Wa,--noexecstack", |
| 69 | "-D_FORTIFY_SOURCE=2", |
| 70 | |
| 71 | "-Wstrict-aliasing=2", |
| 72 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 73 | "-Werror=return-type", |
| 74 | "-Werror=non-virtual-dtor", |
| 75 | "-Werror=address", |
| 76 | "-Werror=sequence-point", |
Colin Cross | 133dbe7 | 2017-11-02 22:55:19 -0700 | [diff] [blame] | 77 | "-Werror=format-security", |
Colin Cross | c8bed31 | 2021-07-14 17:56:21 -0700 | [diff] [blame^] | 78 | "-nostdlibinc", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Colin Cross | 26f1450 | 2017-11-06 13:59:48 -0800 | [diff] [blame] | 81 | deviceGlobalCppflags = []string{ |
| 82 | "-fvisibility-inlines-hidden", |
| 83 | } |
| 84 | |
Colin Cross | 324a457 | 2017-11-02 23:09:41 -0700 | [diff] [blame] | 85 | deviceGlobalLdflags = []string{ |
| 86 | "-Wl,-z,noexecstack", |
| 87 | "-Wl,-z,relro", |
| 88 | "-Wl,-z,now", |
| 89 | "-Wl,--build-id=md5", |
| 90 | "-Wl,--warn-shared-textrel", |
| 91 | "-Wl,--fatal-warnings", |
| 92 | "-Wl,--no-undefined-version", |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 93 | // TODO: Eventually we should link against a libunwind.a with hidden symbols, and then these |
| 94 | // --exclude-libs arguments can be removed. |
Christopher Ferris | c3a1e22 | 2019-04-10 17:57:50 -0700 | [diff] [blame] | 95 | "-Wl,--exclude-libs,libgcc.a", |
Yi Kong | 3d8792f | 2019-05-06 16:18:33 -0700 | [diff] [blame] | 96 | "-Wl,--exclude-libs,libgcc_stripped.a", |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 97 | "-Wl,--exclude-libs,libunwind_llvm.a", |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 98 | "-Wl,--exclude-libs,libunwind.a", |
Ryo Hashimoto | 5818b93 | 2021-03-23 15:05:22 +0900 | [diff] [blame] | 99 | "-Wl,--icf=safe", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Colin Cross | 33bac24 | 2021-07-14 17:03:16 -0700 | [diff] [blame] | 102 | deviceGlobalLldflags = append(deviceGlobalLdflags, |
Chih-Hung Hsieh | 02b4da5 | 2018-04-03 11:33:34 -0700 | [diff] [blame] | 103 | []string{ |
Chih-Hung Hsieh | 02b4da5 | 2018-04-03 11:33:34 -0700 | [diff] [blame] | 104 | "-fuse-ld=lld", |
| 105 | }...) |
| 106 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 107 | hostGlobalCflags = []string{} |
| 108 | |
Colin Cross | 26f1450 | 2017-11-06 13:59:48 -0800 | [diff] [blame] | 109 | hostGlobalCppflags = []string{} |
| 110 | |
Colin Cross | 324a457 | 2017-11-02 23:09:41 -0700 | [diff] [blame] | 111 | hostGlobalLdflags = []string{} |
| 112 | |
Chih-Hung Hsieh | 3101a96 | 2018-04-17 14:16:05 -0700 | [diff] [blame] | 113 | hostGlobalLldflags = []string{"-fuse-ld=lld"} |
Chih-Hung Hsieh | 02b4da5 | 2018-04-03 11:33:34 -0700 | [diff] [blame] | 114 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 115 | commonGlobalCppflags = []string{ |
| 116 | "-Wsign-promo", |
Colin Cross | c8bed31 | 2021-07-14 17:56:21 -0700 | [diff] [blame^] | 117 | |
| 118 | // -Wimplicit-fallthrough is not enabled by -Wall. |
| 119 | "-Wimplicit-fallthrough", |
| 120 | |
| 121 | // Enable clang's thread-safety annotations in libcxx. |
| 122 | "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS", |
| 123 | |
| 124 | // libc++'s math.h has an #include_next outside of system_headers. |
| 125 | "-Wno-gnu-include-next", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | noOverrideGlobalCflags = []string{ |
Christopher Di Bella | 23a991c | 2020-11-11 22:41:32 +0000 | [diff] [blame] | 129 | "-Werror=bool-operation", |
| 130 | "-Werror=implicit-int-float-conversion", |
| 131 | "-Werror=int-in-bool-context", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 132 | "-Werror=int-to-pointer-cast", |
| 133 | "-Werror=pointer-to-int-cast", |
Christopher Di Bella | 23a991c | 2020-11-11 22:41:32 +0000 | [diff] [blame] | 134 | "-Werror=string-compare", |
| 135 | "-Werror=xor-used-as-pow", |
Stephen Hines | 2210e72 | 2020-07-15 11:11:57 -0700 | [diff] [blame] | 136 | // http://b/161386391 for -Wno-void-pointer-to-enum-cast |
| 137 | "-Wno-void-pointer-to-enum-cast", |
| 138 | // http://b/161386391 for -Wno-void-pointer-to-int-cast |
| 139 | "-Wno-void-pointer-to-int-cast", |
| 140 | // http://b/161386391 for -Wno-pointer-to-int-cast |
| 141 | "-Wno-pointer-to-int-cast", |
George Burgess IV | 6c69164 | 2019-09-18 17:52:05 -0700 | [diff] [blame] | 142 | "-Werror=fortify-source", |
Colin Cross | c8bed31 | 2021-07-14 17:56:21 -0700 | [diff] [blame^] | 143 | |
| 144 | "-Werror=address-of-temporary", |
| 145 | // Bug: http://b/29823425 Disable -Wnull-dereference until the |
| 146 | // new cases detected by this warning in Clang r271374 are |
| 147 | // fixed. |
| 148 | //"-Werror=null-dereference", |
| 149 | "-Werror=return-type", |
| 150 | |
| 151 | // http://b/72331526 Disable -Wtautological-* until the instances detected by these |
| 152 | // new warnings are fixed. |
| 153 | "-Wno-tautological-constant-compare", |
| 154 | "-Wno-tautological-type-limit-compare", |
| 155 | // http://b/145210666 |
| 156 | "-Wno-reorder-init-list", |
| 157 | // http://b/145211066 |
| 158 | "-Wno-implicit-int-float-conversion", |
| 159 | // New warnings to be fixed after clang-r377782. |
| 160 | "-Wno-int-in-bool-context", // http://b/148287349 |
| 161 | "-Wno-sizeof-array-div", // http://b/148815709 |
| 162 | "-Wno-tautological-overlap-compare", // http://b/148815696 |
| 163 | // New warnings to be fixed after clang-r383902. |
| 164 | "-Wno-deprecated-copy", // http://b/153746672 |
| 165 | "-Wno-range-loop-construct", // http://b/153747076 |
| 166 | "-Wno-misleading-indentation", // http://b/153746954 |
| 167 | "-Wno-zero-as-null-pointer-constant", // http://b/68236239 |
| 168 | "-Wno-deprecated-anon-enum-enum-conversion", // http://b/153746485 |
| 169 | "-Wno-deprecated-enum-enum-conversion", // http://b/153746563 |
| 170 | "-Wno-string-compare", // http://b/153764102 |
| 171 | "-Wno-enum-enum-conversion", // http://b/154138986 |
| 172 | "-Wno-enum-float-conversion", // http://b/154255917 |
| 173 | "-Wno-pessimizing-move", // http://b/154270751 |
| 174 | // New warnings to be fixed after clang-r399163 |
| 175 | "-Wno-non-c-typedef-for-linkage", // http://b/161304145 |
| 176 | // New warnings to be fixed after clang-r407598 |
| 177 | "-Wno-string-concatenation", // http://b/175068488 |
| 178 | } |
| 179 | |
| 180 | // Extra cflags for external third-party projects to disable warnings that |
| 181 | // are infeasible to fix in all the external projects and their upstream repos. |
| 182 | extraExternalCflags = []string{ |
| 183 | "-Wno-enum-compare", |
| 184 | "-Wno-enum-compare-switch", |
| 185 | |
| 186 | // http://b/72331524 Allow null pointer arithmetic until the instances detected by |
| 187 | // this new warning are fixed. |
| 188 | "-Wno-null-pointer-arithmetic", |
| 189 | |
| 190 | // Bug: http://b/29823425 Disable -Wnull-dereference until the |
| 191 | // new instances detected by this warning are fixed. |
| 192 | "-Wno-null-dereference", |
| 193 | |
| 194 | // http://b/145211477 |
| 195 | "-Wno-pointer-compare", |
| 196 | // http://b/145211022 |
| 197 | "-Wno-xor-used-as-pow", |
| 198 | // http://b/145211022 |
| 199 | "-Wno-final-dtor-non-final-class", |
| 200 | |
| 201 | // http://b/165945989 |
| 202 | "-Wno-psabi", |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 205 | IllegalFlags = []string{ |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 206 | "-w", |
| 207 | } |
Colin Cross | 6f6a428 | 2016-10-17 14:19:06 -0700 | [diff] [blame] | 208 | |
Dan Albert | 043833c | 2017-02-03 16:13:38 -0800 | [diff] [blame] | 209 | CStdVersion = "gnu99" |
Elliott Hughes | 34e4e41 | 2018-11-30 16:03:06 +0000 | [diff] [blame] | 210 | CppStdVersion = "gnu++17" |
Dan Albert | 043833c | 2017-02-03 16:13:38 -0800 | [diff] [blame] | 211 | ExperimentalCStdVersion = "gnu11" |
Elliott Hughes | 3797612 | 2018-11-28 14:16:39 -0800 | [diff] [blame] | 212 | ExperimentalCppStdVersion = "gnu++2a" |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 213 | |
Leo Li | 8756b37 | 2017-05-22 16:11:34 -0700 | [diff] [blame] | 214 | // prebuilts/clang default settings. |
| 215 | ClangDefaultBase = "prebuilts/clang/host" |
Pirama Arumuga Nainar | 3e54508 | 2021-06-23 22:39:37 -0700 | [diff] [blame] | 216 | ClangDefaultVersion = "clang-r416183b1" |
| 217 | ClangDefaultShortVersion = "12.0.7" |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 218 | |
Chih-Hung Hsieh | 775edde | 2017-12-24 22:24:47 -0800 | [diff] [blame] | 219 | // Directories with warnings from Android.bp files. |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 220 | WarningAllowedProjects = []string{ |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 221 | "device/", |
Chih-Hung Hsieh | 64a38dc | 2017-11-14 14:09:14 -0800 | [diff] [blame] | 222 | "vendor/", |
| 223 | } |
| 224 | |
Chih-Hung Hsieh | 775edde | 2017-12-24 22:24:47 -0800 | [diff] [blame] | 225 | // Directories with warnings from Android.mk files. |
| 226 | WarningAllowedOldProjects = []string{} |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 227 | ) |
| 228 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 229 | var pctx = android.NewPackageContext("android/soong/cc/config") |
| 230 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 231 | func init() { |
Kousik Kumar | d207cbe | 2020-10-20 05:52:49 +0000 | [diff] [blame] | 232 | if android.BuildOs == android.Linux { |
| 233 | commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=") |
| 234 | } |
| 235 | |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame] | 236 | exportStringListStaticVariable("CommonGlobalConlyflags", commonGlobalConlyflags) |
| 237 | exportStringListStaticVariable("DeviceGlobalCppflags", deviceGlobalCppflags) |
| 238 | exportStringListStaticVariable("DeviceGlobalLdflags", deviceGlobalLdflags) |
| 239 | exportStringListStaticVariable("DeviceGlobalLldflags", deviceGlobalLldflags) |
| 240 | exportStringListStaticVariable("HostGlobalCppflags", hostGlobalCppflags) |
| 241 | exportStringListStaticVariable("HostGlobalLdflags", hostGlobalLdflags) |
| 242 | exportStringListStaticVariable("HostGlobalLldflags", hostGlobalLldflags) |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 243 | |
| 244 | // Export the static default CommonClangGlobalCflags to Bazel. |
| 245 | // TODO(187086342): handle cflags that are set in VariableFuncs. |
| 246 | commonClangGlobalCFlags := append( |
Colin Cross | 33bac24 | 2021-07-14 17:03:16 -0700 | [diff] [blame] | 247 | commonGlobalCflags, |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 248 | []string{ |
| 249 | "${ClangExtraCflags}", |
| 250 | // Default to zero initialization. |
| 251 | "-ftrivial-auto-var-init=zero", |
| 252 | "-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang", |
| 253 | }...) |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame] | 254 | exportedStringListVars.Set("CommonClangGlobalCflags", commonClangGlobalCFlags) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 255 | |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 256 | pctx.VariableFunc("CommonClangGlobalCflags", func(ctx android.PackageVarContext) string { |
Colin Cross | 33bac24 | 2021-07-14 17:03:16 -0700 | [diff] [blame] | 257 | flags := commonGlobalCflags |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 258 | flags = append(flags, "${ClangExtraCflags}") |
| 259 | |
| 260 | // http://b/131390872 |
| 261 | // Automatically initialize any uninitialized stack variables. |
Stephen Hines | 5c873ac | 2020-05-14 00:59:09 +0000 | [diff] [blame] | 262 | // Prefer zero-init if multiple options are set. |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 263 | if ctx.Config().IsEnvTrue("AUTO_ZERO_INITIALIZE") { |
| 264 | flags = append(flags, "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang") |
| 265 | } else if ctx.Config().IsEnvTrue("AUTO_PATTERN_INITIALIZE") { |
| 266 | flags = append(flags, "-ftrivial-auto-var-init=pattern") |
Stephen Hines | 797e195 | 2020-01-28 14:43:11 -0800 | [diff] [blame] | 267 | } else if ctx.Config().IsEnvTrue("AUTO_UNINITIALIZE") { |
| 268 | flags = append(flags, "-ftrivial-auto-var-init=uninitialized") |
Stephen Hines | 0e1d5d8 | 2020-01-30 15:06:00 -0800 | [diff] [blame] | 269 | } else { |
Stephen Hines | 5c873ac | 2020-05-14 00:59:09 +0000 | [diff] [blame] | 270 | // Default to zero initialization. |
| 271 | flags = append(flags, "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang") |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 272 | } |
Stephen Hines | 66c8b44 | 2019-06-10 17:40:12 -0700 | [diff] [blame] | 273 | return strings.Join(flags, " ") |
| 274 | }) |
| 275 | |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 276 | // Export the static default DeviceClangGlobalCflags to Bazel. |
| 277 | // TODO(187086342): handle cflags that are set in VariableFuncs. |
Colin Cross | c8bed31 | 2021-07-14 17:56:21 -0700 | [diff] [blame^] | 278 | exportedStringListVars.Set("DeviceClangGlobalCflags", deviceGlobalCflags) |
Jingwen Chen | bf61afb | 2021-05-06 13:31:18 +0000 | [diff] [blame] | 279 | |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 280 | pctx.VariableFunc("DeviceClangGlobalCflags", func(ctx android.PackageVarContext) string { |
Colin Cross | c8bed31 | 2021-07-14 17:56:21 -0700 | [diff] [blame^] | 281 | return strings.Join(deviceGlobalCflags, " ") |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 282 | }) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 283 | |
Colin Cross | 33bac24 | 2021-07-14 17:03:16 -0700 | [diff] [blame] | 284 | exportStringListStaticVariable("HostClangGlobalCflags", hostGlobalCflags) |
Colin Cross | c8bed31 | 2021-07-14 17:56:21 -0700 | [diff] [blame^] | 285 | exportStringListStaticVariable("NoOverrideClangGlobalCflags", noOverrideGlobalCflags) |
| 286 | exportStringListStaticVariable("CommonClangGlobalCppflags", commonGlobalCppflags) |
| 287 | exportStringListStaticVariable("ClangExternalCflags", extraExternalCflags) |
Yi Kong | cc80f8d | 2018-06-06 14:42:44 -0700 | [diff] [blame] | 288 | |
Colin Cross | 1cfd89a | 2016-09-15 09:30:46 -0700 | [diff] [blame] | 289 | // Everything in these lists is a crime against abstraction and dependency tracking. |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 290 | // Do not add anything to this list. |
Jingwen Chen | 2199995 | 2021-05-19 05:53:51 +0000 | [diff] [blame] | 291 | commonGlobalIncludes := []string{ |
| 292 | "system/core/include", |
| 293 | "system/logging/liblog/include", |
| 294 | "system/media/audio/include", |
| 295 | "hardware/libhardware/include", |
| 296 | "hardware/libhardware_legacy/include", |
| 297 | "hardware/ril/include", |
| 298 | "frameworks/native/include", |
| 299 | "frameworks/native/opengl/include", |
| 300 | "frameworks/av/include", |
| 301 | } |
Jingwen Chen | 51a1e1c | 2021-05-20 13:40:14 +0000 | [diff] [blame] | 302 | exportedStringListVars.Set("CommonGlobalIncludes", commonGlobalIncludes) |
Jingwen Chen | 2199995 | 2021-05-19 05:53:51 +0000 | [diff] [blame] | 303 | pctx.PrefixedExistentPathsForSourcesVariable("CommonGlobalIncludes", "-I", commonGlobalIncludes) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 304 | |
Leo Li | 8756b37 | 2017-05-22 16:11:34 -0700 | [diff] [blame] | 305 | pctx.SourcePathVariable("ClangDefaultBase", ClangDefaultBase) |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 306 | pctx.VariableFunc("ClangBase", func(ctx android.PackageVarContext) string { |
| 307 | if override := ctx.Config().Getenv("LLVM_PREBUILTS_BASE"); override != "" { |
| 308 | return override |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 309 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 310 | return "${ClangDefaultBase}" |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 311 | }) |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 312 | pctx.VariableFunc("ClangVersion", func(ctx android.PackageVarContext) string { |
| 313 | if override := ctx.Config().Getenv("LLVM_PREBUILTS_VERSION"); override != "" { |
| 314 | return override |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 315 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 316 | return ClangDefaultVersion |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 317 | }) |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 318 | pctx.StaticVariable("ClangPath", "${ClangBase}/${HostPrebuiltTag}/${ClangVersion}") |
| 319 | pctx.StaticVariable("ClangBin", "${ClangPath}/bin") |
| 320 | |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 321 | pctx.VariableFunc("ClangShortVersion", func(ctx android.PackageVarContext) string { |
| 322 | if override := ctx.Config().Getenv("LLVM_RELEASE_VERSION"); override != "" { |
| 323 | return override |
Stephen Hines | e55a4cc | 2016-11-18 17:12:38 -0800 | [diff] [blame] | 324 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 325 | return ClangDefaultShortVersion |
Stephen Hines | e55a4cc | 2016-11-18 17:12:38 -0800 | [diff] [blame] | 326 | }) |
Stephen Hines | 755fe07 | 2018-01-24 19:58:36 -0800 | [diff] [blame] | 327 | pctx.StaticVariable("ClangAsanLibDir", "${ClangBase}/linux-x86/${ClangVersion}/lib64/clang/${ClangShortVersion}/lib/linux") |
Alistair Strachan | 777475c | 2016-08-26 12:55:49 -0700 | [diff] [blame] | 328 | |
Jayant Chowdhary | e622d20 | 2017-02-01 19:19:52 -0800 | [diff] [blame] | 329 | // These are tied to the version of LLVM directly in external/llvm, so they might trail the host prebuilts |
| 330 | // being used for the rest of the build process. |
| 331 | pctx.SourcePathVariable("RSClangBase", "prebuilts/clang/host") |
| 332 | pctx.SourcePathVariable("RSClangVersion", "clang-3289846") |
| 333 | pctx.SourcePathVariable("RSReleaseVersion", "3.8") |
| 334 | pctx.StaticVariable("RSLLVMPrebuiltsPath", "${RSClangBase}/${HostPrebuiltTag}/${RSClangVersion}/bin") |
| 335 | pctx.StaticVariable("RSIncludePath", "${RSLLVMPrebuiltsPath}/../lib64/clang/${RSReleaseVersion}/include") |
| 336 | |
Jeff Gaston | 734e380 | 2017-04-10 15:47:24 -0700 | [diff] [blame] | 337 | pctx.PrefixedExistentPathsForSourcesVariable("RsGlobalIncludes", "-I", |
Colin Cross | 2a252be | 2017-05-01 17:37:24 -0700 | [diff] [blame] | 338 | []string{ |
| 339 | "external/clang/lib/Headers", |
| 340 | "frameworks/rs/script_api/include", |
| 341 | }) |
| 342 | |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 343 | pctx.VariableFunc("CcWrapper", func(ctx android.PackageVarContext) string { |
| 344 | if override := ctx.Config().Getenv("CC_WRAPPER"); override != "" { |
| 345 | return override + " " |
Alistair Strachan | 777475c | 2016-08-26 12:55:49 -0700 | [diff] [blame] | 346 | } |
Dan Willemsen | 54daaf0 | 2018-03-12 13:24:09 -0700 | [diff] [blame] | 347 | return "" |
Alistair Strachan | 777475c | 2016-08-26 12:55:49 -0700 | [diff] [blame] | 348 | }) |
Ramy Medhat | 9a90fe5 | 2020-04-13 13:21:23 -0400 | [diff] [blame] | 349 | |
Colin Cross | 77cdcfd | 2021-03-12 11:28:25 -0800 | [diff] [blame] | 350 | pctx.StaticVariableWithEnvOverride("RECXXPool", "RBE_CXX_POOL", remoteexec.DefaultPool) |
| 351 | pctx.StaticVariableWithEnvOverride("RECXXLinksPool", "RBE_CXX_LINKS_POOL", remoteexec.DefaultPool) |
| 352 | pctx.StaticVariableWithEnvOverride("REClangTidyPool", "RBE_CLANG_TIDY_POOL", remoteexec.DefaultPool) |
| 353 | pctx.StaticVariableWithEnvOverride("RECXXLinksExecStrategy", "RBE_CXX_LINKS_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
| 354 | pctx.StaticVariableWithEnvOverride("REClangTidyExecStrategy", "RBE_CLANG_TIDY_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
| 355 | pctx.StaticVariableWithEnvOverride("REAbiDumperExecStrategy", "RBE_ABI_DUMPER_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
| 356 | pctx.StaticVariableWithEnvOverride("REAbiLinkerExecStrategy", "RBE_ABI_LINKER_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | var HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS) |