Revert^4 "Package dexpreopt artifacts for libcore jars in the ART apex."
This reverts commit bf0e47648ab6cba10e10d07693bf0c813905396c.
Reason for revert: coverage build with EMMA_INSTRUMENT_FRAMEWORK=true
is fixed by inspecting the environment variable and not generating
boot image in case it is set.
Dexpreopt artifacts for the libcore part of the boot class path are
now packaged in the ART apex. The system image still contains
dexpreopt artifacts for the full set of boot class path libraries
(both libcore and framework); the libcore part will be removed and
boot image extension will be used in a follow-up CL.
Since this is specific to the ART apex and makes no sense for other
apexes, the implementation adds a boolean flag "is ART apex" rather
than a new apex module property.
Build rules for the new set of dexpreopt artifacts are created using
a new variant of the global boot image config. Previously we had two
variants: "default" (for the system image) and "apex" (for the
JIT-zygote experiment). This patch adds a third "art" variant.
Test: m
Test: m art/build/apex/runtests.sh
Bug: 144091989
Change-Id: I113c0d39222d6d697cb62cd09d5010607872fc2b
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 74ef667..a29665e 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -51,6 +51,7 @@
type bootImageConfig struct {
name string
+ stem string
modules []string
dexLocations []string
dexPaths android.WritablePaths
@@ -71,7 +72,7 @@
// In addition, each .art file has an associated .oat and .vdex file, and an
// unstripped .oat file
for i, m := range image.modules {
- name := image.name
+ name := image.stem
if i != 0 {
name += "-" + stemOf(m)
}
@@ -139,6 +140,12 @@
return false
}
+func skipDexpreoptArtBootJars(ctx android.BuilderContext) bool {
+ // with EMMA_INSTRUMENT_FRAMEWORK=true ART boot class path libraries have dependencies on framework,
+ // therefore dexpreopt ART libraries cannot be dexpreopted in isolation => no ART boot image
+ return ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK")
+}
+
type dexpreoptBootJars struct {
defaultBootImage *bootImage
otherImages []*bootImage
@@ -146,6 +153,14 @@
dexpreoptConfigForMake android.WritablePath
}
+// Accessor function for the apex package. Returns nil if dexpreopt is disabled.
+func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.Paths {
+ if skipDexpreoptBootJars(ctx) || skipDexpreoptArtBootJars(ctx) {
+ return nil
+ }
+ return artBootImageConfig(ctx).imagesDeps
+}
+
// dexpreoptBoot singleton rules
func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
if skipDexpreoptBootJars(ctx) {
@@ -169,7 +184,12 @@
// Always create the default boot image first, to get a unique profile rule for all images.
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
+ if !skipDexpreoptArtBootJars(ctx) {
+ // Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
+ buildBootImage(ctx, artBootImageConfig(ctx))
+ }
if global.GenerateApexImage {
+ // Create boot images for the JIT-zygote experiment.
d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
}
@@ -178,8 +198,6 @@
// buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage.
func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootImage {
- global := dexpreoptGlobalConfig(ctx)
-
image := newBootImage(ctx, config)
bootDexJars := make(android.Paths, len(image.modules))
@@ -223,12 +241,9 @@
bootFrameworkProfileRule(ctx, image, missingDeps)
var allFiles android.Paths
-
- if !global.DisablePreopt {
- for _, target := range image.targets {
- files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
- allFiles = append(allFiles, files.Paths()...)
- }
+ for _, target := range image.targets {
+ files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
+ allFiles = append(allFiles, files.Paths()...)
}
if image.zip != nil {
@@ -251,7 +266,7 @@
global := dexpreoptGlobalConfig(ctx)
symbolsDir := image.symbolsDir.Join(ctx, "system/framework", arch.String())
- symbolsFile := symbolsDir.Join(ctx, image.name+".oat")
+ symbolsFile := symbolsDir.Join(ctx, image.stem+".oat")
outputDir := image.dir.Join(ctx, "system/framework", arch.String())
outputPath := image.images[arch]
oatLocation := pathtools.ReplaceExtension(dexpreopt.PathToLocation(outputPath, arch), "oat")
@@ -381,8 +396,9 @@
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
return nil
}
- return ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
+ profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
tools := global.Tools
+ defaultProfile := "frameworks/base/config/boot-image-profile.txt"
rule := android.NewRuleBuilder()
rule.MissingDeps(missingDeps)
@@ -394,18 +410,13 @@
bootImageProfile = combinedBootImageProfile
} else if len(global.BootImageProfiles) == 1 {
bootImageProfile = global.BootImageProfiles[0]
+ } else if path := android.ExistentPathForSource(ctx, defaultProfile); path.Valid() {
+ bootImageProfile = path.Path()
} else {
- // If not set, use the default. Some branches like master-art-host don't have frameworks/base, so manually
- // handle the case that the default is missing. Those branches won't attempt to build the profile rule,
- // and if they do they'll get a missing deps error.
- defaultProfile := "frameworks/base/config/boot-image-profile.txt"
- path := android.ExistentPathForSource(ctx, defaultProfile)
- if path.Valid() {
- bootImageProfile = path.Path()
- } else {
- missingDeps = append(missingDeps, defaultProfile)
- bootImageProfile = android.PathForOutput(ctx, "missing")
- }
+ // No profile (not even a default one, which is the case on some branches
+ // like master-art-host that don't have frameworks/base).
+ // Return nil and continue without profile.
+ return nil
}
profile := image.dir.Join(ctx, "boot.prof")
@@ -425,7 +436,11 @@
image.profileInstalls = rule.Installs()
return profile
- }).(android.WritablePath)
+ })
+ if profile == nil {
+ return nil // wrap nil into a typed pointer with value nil
+ }
+ return profile.(android.WritablePath)
}
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")