Ensure primary boot image files are created before they are used

Previously, when building a framework boot image variant it added an
implicit dependency onto the first file in the primary boot image
variant to ensure that the primary boot image variant files that the
dex2oat command needs have been created. That works when generating
from source as in that case all the files for a boot image variant are
created by a single command. However, it does not work for prebuilts as
each prebuilt file will be copied into the required location by
separate copy commands.

This change adds all the files that the dex2oat command uses implicitly
when building an extension boot image as implicit dependencies.

Bug: 177892522
Test: m SOONG_CONFIG_art_module_source_build=false droid
      - the previous command only works in combination with a number of
        other build changes.
Merged-In: I183748fd17f8f3003890675b8c6bb9fcab331443
Change-Id: I183748fd17f8f3003890675b8c6bb9fcab331443
(cherry picked from commit bff50e2b80)
This commit is contained in:
Paul Duffin 2021-06-04 17:25:28 +01:00
parent bfeb714333
commit 8c666a3665
2 changed files with 25 additions and 5 deletions

View file

@ -276,13 +276,24 @@ type bootImageVariant struct {
dexLocationsDeps []string // for the dependency images and in this image
// Paths to image files.
imagePathOnHost android.OutputPath // first image file path on host
imagePathOnDevice string // first image file path on device
imagesDeps android.OutputPaths // all files
imagePathOnHost android.OutputPath // first image file path on host
imagePathOnDevice string // first image file path on device
// Only for extensions, paths to the primary boot images.
// All the files that constitute this image variant, i.e. .art, .oat and .vdex files.
imagesDeps android.OutputPaths
// The path to the primary image variant's imagePathOnHost field, where primary image variant
// means the image variant that this extends.
//
// This is only set for a variant of an image that extends another image.
primaryImages android.OutputPath
// The paths to the primary image variant's imagesDeps field, where primary image variant
// means the image variant that this extends.
//
// This is only set for a variant of an image that extends another image.
primaryImagesDeps android.Paths
// Rules which should be used in make to install the outputs.
installs android.RuleBuilderInstalls
vdexInstalls android.RuleBuilderInstalls
@ -588,7 +599,15 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p
cmd.
Flag("--runtime-arg").FlagWithInputList("-Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
Flag("--runtime-arg").FlagWithList("-Xbootclasspath-locations:", image.dexLocationsDeps, ":").
FlagWithArg("--boot-image=", dexpreopt.PathToLocation(artImage, arch)).Implicit(artImage)
// Add the path to the first file in the boot image with the arch specific directory removed,
// dex2oat will reconstruct the path to the actual file when it needs it. As the actual path
// to the file cannot be passed to the command make sure to add the actual path as an Implicit
// dependency to ensure that it is built before the command runs.
FlagWithArg("--boot-image=", dexpreopt.PathToLocation(artImage, arch)).Implicit(artImage).
// Similarly, the dex2oat tool will automatically find the paths to other files in the base
// boot image so make sure to add them as implicit dependencies to ensure that they are built
// before this command is run.
Implicits(image.primaryImagesDeps)
} else {
// It is a primary image, so it needs a base address.
cmd.FlagWithArg("--base=", ctx.Config().LibartImgDeviceBaseAddress())

View file

@ -125,6 +125,7 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
frameworkCfg.dexPathsDeps = append(artCfg.dexPathsDeps, frameworkCfg.dexPathsDeps...)
for i := range targets {
frameworkCfg.variants[i].primaryImages = artCfg.variants[i].imagePathOnHost
frameworkCfg.variants[i].primaryImagesDeps = artCfg.variants[i].imagesDeps.Paths()
frameworkCfg.variants[i].dexLocationsDeps = append(artCfg.variants[i].dexLocations, frameworkCfg.variants[i].dexLocationsDeps...)
}