Merge "Fix TestDroiddoc's reliance on absolute paths"
diff --git a/android/bazel.go b/android/bazel.go
index 9b06426..9a14e70 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -127,10 +127,57 @@
"system/core/libcutils": Bp2BuildDefaultTrueRecursively,
"system/logging/liblog": Bp2BuildDefaultTrueRecursively,
}
+
+ // Per-module denylist to always opt modules out.
+ bp2buildModuleDoNotConvert = map[string]bool{
+ "libBionicBenchmarksUtils": true,
+ "libbionic_spawn_benchmark": true,
+ "libc_jemalloc_wrapper": true,
+ "libc_bootstrap": true,
+ "libc_init_static": true,
+ "libc_init_dynamic": true,
+ "libc_tzcode": true,
+ "lib_dns": true,
+ "libc_freebsd": true,
+ "libc_freebsd_large_stack": true,
+ "libc_netbsd": true,
+ "libc_openbsd_ndk": true,
+ "libc_openbsd_large_stack": true,
+ "libc_openbsd": true,
+ "libc_gdtoa": true,
+ "libc_fortify": true,
+ "libc_bionic": true,
+ "libc_bionic_ndk": true,
+ "libc_bionic_systrace": true,
+ "libc_pthread": true,
+ "libc_syscalls": true,
+ "libc_aeabi": true,
+ "libc_ndk": true,
+ "libc_nopthread": true,
+ "libc_common": true,
+ "libc_static_dispatch": true,
+ "libc_dynamic_dispatch": true,
+ "libc_common_static": true,
+ "libc_common_shared": true,
+ "libc_unwind_static": true,
+ "libc_nomalloc": true,
+ "libasync_safe": true,
+ "libc_malloc_debug_backtrace": true,
+ "libsystemproperties": true,
+ "libdl_static": true,
+ "liblinker_main": true,
+ "liblinker_malloc": true,
+ "liblinker_debuggerd_stub": true,
+ "libbionic_tests_headers_posix": true,
+ }
)
// ConvertWithBp2build returns whether the given BazelModuleBase should be converted with bp2build.
func (b *BazelModuleBase) ConvertWithBp2build(ctx BazelConversionPathContext) bool {
+ if bp2buildModuleDoNotConvert[ctx.Module().Name()] {
+ return false
+ }
+
// Ensure that the module type of this module has a bp2build converter. This
// prevents mixed builds from using auto-converted modules just by matching
// the package dir; it also has to have a bp2build mutator as well.
diff --git a/cc/cc.go b/cc/cc.go
index cab7459..0c46b24 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1833,12 +1833,6 @@
if c.compiler != nil {
deps = c.compiler.compilerDeps(ctx, deps)
}
- // Add the PGO dependency (the clang_rt.profile runtime library), which
- // sometimes depends on symbols from libgcc, before libgcc gets added
- // in linkerDeps().
- if c.pgo != nil {
- deps = c.pgo.deps(ctx, deps)
- }
if c.linker != nil {
deps = c.linker.linkerDeps(ctx, deps)
}
diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go
index 59c0422..fce28c1 100644
--- a/cc/config/toolchain.go
+++ b/cc/config/toolchain.go
@@ -245,10 +245,6 @@
return LibclangRuntimeLibrary(t, "tsan")
}
-func ProfileRuntimeLibrary(t Toolchain) string {
- return LibclangRuntimeLibrary(t, "profile")
-}
-
func ScudoRuntimeLibrary(t Toolchain) string {
return LibclangRuntimeLibrary(t, "scudo")
}
diff --git a/cc/pgo.go b/cc/pgo.go
index ada694b..95c9c2e 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -22,7 +22,6 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
- "android/soong/cc/config"
)
var (
@@ -271,14 +270,6 @@
}
}
-func (pgo *pgo) deps(ctx BaseModuleContext, deps Deps) Deps {
- if pgo.Properties.ShouldProfileModule {
- runtimeLibrary := config.ProfileRuntimeLibrary(ctx.toolchain())
- deps.LateStaticLibs = append(deps.LateStaticLibs, runtimeLibrary)
- }
- return deps
-}
-
func (pgo *pgo) flags(ctx ModuleContext, flags Flags) Flags {
if ctx.Host() {
return flags
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 8873b4e..02f1120 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -33,6 +33,8 @@
OnlyPreoptBootImageAndSystemServer bool // only preopt jars in the boot image or system server
+ PreoptWithUpdatableBcp bool // If updatable boot jars are included in dexpreopt or not.
+
UseArtImage bool // use the art image (use other boot class path dex files without image)
HasSystemOther bool // store odex files that match PatternsOnSystemOther on the system_other partition
diff --git a/dexpreopt/testing.go b/dexpreopt/testing.go
index 4801482..c0ba5ca 100644
--- a/dexpreopt/testing.go
+++ b/dexpreopt/testing.go
@@ -117,3 +117,17 @@
dexpreoptConfig.BootJars = android.CreateTestConfiguredJarList(bootJars)
})
}
+
+// FixtureSetUpdatableBootJars sets the UpdatableBootJars property in the global config.
+func FixtureSetUpdatableBootJars(bootJars ...string) android.FixturePreparer {
+ return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) {
+ dexpreoptConfig.UpdatableBootJars = android.CreateTestConfiguredJarList(bootJars)
+ })
+}
+
+// FixtureSetPreoptWithUpdatableBcp sets the PreoptWithUpdatableBcp property in the global config.
+func FixtureSetPreoptWithUpdatableBcp(value bool) android.FixturePreparer {
+ return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) {
+ dexpreoptConfig.PreoptWithUpdatableBcp = value
+ })
+}
diff --git a/java/app_test.go b/java/app_test.go
index 2523533..825ad20 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -26,6 +26,7 @@
"android/soong/android"
"android/soong/cc"
+ "android/soong/dexpreopt"
"android/soong/genrule"
)
@@ -2422,6 +2423,66 @@
`#PCL[/system/framework/android.test.mock.jar] `)
}
+func TestDexpreoptBcp(t *testing.T) {
+ bp := `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java"],
+ api_packages: ["foo"],
+ sdk_version: "current",
+ }
+
+ java_sdk_library {
+ name: "bar",
+ srcs: ["a.java"],
+ api_packages: ["bar"],
+ permitted_packages: ["bar"],
+ sdk_version: "current",
+ }
+
+ android_app {
+ name: "app",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ }
+ `
+
+ testCases := []struct {
+ name string
+ with bool
+ expect string
+ }{
+ {
+ name: "with updatable bcp",
+ with: true,
+ expect: "/system/framework/foo.jar:/system/framework/bar.jar",
+ },
+ {
+ name: "without updatable bcp",
+ with: false,
+ expect: "/system/framework/foo.jar",
+ },
+ }
+
+ for _, test := range testCases {
+ t.Run(test.name, func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("runtime-library", "foo", "bar"),
+ dexpreopt.FixtureSetBootJars("platform:foo"),
+ dexpreopt.FixtureSetUpdatableBootJars("platform:bar"),
+ dexpreopt.FixtureSetPreoptWithUpdatableBcp(test.with),
+ ).RunTestWithBp(t, bp)
+
+ app := result.ModuleForTests("app", "android_common")
+ cmd := app.Rule("dexpreopt").RuleParams.Command
+ bcp := " -Xbootclasspath-locations:" + test.expect + " " // space at the end matters
+ android.AssertStringDoesContain(t, "dexpreopt app bcp", cmd, bcp)
+ })
+ }
+}
+
func TestCodelessApp(t *testing.T) {
testCases := []struct {
name string
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index a2961c2..b4cf012 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -160,14 +160,17 @@
globalSoong := dexpreopt.GetGlobalSoongConfig(ctx)
global := dexpreopt.GetGlobalConfig(ctx)
+
+ isSystemServerJar := inList(ctx.ModuleName(), global.SystemServerJars)
+
bootImage := defaultBootImageConfig(ctx)
- dexFiles := bootImage.dexPathsDeps.Paths()
- // The dex locations for all Android variants are identical.
- dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps
if global.UseArtImage {
bootImage = artBootImageConfig(ctx)
}
+ // System server jars are an exception: they are dexpreopted without updatable bootclasspath.
+ dexFiles, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp && !isSystemServerJar)
+
targets := ctx.MultiTargets()
if len(targets) == 0 {
// assume this is a java library, dexpreopt for all arches for now
@@ -176,7 +179,7 @@
targets = append(targets, target)
}
}
- if inList(ctx.ModuleName(), global.SystemServerJars) && !d.isSDKLibrary {
+ if isSystemServerJar && !d.isSDKLibrary {
// If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
targets = targets[:1]
}
@@ -237,7 +240,7 @@
DexPreoptImagesDeps: imagesDeps,
DexPreoptImageLocations: imageLocations,
- PreoptBootClassPathDexFiles: dexFiles,
+ PreoptBootClassPathDexFiles: dexFiles.Paths(),
PreoptBootClassPathDexLocations: dexLocations,
PreoptExtractedApk: false,
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 17499ee..7137f33 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -214,7 +214,7 @@
var artApexNames = []string{
"com.android.art",
"com.android.art.debug",
- "com.android.art,testing",
+ "com.android.art.testing",
"com.google.android.art",
"com.google.android.art.debug",
"com.google.android.art.testing",
@@ -439,6 +439,8 @@
// Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
+ copyUpdatableBootJars(ctx)
+
dumpOatRules(ctx, d.defaultBootImage)
}
@@ -630,6 +632,21 @@
return image
}
+// Generate commands that will copy updatable boot jars to predefined paths in the global config.
+func copyUpdatableBootJars(ctx android.SingletonContext) {
+ config := GetUpdatableBootConfig(ctx)
+ getBootJarFunc := func(module android.Module) (int, android.Path) {
+ index, jar, _ := getBootJar(ctx, config.modules, module, "configured in updatable boot jars ")
+ return index, jar
+ }
+ missingDeps := findAndCopyBootJars(ctx, config.modules, config.dexPaths, getBootJarFunc)
+ // Ignoring missing dependencies here. Ideally they should be added to the dexpreopt rule, but
+ // that is not possible as this rule is created after dexpreopt rules (it's in a singleton
+ // context, and they are in a module context). The true fix is to add dependencies from the
+ // dexpreopted modules on updatable boot jars and avoid this copying altogether.
+ _ = missingDeps
+}
+
// Generate boot image build rules for a specific target.
func buildBootImageVariant(ctx android.SingletonContext, image *bootImageVariant,
profile android.Path, missingDeps []string) android.WritablePaths {
@@ -997,8 +1014,11 @@
image := d.defaultBootImage
if image != nil {
ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
- ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPathsDeps.Strings(), " "))
- ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.getAnyAndroidVariant().dexLocationsDeps, " "))
+
+ global := dexpreopt.GetGlobalConfig(ctx)
+ dexPaths, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp)
+ ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(dexPaths.Strings(), " "))
+ ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(dexLocations, " "))
var imageNames []string
// TODO: the primary ART boot image should not be exposed to Make, as it is installed in a
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 282e936..64b2656 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -176,6 +176,57 @@
})
}
+// Updatable boot config allows to access build/install paths of updatable boot jars without going
+// through the usual trouble of registering dependencies on those modules and extracting build paths
+// from those dependencies.
+type updatableBootConfig struct {
+ // A list of updatable boot jars.
+ modules android.ConfiguredJarList
+
+ // A list of predefined build paths to updatable boot jars. They are configured very early,
+ // before the modules for these jars are processed and the actual paths are generated, and
+ // later on a singleton adds commands to copy actual jars to the predefined paths.
+ dexPaths android.WritablePaths
+
+ // A list of dex locations (a.k.a. on-device paths) to the boot jars.
+ dexLocations []string
+}
+
+var updatableBootConfigKey = android.NewOnceKey("updatableBootConfig")
+
+// Returns updatable boot config.
+func GetUpdatableBootConfig(ctx android.PathContext) updatableBootConfig {
+ return ctx.Config().Once(updatableBootConfigKey, func() interface{} {
+ updatableBootJars := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars
+
+ dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "updatable_bootjars")
+ dexPaths := updatableBootJars.BuildPaths(ctx, dir)
+
+ dexLocations := updatableBootJars.DevicePaths(ctx.Config(), android.Android)
+
+ return updatableBootConfig{updatableBootJars, dexPaths, dexLocations}
+ }).(updatableBootConfig)
+}
+
+// Returns a list of paths and a list of locations for the boot jars used in dexpreopt (to be
+// passed in -Xbootclasspath and -Xbootclasspath-locations arguments for dex2oat).
+func bcpForDexpreopt(ctx android.PathContext, withUpdatable bool) (android.WritablePaths, []string) {
+ // Non-updatable boot jars (they are used both in the boot image and in dexpreopt).
+ bootImage := defaultBootImageConfig(ctx)
+ dexPaths := bootImage.dexPathsDeps
+ // The dex locations for all Android variants are identical.
+ dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps
+
+ if withUpdatable {
+ // Updatable boot jars (they are used only in dexpreopt, but not in the boot image).
+ updBootConfig := GetUpdatableBootConfig(ctx)
+ dexPaths = append(dexPaths, updBootConfig.dexPaths...)
+ dexLocations = append(dexLocations, updBootConfig.dexLocations...)
+ }
+
+ return dexPaths, dexLocations
+}
+
var defaultBootclasspathKey = android.NewOnceKey("defaultBootclasspath")
var copyOf = android.CopyOf