Remove profilePathOnHost from bootImageConfig
The use of this field to return information from bootImageProfileRule
up the call stack to one of the users resulted in data races being
detected. This change simply returns the profile path back up the call
stack.
Bug: 245956352
Test: m nothing
go test -race ./sdk/... -run TestSnapshotWithBootclasspathFragment_ImageName -test.count 100
# Run the previous command without this change and sometimes it
# shows the data race around profilePathOnHost. With this change
# that data race is not reported. Although there is still another
# data race.
Change-Id: I03b09e514cc94f2a6c9d5117d3b2f130cc2e4f5b
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 62386e3..1374566 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -282,11 +282,6 @@
// Deprecated: Not initialized correctly, see struct comment.
profileLicenseMetadataFile android.OptionalPath
- // Path to the image profile file on host (or empty, if profile is not generated).
- //
- // Deprecated: Not initialized correctly, see struct comment.
- profilePathOnHost android.Path
-
// Target-dependent fields.
variants []*bootImageVariant
@@ -575,7 +570,7 @@
// boot image files.
//
// The paths are returned because they are needed elsewhere in Soong, e.g. for populating an APEX.
-func buildBootImageVariantsForAndroidOs(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath) bootImageFilesByArch {
+func buildBootImageVariantsForAndroidOs(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath) bootImageOutputs {
return buildBootImageForOsType(ctx, image, profile, android.Android)
}
@@ -590,12 +585,22 @@
buildBootImageForOsType(ctx, image, profile, ctx.Config().BuildOS)
}
+// bootImageOutputs encapsulates information about boot images that were created/obtained by
+// commonBootclasspathFragment.produceBootImageFiles.
+type bootImageOutputs struct {
+ // Map from arch to the paths to the boot image files created/obtained for that arch.
+ byArch bootImageFilesByArch
+
+ // The path to the profile file created/obtained for the boot image.
+ profile android.WritablePath
+}
+
// buildBootImageForOsType takes a bootImageConfig, a profile file and an android.OsType
// boot image files are required for and it creates rules to build the boot image
// files for all the required architectures for them.
//
// It returns a map from android.ArchType to the predefined paths of the boot image files.
-func buildBootImageForOsType(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath, requiredOsType android.OsType) bootImageFilesByArch {
+func buildBootImageForOsType(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath, requiredOsType android.OsType) bootImageOutputs {
filesByArch := bootImageFilesByArch{}
for _, variant := range image.variants {
if variant.target.Os == requiredOsType {
@@ -604,7 +609,10 @@
}
}
- return filesByArch
+ return bootImageOutputs{
+ filesByArch,
+ profile,
+ }
}
// buildBootImageZipInPredefinedLocation generates a zip file containing all the boot image files.
@@ -851,8 +859,6 @@
rule.Build("bootJarsProfile", "profile boot jars")
- image.profilePathOnHost = profile
-
return profile
}