Loading dexpreopt/config.go +23 −11 Original line number Diff line number Diff line Loading @@ -84,6 +84,15 @@ type GlobalConfig struct { BootFlags string // extra flags to pass to dex2oat for the boot image Dex2oatImageXmx string // max heap size for dex2oat for the boot image Dex2oatImageXms string // initial heap size for dex2oat for the boot image // If true, downgrade the compiler filter of dexpreopt to "extract" when verify_uses_libraries // check fails, instead of failing the build. This will disable any AOT-compilation. // // The intended use case for this flag is to have a smoother migration path for the Java // modules that need to add <uses-library> information in their build files. The flag allows to // quickly silence build errors. This flag should be used with caution and only as a temporary // measure, as it masks real errors and affects performance. RelaxUsesLibraryCheck bool } // GlobalSoongConfig contains the global config that is generated from Soong, Loading Loading @@ -113,8 +122,9 @@ type ModuleConfig struct { ProfileIsTextListing bool ProfileBootListing android.OptionalPath EnforceUsesLibraries bool ProvidesUsesLibrary string // the name of the <uses-library> (usually the same as its module) EnforceUsesLibraries bool // turn on build-time verify_uses_libraries check EnforceUsesLibrariesStatusFile android.Path // a file with verify_uses_libraries errors (if any) ProvidesUsesLibrary string // library name (usually the same as module name) ClassLoaderContexts ClassLoaderContextMap Archs []android.ArchType Loading Loading @@ -262,6 +272,7 @@ func ParseModuleConfig(ctx android.PathContext, data []byte) (*ModuleConfig, err DexPath string ManifestPath string ProfileClassListing string EnforceUsesLibrariesStatusFile string ClassLoaderContexts jsonClassLoaderContextMap DexPreoptImages []string DexPreoptImageLocations []string Loading @@ -280,6 +291,7 @@ func ParseModuleConfig(ctx android.PathContext, data []byte) (*ModuleConfig, err config.ModuleConfig.DexPath = constructPath(ctx, config.DexPath) config.ModuleConfig.ManifestPath = constructPath(ctx, config.ManifestPath) config.ModuleConfig.ProfileClassListing = android.OptionalPathForPath(constructPath(ctx, config.ProfileClassListing)) config.ModuleConfig.EnforceUsesLibrariesStatusFile = constructPath(ctx, config.EnforceUsesLibrariesStatusFile) config.ModuleConfig.ClassLoaderContexts = fromJsonClassLoaderContext(ctx, config.ClassLoaderContexts) config.ModuleConfig.DexPreoptImages = constructPaths(ctx, config.DexPreoptImages) config.ModuleConfig.DexPreoptImageLocations = config.DexPreoptImageLocations Loading dexpreopt/dexpreopt.go +21 −5 Original line number Diff line number Diff line Loading @@ -279,11 +279,12 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g // Generate command that saves host and target class loader context in shell variables. clc, paths := ComputeClassLoaderContext(module.ClassLoaderContexts) cmd := rule.Command(). Text(`eval "$(`).Tool(globalSoong.ConstructContext). rule.Command(). Text("if ! test -s ").Input(module.EnforceUsesLibrariesStatusFile). Text(` ; then eval "$(`).Tool(globalSoong.ConstructContext). Text(` --target-sdk-version ${target_sdk_version}`). Text(clc).Implicits(paths) cmd.Text(`)"`) Text(clc).Implicits(paths). Text(`)" ; fi`) } else { // Other libraries or APKs for which the exact <uses-library> list is unknown. Loading Loading @@ -366,8 +367,17 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g } else { compilerFilter = "quicken" } if module.EnforceUsesLibraries { // If the verify_uses_libraries check failed (in this case status file contains a // non-empty error message), then use "extract" compiler filter to avoid compiling any // code (it would be rejected on device because of a class loader context mismatch). cmd.Text("--compiler-filter=$(if test -s "). Input(module.EnforceUsesLibrariesStatusFile). Text(" ; then echo extract ; else echo " + compilerFilter + " ; fi)") } else { cmd.FlagWithArg("--compiler-filter=", compilerFilter) } } if generateDM { cmd.FlagWithArg("--copy-dex-files=", "false") Loading Loading @@ -542,6 +552,12 @@ func checkSystemServerOrder(ctx android.PathContext, jarIndex int) { } } // Returns path to a file containing the reult of verify_uses_libraries check (empty if the check // has succeeded, or an error message if it failed). func UsesLibrariesStatusFile(ctx android.ModuleContext) android.WritablePath { return android.PathForModuleOut(ctx, "enforce_uses_libraries.status") } func contains(l []string, s string) bool { for _, e := range l { if e == s { Loading dexpreopt/dexpreopt_test.go +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ func testModuleConfig(ctx android.PathContext, name, partition string) *ModuleCo PreoptFlags: nil, ProfileClassListing: android.OptionalPath{}, ProfileIsTextListing: false, EnforceUsesLibrariesStatusFile: android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)), EnforceUsesLibraries: false, ClassLoaderContexts: nil, Archs: []android.ArchType{android.Arm}, Loading java/app.go +9 −1 Original line number Diff line number Diff line Loading @@ -1260,13 +1260,19 @@ func (u *usesLibrary) freezeEnforceUsesLibraries() { // in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the manifest. func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path { outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml") statusFile := dexpreopt.UsesLibrariesStatusFile(ctx) rule := android.NewRuleBuilder(pctx, ctx) cmd := rule.Command().BuiltTool("manifest_check"). Flag("--enforce-uses-libraries"). Input(manifest). FlagWithOutput("--enforce-uses-libraries-status ", statusFile). FlagWithOutput("-o ", outputFile) if dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck { cmd.Flag("--enforce-uses-libraries-relax") } for _, lib := range u.usesLibraryProperties.Uses_libs { cmd.FlagWithArg("--uses-library ", lib) } Loading @@ -1284,6 +1290,7 @@ func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, man // in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the APK. func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk android.Path) android.Path { outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base()) statusFile := dexpreopt.UsesLibrariesStatusFile(ctx) rule := android.NewRuleBuilder(pctx, ctx) aapt := ctx.Config().HostToolPath(ctx, "aapt") Loading @@ -1291,7 +1298,8 @@ func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk andr Textf("aapt_binary=%s", aapt.String()).Implicit(aapt). Textf(`uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Uses_libs, " ")). Textf(`optional_uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Optional_uses_libs, " ")). Tool(android.PathForSource(ctx, "build/make/core/verify_uses_libraries.sh")).Input(apk) Textf(`relax_check="%b"`, dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck). Tool(android.PathForSource(ctx, "build/make/core/verify_uses_libraries.sh")).Input(apk).Output(statusFile) rule.Command().Text("cp -f").Input(apk).Output(outputFile) rule.Build("verify_uses_libraries", "verify <uses-library>") Loading java/dexpreopt.go +5 −3 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ type dexpreopter struct { isPresignedPrebuilt bool manifestFile android.Path statusFile android.WritablePath enforceUsesLibs bool classLoaderContexts dexpreopt.ClassLoaderContextMap Loading Loading @@ -226,6 +227,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr ProfileIsTextListing: profileIsTextListing, ProfileBootListing: profileBootListing, EnforceUsesLibrariesStatusFile: dexpreopt.UsesLibrariesStatusFile(ctx), EnforceUsesLibraries: d.enforceUsesLibs, ProvidesUsesLibrary: providesUsesLib, ClassLoaderContexts: d.classLoaderContexts, Loading Loading
dexpreopt/config.go +23 −11 Original line number Diff line number Diff line Loading @@ -84,6 +84,15 @@ type GlobalConfig struct { BootFlags string // extra flags to pass to dex2oat for the boot image Dex2oatImageXmx string // max heap size for dex2oat for the boot image Dex2oatImageXms string // initial heap size for dex2oat for the boot image // If true, downgrade the compiler filter of dexpreopt to "extract" when verify_uses_libraries // check fails, instead of failing the build. This will disable any AOT-compilation. // // The intended use case for this flag is to have a smoother migration path for the Java // modules that need to add <uses-library> information in their build files. The flag allows to // quickly silence build errors. This flag should be used with caution and only as a temporary // measure, as it masks real errors and affects performance. RelaxUsesLibraryCheck bool } // GlobalSoongConfig contains the global config that is generated from Soong, Loading Loading @@ -113,8 +122,9 @@ type ModuleConfig struct { ProfileIsTextListing bool ProfileBootListing android.OptionalPath EnforceUsesLibraries bool ProvidesUsesLibrary string // the name of the <uses-library> (usually the same as its module) EnforceUsesLibraries bool // turn on build-time verify_uses_libraries check EnforceUsesLibrariesStatusFile android.Path // a file with verify_uses_libraries errors (if any) ProvidesUsesLibrary string // library name (usually the same as module name) ClassLoaderContexts ClassLoaderContextMap Archs []android.ArchType Loading Loading @@ -262,6 +272,7 @@ func ParseModuleConfig(ctx android.PathContext, data []byte) (*ModuleConfig, err DexPath string ManifestPath string ProfileClassListing string EnforceUsesLibrariesStatusFile string ClassLoaderContexts jsonClassLoaderContextMap DexPreoptImages []string DexPreoptImageLocations []string Loading @@ -280,6 +291,7 @@ func ParseModuleConfig(ctx android.PathContext, data []byte) (*ModuleConfig, err config.ModuleConfig.DexPath = constructPath(ctx, config.DexPath) config.ModuleConfig.ManifestPath = constructPath(ctx, config.ManifestPath) config.ModuleConfig.ProfileClassListing = android.OptionalPathForPath(constructPath(ctx, config.ProfileClassListing)) config.ModuleConfig.EnforceUsesLibrariesStatusFile = constructPath(ctx, config.EnforceUsesLibrariesStatusFile) config.ModuleConfig.ClassLoaderContexts = fromJsonClassLoaderContext(ctx, config.ClassLoaderContexts) config.ModuleConfig.DexPreoptImages = constructPaths(ctx, config.DexPreoptImages) config.ModuleConfig.DexPreoptImageLocations = config.DexPreoptImageLocations Loading
dexpreopt/dexpreopt.go +21 −5 Original line number Diff line number Diff line Loading @@ -279,11 +279,12 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g // Generate command that saves host and target class loader context in shell variables. clc, paths := ComputeClassLoaderContext(module.ClassLoaderContexts) cmd := rule.Command(). Text(`eval "$(`).Tool(globalSoong.ConstructContext). rule.Command(). Text("if ! test -s ").Input(module.EnforceUsesLibrariesStatusFile). Text(` ; then eval "$(`).Tool(globalSoong.ConstructContext). Text(` --target-sdk-version ${target_sdk_version}`). Text(clc).Implicits(paths) cmd.Text(`)"`) Text(clc).Implicits(paths). Text(`)" ; fi`) } else { // Other libraries or APKs for which the exact <uses-library> list is unknown. Loading Loading @@ -366,8 +367,17 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g } else { compilerFilter = "quicken" } if module.EnforceUsesLibraries { // If the verify_uses_libraries check failed (in this case status file contains a // non-empty error message), then use "extract" compiler filter to avoid compiling any // code (it would be rejected on device because of a class loader context mismatch). cmd.Text("--compiler-filter=$(if test -s "). Input(module.EnforceUsesLibrariesStatusFile). Text(" ; then echo extract ; else echo " + compilerFilter + " ; fi)") } else { cmd.FlagWithArg("--compiler-filter=", compilerFilter) } } if generateDM { cmd.FlagWithArg("--copy-dex-files=", "false") Loading Loading @@ -542,6 +552,12 @@ func checkSystemServerOrder(ctx android.PathContext, jarIndex int) { } } // Returns path to a file containing the reult of verify_uses_libraries check (empty if the check // has succeeded, or an error message if it failed). func UsesLibrariesStatusFile(ctx android.ModuleContext) android.WritablePath { return android.PathForModuleOut(ctx, "enforce_uses_libraries.status") } func contains(l []string, s string) bool { for _, e := range l { if e == s { Loading
dexpreopt/dexpreopt_test.go +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ func testModuleConfig(ctx android.PathContext, name, partition string) *ModuleCo PreoptFlags: nil, ProfileClassListing: android.OptionalPath{}, ProfileIsTextListing: false, EnforceUsesLibrariesStatusFile: android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)), EnforceUsesLibraries: false, ClassLoaderContexts: nil, Archs: []android.ArchType{android.Arm}, Loading
java/app.go +9 −1 Original line number Diff line number Diff line Loading @@ -1260,13 +1260,19 @@ func (u *usesLibrary) freezeEnforceUsesLibraries() { // in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the manifest. func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path { outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml") statusFile := dexpreopt.UsesLibrariesStatusFile(ctx) rule := android.NewRuleBuilder(pctx, ctx) cmd := rule.Command().BuiltTool("manifest_check"). Flag("--enforce-uses-libraries"). Input(manifest). FlagWithOutput("--enforce-uses-libraries-status ", statusFile). FlagWithOutput("-o ", outputFile) if dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck { cmd.Flag("--enforce-uses-libraries-relax") } for _, lib := range u.usesLibraryProperties.Uses_libs { cmd.FlagWithArg("--uses-library ", lib) } Loading @@ -1284,6 +1290,7 @@ func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, man // in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the APK. func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk android.Path) android.Path { outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base()) statusFile := dexpreopt.UsesLibrariesStatusFile(ctx) rule := android.NewRuleBuilder(pctx, ctx) aapt := ctx.Config().HostToolPath(ctx, "aapt") Loading @@ -1291,7 +1298,8 @@ func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk andr Textf("aapt_binary=%s", aapt.String()).Implicit(aapt). Textf(`uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Uses_libs, " ")). Textf(`optional_uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Optional_uses_libs, " ")). Tool(android.PathForSource(ctx, "build/make/core/verify_uses_libraries.sh")).Input(apk) Textf(`relax_check="%b"`, dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck). Tool(android.PathForSource(ctx, "build/make/core/verify_uses_libraries.sh")).Input(apk).Output(statusFile) rule.Command().Text("cp -f").Input(apk).Output(outputFile) rule.Build("verify_uses_libraries", "verify <uses-library>") Loading
java/dexpreopt.go +5 −3 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ type dexpreopter struct { isPresignedPrebuilt bool manifestFile android.Path statusFile android.WritablePath enforceUsesLibs bool classLoaderContexts dexpreopt.ClassLoaderContextMap Loading Loading @@ -226,6 +227,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr ProfileIsTextListing: profileIsTextListing, ProfileBootListing: profileBootListing, EnforceUsesLibrariesStatusFile: dexpreopt.UsesLibrariesStatusFile(ctx), EnforceUsesLibraries: d.enforceUsesLibs, ProvidesUsesLibrary: providesUsesLib, ClassLoaderContexts: d.classLoaderContexts, Loading