Remove clang indirection, affects command line ordering
Move the last clang-specific list into the common global list. This
affects the command line flag ordering due to the the -fdebug-prefix-map=
flag that is added by an init() function, which will force every native
rule to recompile.
Bug: 68947919
Test: m checkbuild
Change-Id: Ic2509e61e9555e9483b92a18d7e8d9913b7125cc
diff --git a/cc/config/clang.go b/cc/config/clang.go
index 9cfe28f..53a7306 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -92,64 +92,6 @@
"readability-function-cognitive-complexity", // http://b/175055536
}
-func init() {
- exportStringListStaticVariable("ClangExtraCflags", []string{
- "-D__compiler_offsetof=__builtin_offsetof",
-
- // Emit address-significance table which allows linker to perform safe ICF. Clang does
- // not emit the table by default on Android since NDK still uses GNU binutils.
- "-faddrsig",
-
- // Turn on -fcommon explicitly, since Clang now defaults to -fno-common. The cleanup bug
- // tracking this is http://b/151457797.
- "-fcommon",
-
- // Help catch common 32/64-bit errors.
- "-Werror=int-conversion",
-
- // Enable the new pass manager.
- "-fexperimental-new-pass-manager",
-
- // Disable overly aggressive warning for macros defined with a leading underscore
- // This happens in AndroidConfig.h, which is included nearly everywhere.
- // TODO: can we remove this now?
- "-Wno-reserved-id-macro",
-
- // Workaround for ccache with clang.
- // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
- "-Wno-unused-command-line-argument",
-
- // Force clang to always output color diagnostics. Ninja will strip the ANSI
- // color codes if it is not running in a terminal.
- "-fcolor-diagnostics",
-
- // Warnings from clang-7.0
- "-Wno-sign-compare",
-
- // Warnings from clang-8.0
- "-Wno-defaulted-function-deleted",
-
- // Disable -Winconsistent-missing-override until we can clean up the existing
- // codebase for it.
- "-Wno-inconsistent-missing-override",
-
- // Warnings from clang-10
- // Nested and array designated initialization is nice to have.
- "-Wno-c99-designator",
-
- // Warnings from clang-12
- "-Wno-gnu-folding-constant",
-
- // Calls to the APIs that are newer than the min sdk version of the caller should be
- // guarded with __builtin_available.
- "-Wunguarded-availability",
- // This macro allows the bionic versioning.h to indirectly determine whether the
- // option -Wunguarded-availability is on or not.
- "-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__",
- })
-
-}
-
func ClangFilterUnknownCflags(cflags []string) []string {
result, _ := android.FilterList(cflags, ClangUnknownCflags)
return result
diff --git a/cc/config/global.go b/cc/config/global.go
index bcee06a..dfbe6c4 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -55,6 +55,59 @@
"-Werror=pragma-pack-suspicious-include",
"-Werror=string-plus-int",
"-Werror=unreachable-code-loop-increment",
+
+ "-D__compiler_offsetof=__builtin_offsetof",
+
+ // Emit address-significance table which allows linker to perform safe ICF. Clang does
+ // not emit the table by default on Android since NDK still uses GNU binutils.
+ "-faddrsig",
+
+ // Turn on -fcommon explicitly, since Clang now defaults to -fno-common. The cleanup bug
+ // tracking this is http://b/151457797.
+ "-fcommon",
+
+ // Help catch common 32/64-bit errors.
+ "-Werror=int-conversion",
+
+ // Enable the new pass manager.
+ "-fexperimental-new-pass-manager",
+
+ // Disable overly aggressive warning for macros defined with a leading underscore
+ // This happens in AndroidConfig.h, which is included nearly everywhere.
+ // TODO: can we remove this now?
+ "-Wno-reserved-id-macro",
+
+ // Workaround for ccache with clang.
+ // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
+ "-Wno-unused-command-line-argument",
+
+ // Force clang to always output color diagnostics. Ninja will strip the ANSI
+ // color codes if it is not running in a terminal.
+ "-fcolor-diagnostics",
+
+ // Warnings from clang-7.0
+ "-Wno-sign-compare",
+
+ // Warnings from clang-8.0
+ "-Wno-defaulted-function-deleted",
+
+ // Disable -Winconsistent-missing-override until we can clean up the existing
+ // codebase for it.
+ "-Wno-inconsistent-missing-override",
+
+ // Warnings from clang-10
+ // Nested and array designated initialization is nice to have.
+ "-Wno-c99-designator",
+
+ // Warnings from clang-12
+ "-Wno-gnu-folding-constant",
+
+ // Calls to the APIs that are newer than the min sdk version of the caller should be
+ // guarded with __builtin_available.
+ "-Wunguarded-availability",
+ // This macro allows the bionic versioning.h to indirectly determine whether the
+ // option -Wunguarded-availability is on or not.
+ "-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__",
}
commonGlobalConlyflags = []string{}
@@ -246,7 +299,6 @@
bazelCommonGlobalCflags := append(
commonGlobalCflags,
[]string{
- "${ClangExtraCflags}",
// Default to zero initialization.
"-ftrivial-auto-var-init=zero",
"-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang",
@@ -255,7 +307,6 @@
pctx.VariableFunc("CommonGlobalCflags", func(ctx android.PackageVarContext) string {
flags := commonGlobalCflags
- flags = append(flags, "${ClangExtraCflags}")
// http://b/131390872
// Automatically initialize any uninitialized stack variables.