Add noOverride64GlobalCflags support to Soong

Bug: b/261642850
Test: Build and check warnings. Add two xfail tests in bionic and see the
results locally.

Change-Id: I68fca0084787c329b6c49ce4dff6fd132f820735
This commit is contained in:
zijunzhao 2023-01-12 07:26:20 +00:00
parent 6cf5e0d9cb
commit 933e38093d
4 changed files with 58 additions and 1 deletions

View file

@ -519,6 +519,13 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
cppflags += " ${config.NoOverrideGlobalCflags}"
toolingCppflags += " ${config.NoOverrideGlobalCflags}"
if flags.toolchain.Is64Bit() {
cflags += " ${config.NoOverride64GlobalCflags}"
toolingCflags += " ${config.NoOverride64GlobalCflags}"
cppflags += " ${config.NoOverride64GlobalCflags}"
toolingCppflags += " ${config.NoOverride64GlobalCflags}"
}
modulePath := android.PathForModuleSrc(ctx).String()
if android.IsThirdPartyPath(modulePath) {
cflags += " ${config.NoOverrideExternalGlobalCflags}"

View file

@ -4483,6 +4483,39 @@ func TestIncludeDirectoryOrdering(t *testing.T) {
}
func TestAddnoOverride64GlobalCflags(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_shared {
name: "libclient",
srcs: ["foo.c"],
shared_libs: ["libfoo#1"],
}
cc_library_shared {
name: "libfoo",
srcs: ["foo.c"],
shared_libs: ["libbar"],
export_shared_lib_headers: ["libbar"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
cc_library_shared {
name: "libbar",
export_include_dirs: ["include/libbar"],
srcs: ["foo.c"],
}`)
cFlags := ctx.ModuleForTests("libclient", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"]
if !strings.Contains(cFlags, "${config.NoOverride64GlobalCflags}") {
t.Errorf("expected %q in cflags, got %q", "${config.NoOverride64GlobalCflags}", cFlags)
}
}
func TestCcBuildBrokenClangProperty(t *testing.T) {
t.Parallel()
tests := []struct {

View file

@ -247,6 +247,8 @@ var (
"-Wno-error=enum-constexpr-conversion", // http://b/243964282
}
noOverride64GlobalCflags = []string{}
noOverrideExternalGlobalCflags = []string{
// http://b/148815709
"-Wno-sizeof-array-div",
@ -384,12 +386,26 @@ func init() {
return strings.Join(deviceGlobalCflags, " ")
})
// Export the static default NoOverrideGlobalCflags to Bazel.
// Export the static default NoOverrideGlobalCflags and NoOverride64GlobalCflags to Bazel.
exportedVars.ExportStringList("NoOverrideGlobalCflags", noOverrideGlobalCflags)
exportedVars.ExportStringList("NoOverride64GlobalCflags", noOverride64GlobalCflags)
pctx.VariableFunc("NoOverrideGlobalCflags", func(ctx android.PackageVarContext) string {
flags := noOverrideGlobalCflags
if ctx.Config().IsEnvTrue("LLVM_NEXT") {
flags = append(noOverrideGlobalCflags, llvmNextExtraCommonGlobalCflags...)
if ctx.Config().Android64() {
flags = append(noOverride64GlobalCflags)
}
}
return strings.Join(flags, " ")
})
// Export the static default NoOverride64GlobalCflags to Bazel.
exportedVars.ExportStringList("NoOverride64GlobalCflags", noOverride64GlobalCflags)
pctx.VariableFunc("NoOverride64GlobalCflags", func(ctx android.PackageVarContext) string {
flags := noOverride64GlobalCflags
if ctx.Config().IsEnvTrue("LLVM_NEXT") && ctx.Config().Android64() {
flags = append(noOverride64GlobalCflags, llvmNextExtraCommonGlobalCflags...)
}
return strings.Join(flags, " ")
})

View file

@ -93,6 +93,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("CLANG_EXTERNAL_CFLAGS", "${config.ExternalCflags}")
ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${config.NoOverrideGlobalCflags}")
ctx.Strict("GLOBAL_CLANG_CFLAGS_64_NO_OVERRIDE", "${config.NoOverride64GlobalCflags}")
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
ctx.Strict("GLOBAL_CLANG_EXTERNAL_CFLAGS_NO_OVERRIDE", "${config.NoOverrideExternalGlobalCflags}")