diff options
| author | mosimchah <mosimchah@gmail.com> | 2025-12-02 09:27:38 -0500 |
|---|---|---|
| committer | mosimchah <mosimchah@gmail.com> | 2025-12-02 09:27:38 -0500 |
| commit | c7bade461dc55726f62997d13a48582f7c4b4655 (patch) | |
| tree | ea0588da76060a2038f54f67efd046ca77634b10 /dexpreopt/config.go | |
| parent | 0f5414d19317805e8bbbe7c4db5f0fd78769bad5 (diff) | |
| parent | 89d78cff8b00d3b20a90074635c3fe5a2ee49474 (diff) | |
Merge branch 'lineage-23.1' of https://github.com/LineageOS/android_build_soong into HEADw16.1
* 'lineage-23.1' of https://github.com/LineageOS/android_build_soong: (528 commits)
Revert "install_symlink: Make symlink target configurable"
Reapply "Clear as much of cc.Module as possible after GenerateBuildActions"
Revert "rust: config: Fix missing CPU variant LD flags in Rust"
Rename build-flag in outdir
Revert^4 "cipd: Default CIPD proxy server to on, add opt-out"
Convert check-vintf-all to phony with actions
Create a partial implementation of check-vintf-all for soong-only
Configure RBE rust pool based on build variant
Revert^3 "Add sdk version check to arr"
Add jdk.internal.invoke to the allowlist
Make droid always depend on symbols zip
Import Device and Odm skus
Don't install gob_gen in Soong
Remove bazel reference from run_integration_tests.sh
Fix bootstrap_test.sh
Don't panic in aconfig libraries when AllowMissingDependencies is set
Avoid returning nil paths from PathForModuleSrc
Revert "Flag controled clang version"
Rework module target dependencies on required deps
Revert^2 "Add sdk version check to arr"
...
Change-Id: I6e9a63fa14fda917a42e426e5dcebbad7f67e1de
Diffstat (limited to 'dexpreopt/config.go')
| -rw-r--r-- | dexpreopt/config.go | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/dexpreopt/config.go b/dexpreopt/config.go index af09dbcca..1fb652c3c 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -101,6 +101,10 @@ type GlobalConfig struct { // "true" to force preopt with CMC GC (a.k.a., UFFD GC); "false" to force preopt with CC GC; // "default" to determine the GC type based on the kernel version file. EnableUffdGc string + + // The target's `SDK_INT` (ro.build.version.sdk) string value. "" for undefined/indeterminate. + // Conditionally used to set assumed values in AOT-compilation. + PlatformSdkVersion string } var allPlatformSystemServerJarsKey = android.NewOnceKey("allPlatformSystemServerJars") @@ -162,6 +166,7 @@ type GlobalSoongConfig struct { ManifestCheck android.Path ConstructContext android.Path UffdGcFlag android.WritablePath + AssumeValueFlags android.WritablePath } type ModuleConfig struct { @@ -469,8 +474,8 @@ func (d dex2oatDependencyTag) AllowDisabledModuleDependency(target android.Modul func (d dex2oatDependencyTag) AllowDisabledModuleDependencyProxy( ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool { - return android.OtherModulePointerProviderOrDefault( - ctx, target, android.CommonModuleInfoProvider).ReplacedByPrebuilt + return android.OtherModuleProviderOrDefault( + ctx, target, android.PrebuiltInfoProvider).ReplacedByPrebuilt } // Dex2oatDepTag represents the dependency onto the dex2oatd module. It is added to any module that @@ -514,7 +519,11 @@ func dex2oatPathFromDep(ctx android.ModuleContext) android.Path { // prebuilt explicitly here instead. var dex2oatModule android.ModuleProxy ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { - prebuiltInfo, isPrebuilt := android.OtherModuleProvider(ctx, child, android.PrebuiltModuleInfoProvider) + var isPrebuilt, usePrebuilt bool + if prebuiltInfo, ok := android.OtherModuleProvider(ctx, child, android.PrebuiltInfoProvider); ok { + isPrebuilt = prebuiltInfo.IsPrebuilt + usePrebuilt = prebuiltInfo.UsePrebuilt + } if android.EqualModules(parent, ctx.Module()) && ctx.OtherModuleDependencyTag(child) == Dex2oatDepTag { // Found the source module, or prebuilt module that has replaced the source. dex2oatModule = child @@ -525,7 +534,7 @@ func dex2oatPathFromDep(ctx android.ModuleContext) android.Path { } } if android.EqualModules(parent, dex2oatModule) && ctx.OtherModuleDependencyTag(child) == android.PrebuiltDepTag { - if isPrebuilt && prebuiltInfo.UsePrebuilt { + if isPrebuilt && usePrebuilt { dex2oatModule = child // Found a prebuilt that should be used. } } @@ -557,6 +566,7 @@ func createGlobalSoongConfig(ctx android.ModuleContext) *GlobalSoongConfig { ManifestCheck: ctx.Config().HostToolPath(ctx, "manifest_check"), ConstructContext: ctx.Config().HostToolPath(ctx, "construct_context"), UffdGcFlag: getUffdGcFlagPath(ctx), + AssumeValueFlags: getAssumeValueFlagsPath(ctx), } } @@ -609,6 +619,7 @@ type globalJsonSoongConfig struct { ManifestCheck string ConstructContext string UffdGcFlag string + AssumeValueFlags string } // ParseGlobalSoongConfig parses the given data assumed to be read from the @@ -631,6 +642,7 @@ func ParseGlobalSoongConfig(ctx android.PathContext, data []byte) (*GlobalSoongC ManifestCheck: constructPath(ctx, jc.ManifestCheck), ConstructContext: constructPath(ctx, jc.ConstructContext), UffdGcFlag: constructWritablePath(ctx, jc.UffdGcFlag), + AssumeValueFlags: constructWritablePath(ctx, jc.AssumeValueFlags), } return config, nil @@ -671,6 +683,8 @@ func (s *globalSoongConfigSingleton) GenerateBuildActions(ctx android.SingletonC return } + buildAssumedValues(ctx, global, config) + jc := globalJsonSoongConfig{ Profman: config.Profman.String(), Dex2oat: config.Dex2oat.String(), @@ -680,6 +694,7 @@ func (s *globalSoongConfigSingleton) GenerateBuildActions(ctx android.SingletonC ManifestCheck: config.ManifestCheck.String(), ConstructContext: config.ConstructContext.String(), UffdGcFlag: config.UffdGcFlag.String(), + AssumeValueFlags: config.AssumeValueFlags.String(), } data, err := json.Marshal(jc) @@ -711,6 +726,7 @@ func (s *globalSoongConfigSingleton) MakeVars(ctx android.MakeVarsContext) { config.ManifestCheck.String(), config.ConstructContext.String(), config.UffdGcFlag.String(), + config.AssumeValueFlags.String(), }, " ")) } @@ -737,6 +753,27 @@ func buildUffdGcFlag(ctx android.BuilderContext, global *GlobalConfig) { } } +func buildAssumedValues(ctx android.BuilderContext, global *GlobalConfig, globalSoong *GlobalSoongConfig) { + assumeValueFlags := getAssumeValueFlagsPath(ctx) + + if global.PlatformSdkVersion != "" { + maybeAssumedValues := fmt.Sprintf(`'--assume-value=Landroid/os/Build$VERSION;->SDK_INT:%s'`, global.PlatformSdkVersion) + rule := android.NewRuleBuilder(pctx, ctx) + cmd := rule.Command() + // First check dex2oat to see if it supports `--assume-value=` arguments. + // If it does, stash the assumed value args in a reusable output file for compilation. + // Otherwise, just create an empty placeholder file that becomes a no-op. + // TODO(b/204924812): Remove the args check after prebuilt ART modules are updated from source. + cmd.Text("if (").Tool(globalSoong.Dex2oat).Text("--help 2>&1 | grep -q -- --assume-value)"). + Text("; then echo").Text(maybeAssumedValues).Text(">").Output(assumeValueFlags). + Text("; else >").Output(assumeValueFlags). + Text("; fi") + rule.Restat().Build("dexpreopt_assume_value_flags", "dexpreopt_assume_value_flags") + } else { + android.WriteFileRuleVerbatim(ctx, assumeValueFlags, "") + } +} + func GlobalConfigForTests(ctx android.PathContext) *GlobalConfig { return &GlobalConfig{ DisablePreopt: false, @@ -791,6 +828,7 @@ func globalSoongConfigForTests(ctx android.BuilderContext) *GlobalSoongConfig { ManifestCheck: android.PathForTesting("manifest_check"), ConstructContext: android.PathForTesting("construct_context"), UffdGcFlag: android.PathForOutput(ctx, "dexpreopt_test", "uffd_gc_flag.txt"), + AssumeValueFlags: android.PathForOutput(ctx, "dexpreopt_test", "assume_value_flags.txt"), } } @@ -806,3 +844,7 @@ func GetDexpreoptDirName(ctx android.PathContext) string { func getUffdGcFlagPath(ctx android.PathContext) android.WritablePath { return android.PathForOutput(ctx, "dexpreopt/uffd_gc_flag.txt") } + +func getAssumeValueFlagsPath(ctx android.PathContext) android.WritablePath { + return android.PathForOutput(ctx, "dexpreopt/assume_value_flags.txt") +} |
