diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/Android.bp | 1 | ||||
-rw-r--r-- | cc/afdo.go | 2 | ||||
-rw-r--r-- | cc/builder.go | 7 | ||||
-rw-r--r-- | cc/cc.go | 11 | ||||
-rw-r--r-- | cc/cc_test.go | 6 | ||||
-rw-r--r-- | cc/config/tidy.go | 9 | ||||
-rw-r--r-- | cc/config/x86_64_device.go | 19 | ||||
-rw-r--r-- | cc/fuzz.go | 1 | ||||
-rw-r--r-- | cc/lto.go | 9 | ||||
-rw-r--r-- | cc/test.go | 2 |
10 files changed, 39 insertions, 28 deletions
diff --git a/cc/Android.bp b/cc/Android.bp index 8fa0fbeb0..77e96db35 100644 --- a/cc/Android.bp +++ b/cc/Android.bp @@ -19,6 +19,7 @@ bootstrap_go_package { "soong-multitree", "soong-snapshot", "soong-sysprop-bp2build", + "soong-testing", "soong-tradefed", ], srcs: [ diff --git a/cc/afdo.go b/cc/afdo.go index ac210d44a..91cf0b8a2 100644 --- a/cc/afdo.go +++ b/cc/afdo.go @@ -35,7 +35,7 @@ var ( var afdoProfileProjectsConfigKey = android.NewOnceKey("AfdoProfileProjects") // This flag needs to be in both CFlags and LdFlags to ensure correct symbol ordering -const afdoFlagsFormat = "-fprofile-sample-use=%s" +const afdoFlagsFormat = "-fprofile-sample-use=%s -fprofile-sample-accurate" func recordMissingAfdoProfileFile(ctx android.BaseModuleContext, missing string) { getNamedMapForConfig(ctx.Config(), modulesMissingProfileFileKey).Store(missing, true) diff --git a/cc/builder.go b/cc/builder.go index 3f582fa85..69cf75bdd 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -681,16 +681,11 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs tidyCmd := "${config.ClangBin}/clang-tidy" rule := clangTidy - reducedCFlags := moduleFlags if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") { rule = clangTidyRE - // b/248371171, work around RBE input processor problem - // some cflags rejected by input processor, but usually - // do not affect included files or clang-tidy - reducedCFlags = config.TidyReduceCFlags(reducedCFlags) } - sharedCFlags := shareFlags("cFlags", reducedCFlags) + sharedCFlags := shareFlags("cFlags", moduleFlags) srcRelPath := srcFile.Rel() // Add the .tidy rule @@ -24,6 +24,7 @@ import ( "strconv" "strings" + "android/soong/testing" "android/soong/ui/metrics/bp2build_metrics_proto" "github.com/google/blueprint" @@ -862,9 +863,10 @@ type Module struct { Properties BaseProperties // initialize before calling Init - hod android.HostOrDeviceSupported - multilib android.Multilib - bazelable bool + hod android.HostOrDeviceSupported + multilib android.Multilib + bazelable bool + testModule bool // Allowable SdkMemberTypes of this module type. sdkMemberTypes []android.SdkMemberType @@ -2329,6 +2331,9 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } } + if c.testModule { + ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{}) + } c.maybeInstall(ctx, apexInfo) } diff --git a/cc/cc_test.go b/cc/cc_test.go index 794c5ee51..e2dba9043 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -720,7 +720,7 @@ func TestDataLibs(t *testing.T) { return } if len(testBinary.dataPaths()) != 1 { - t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths()) + t.Errorf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths()) return } @@ -777,7 +777,7 @@ func TestDataLibsRelativeInstallPath(t *testing.T) { t.Fatalf("expected exactly one output file. output files: [%s]", outputFiles) } if len(testBinary.dataPaths()) != 2 { - t.Fatalf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths()) + t.Fatalf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths()) } outputPath := outputFiles[0].String() @@ -3332,7 +3332,7 @@ func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) { t.Errorf("expected exactly one output file. output files: [%s]", outputFiles) } if len(testBinary.dataPaths()) != 1 { - t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths()) + t.Errorf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths()) } outputPath := outputFiles[0].String() diff --git a/cc/config/tidy.go b/cc/config/tidy.go index efa45495b..b40557a29 100644 --- a/cc/config/tidy.go +++ b/cc/config/tidy.go @@ -16,7 +16,6 @@ package config import ( "android/soong/android" - "regexp" "strings" ) @@ -281,11 +280,3 @@ func TidyFlagsForSrcFile(srcFile android.Path, flags string) string { } return flags } - -var ( - removedCFlags = regexp.MustCompile(" -fsanitize=[^ ]*memtag-[^ ]* ") -) - -func TidyReduceCFlags(flags string) string { - return removedCFlags.ReplaceAllString(flags, " ") -} diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index 9f093bb90..00a395f78 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -33,6 +33,8 @@ var ( "-Wl,--hash-style=gnu", } + X86_64Lldflags = x86_64Ldflags + x86_64ArchVariantCflags = map[string][]string{ "": []string{ "-march=x86-64", @@ -94,10 +96,23 @@ func init() { exportedVars.ExportStringListStaticVariable("X86_64ToolchainLdflags", []string{"-m64"}) exportedVars.ExportStringListStaticVariable("X86_64Ldflags", x86_64Ldflags) - exportedVars.ExportStringListStaticVariable("X86_64Lldflags", x86_64Ldflags) + exportedVars.ExportStringList("X86_64Lldflags", X86_64Lldflags) + pctx.VariableFunc("X86_64Lldflags", func(ctx android.PackageVarContext) string { + maxPageSizeFlag := "-Wl,-z,max-page-size=" + ctx.Config().MaxPageSizeSupported() + flags := append(X86_64Lldflags, maxPageSizeFlag) + return strings.Join(flags, " ") + }) // Clang cflags - exportedVars.ExportStringListStaticVariable("X86_64Cflags", x86_64Cflags) + exportedVars.ExportStringList("X86_64Cflags", x86_64Cflags) + pctx.VariableFunc("X86_64Cflags", func(ctx android.PackageVarContext) string { + flags := x86_64Cflags + if ctx.Config().PageSizeAgnostic() { + flags = append(flags, "-D__BIONIC_NO_PAGE_SIZE_MACRO") + } + return strings.Join(flags, " ") + }) + exportedVars.ExportStringListStaticVariable("X86_64Cppflags", x86_64Cppflags) // Yasm flags diff --git a/cc/fuzz.go b/cc/fuzz.go index df9f21ad2..8fc48983e 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -96,6 +96,7 @@ func fuzzMutatorDeps(mctx android.TopDownMutatorContext) { // your device, or $ANDROID_PRODUCT_OUT/data/fuzz in your build tree. func LibFuzzFactory() android.Module { module := NewFuzzer(android.HostAndDeviceSupported) + module.testModule = true return module.Init() } @@ -147,10 +147,11 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags { } } - // Register allocation MLGO flags for ARM64. - if ctx.Arch().ArchType == android.Arm64 { - ltoCFlags = append(ltoCFlags, "-mllvm -regalloc-enable-advisor=release") - ltoLdFlags = append(ltoLdFlags, "-Wl,-mllvm,-regalloc-enable-advisor=release") + if !ctx.Config().IsEnvFalse("THINLTO_USE_MLGO") { + // Register allocation MLGO flags for ARM64. + if ctx.Arch().ArchType == android.Arm64 { + ltoLdFlags = append(ltoLdFlags, "-Wl,-mllvm,-regalloc-enable-advisor=release") + } // Flags for training MLGO model. if ctx.Config().IsEnvTrue("THINLTO_EMIT_INDEXES_AND_IMPORTS") { ltoLdFlags = append(ltoLdFlags, "-Wl,--save-temps=import") diff --git a/cc/test.go b/cc/test.go index 5b778dc87..a4224c34a 100644 --- a/cc/test.go +++ b/cc/test.go @@ -158,6 +158,7 @@ func TestLibraryFactory() android.Module { // binary. func BenchmarkFactory() android.Module { module := NewBenchmark(android.HostAndDeviceSupported) + module.testModule = true return module.Init() } @@ -489,6 +490,7 @@ func NewTest(hod android.HostOrDeviceSupported, bazelable bool) *Module { module, binary := newBinary(hod, bazelable) module.bazelable = bazelable module.multilib = android.MultilibBoth + module.testModule = true binary.baseInstaller = NewTestInstaller() test := &testBinary{ |