Merge "Determine GC type based on BUILT_KERNEL_VERSION_FILE." into main
diff --git a/android/deapexer.go b/android/deapexer.go
index 2704b3e..61ae64e 100644
--- a/android/deapexer.go
+++ b/android/deapexer.go
@@ -83,6 +83,10 @@
// name of the java libraries exported from the apex
// e.g. core-libart
exportedModuleNames []string
+
+ // name of the java libraries exported from the apex that should be dexpreopt'd with the .prof
+ // file embedded in the apex
+ dexpreoptProfileGuidedExportedModuleNames []string
}
// ApexModuleName returns the name of the APEX module that provided the info.
@@ -121,6 +125,14 @@
}
}
+func (i *DeapexerInfo) GetDexpreoptProfileGuidedExportedModuleNames() []string {
+ return i.dexpreoptProfileGuidedExportedModuleNames
+}
+
+func (i *DeapexerInfo) AddDexpreoptProfileGuidedExportedModuleNames(names ...string) {
+ i.dexpreoptProfileGuidedExportedModuleNames = append(i.dexpreoptProfileGuidedExportedModuleNames, names...)
+}
+
type deapexerTagStruct struct {
blueprint.BaseDependencyTag
}
@@ -143,6 +155,9 @@
// the path to the extracted file will be stored in the DeapexerInfo using the APEX relative file
// path as the key, The path can then be retrieved using the PrebuiltExportPath(key) method.
RequiredFilesFromPrebuiltApex(ctx BaseModuleContext) []string
+
+ // Returns true if a transitive dependency of an apex should use a .prof file to guide dexpreopt
+ UseProfileGuidedDexpreopt() bool
}
// Marker interface that identifies dependencies on modules that may require files from a prebuilt
diff --git a/android/defaults_test.go b/android/defaults_test.go
index a7542ab..0ad0fb8 100644
--- a/android/defaults_test.go
+++ b/android/defaults_test.go
@@ -16,10 +16,13 @@
import (
"testing"
+
+ "github.com/google/blueprint"
)
type defaultsTestProperties struct {
- Foo []string
+ Foo []string
+ Path_prop []string `android:"path"`
}
type defaultsTestModule struct {
@@ -130,3 +133,40 @@
// TODO: missing transitive defaults is currently not handled
_ = missingTransitiveDefaults
}
+
+func TestDefaultsPathProperties(t *testing.T) {
+ bp := `
+ defaults {
+ name: "defaults",
+ path_prop: [":gen"],
+ }
+
+ test {
+ name: "foo",
+ defaults: ["defaults"],
+ }
+
+ test {
+ name: "gen",
+ }
+ `
+
+ result := GroupFixturePreparers(
+ prepareForDefaultsTest,
+ FixtureWithRootAndroidBp(bp),
+ ).RunTest(t)
+
+ collectDeps := func(m Module) []string {
+ var deps []string
+ result.VisitDirectDeps(m, func(dep blueprint.Module) {
+ deps = append(deps, result.ModuleName(dep))
+ })
+ return deps
+ }
+
+ foo := result.Module("foo", "")
+ defaults := result.Module("defaults", "")
+
+ AssertStringListContains(t, "foo should depend on gen", collectDeps(foo), "gen")
+ AssertStringListDoesNotContain(t, "defaults should not depend on gen", collectDeps(defaults), "gen")
+}
diff --git a/android/path_properties.go b/android/path_properties.go
index fdc4d91..bbfaa8c 100644
--- a/android/path_properties.go
+++ b/android/path_properties.go
@@ -33,6 +33,11 @@
// The pathDepsMutator automatically adds dependencies on any module that is listed with the
// ":module" module reference syntax in a property that is tagged with `android:"path"`.
func pathDepsMutator(ctx BottomUpMutatorContext) {
+ if _, ok := ctx.Module().(DefaultsModule); ok {
+ // Defaults modules shouldn't have dependencies added for path properties, they have already been
+ // squashed into the real modules.
+ return
+ }
props := ctx.Module().base().GetProperties()
addPathDepsForProps(ctx, props)
}
diff --git a/android/util.go b/android/util.go
index 51313ce..363b31c 100644
--- a/android/util.go
+++ b/android/util.go
@@ -15,6 +15,7 @@
package android
import (
+ "cmp"
"fmt"
"path/filepath"
"reflect"
@@ -106,15 +107,8 @@
return SortedKeys(m)
}
-type Ordered interface {
- ~string |
- ~float32 | ~float64 |
- ~int | ~int8 | ~int16 | ~int32 | ~int64 |
- ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
-}
-
// SortedKeys returns the keys of the given map in the ascending order.
-func SortedKeys[T Ordered, V any](m map[T]V) []T {
+func SortedKeys[T cmp.Ordered, V any](m map[T]V) []T {
if len(m) == 0 {
return nil
}
diff --git a/android/util_test.go b/android/util_test.go
index 699135b..8e73d83 100644
--- a/android/util_test.go
+++ b/android/util_test.go
@@ -15,6 +15,7 @@
package android
import (
+ "cmp"
"fmt"
"reflect"
"strconv"
@@ -650,7 +651,7 @@
}
}
-func testSortedKeysHelper[K Ordered, V any](t *testing.T, name string, input map[K]V, expected []K) {
+func testSortedKeysHelper[K cmp.Ordered, V any](t *testing.T, name string, input map[K]V, expected []K) {
t.Helper()
t.Run(name, func(t *testing.T) {
actual := SortedKeys(input)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 7e67c0f..d3959ec 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -1455,6 +1455,7 @@
name: "libc",
no_libcrt: true,
nocrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
stubs: { versions: ["1"] },
@@ -1469,6 +1470,7 @@
name: "libclang_rt.hwasan",
no_libcrt: true,
nocrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
srcs: [""],
@@ -1511,6 +1513,7 @@
name: "libc",
no_libcrt: true,
nocrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
stubs: { versions: ["1"] },
@@ -1521,6 +1524,7 @@
name: "libclang_rt.hwasan",
no_libcrt: true,
nocrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
srcs: [""],
@@ -3768,13 +3772,6 @@
"lib64/libvndk.so",
"lib64/libvndksp.so"),
},
- {
- vndkVersion: "",
- expectedFiles: append(commonFiles,
- // Legacy VNDK APEX contains only VNDK-SP files (of core variant)
- "lib/libvndksp.so",
- "lib64/libvndksp.so"),
- },
}
for _, tc := range testCases {
t.Run("VNDK.current with DeviceVndkVersion="+tc.vndkVersion, func(t *testing.T) {
diff --git a/apex/deapexer.go b/apex/deapexer.go
index 5ff622c..a673108 100644
--- a/apex/deapexer.go
+++ b/apex/deapexer.go
@@ -53,6 +53,10 @@
// all architectures, e.g. java.
CommonModules []string
+ // List of modules that use an embedded .prof to guide optimization of the equivalent dexpreopt artifact
+ // This is a subset of CommonModules
+ DexpreoptProfileGuidedModules []string
+
// List of files exported from the .apex file by this module
//
// Each entry is a path from the apex root, e.g. javalib/core-libart.jar.
@@ -128,6 +132,7 @@
if len(exports) > 0 {
// Make the information available for other modules.
di := android.NewDeapexerInfo(apexModuleName(ctx.ModuleName()), exports, p.properties.CommonModules)
+ di.AddDexpreoptProfileGuidedExportedModuleNames(p.properties.DexpreoptProfileGuidedModules...)
android.SetProvider(ctx, android.DeapexerProvider, di)
// Create a sorted list of the files that this exports.
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 551942d..399d9b9 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -629,6 +629,7 @@
// Compute the deapexer properties from the transitive dependencies of this module.
commonModules := []string{}
+ dexpreoptProfileGuidedModules := []string{}
exportedFiles := []string{}
ctx.WalkDeps(func(child, parent android.Module) bool {
tag := ctx.OtherModuleDependencyTag(child)
@@ -642,9 +643,14 @@
if _, ok := tag.(android.RequiresFilesFromPrebuiltApexTag); ok {
commonModules = append(commonModules, name)
- requiredFiles := child.(android.RequiredFilesFromPrebuiltApex).RequiredFilesFromPrebuiltApex(ctx)
+ extract := child.(android.RequiredFilesFromPrebuiltApex)
+ requiredFiles := extract.RequiredFilesFromPrebuiltApex(ctx)
exportedFiles = append(exportedFiles, requiredFiles...)
+ if extract.UseProfileGuidedDexpreopt() {
+ dexpreoptProfileGuidedModules = append(dexpreoptProfileGuidedModules, name)
+ }
+
// Visit the dependencies of this module just in case they also require files from the
// prebuilt apex.
return true
@@ -657,7 +663,8 @@
deapexerProperties := &DeapexerProperties{
// Remove any duplicates from the common modules lists as a module may be included via a direct
// dependency as well as transitive ones.
- CommonModules: android.SortedUniqueStrings(commonModules),
+ CommonModules: android.SortedUniqueStrings(commonModules),
+ DexpreoptProfileGuidedModules: android.SortedUniqueStrings(dexpreoptProfileGuidedModules),
}
// Populate the exported files property in a fixed order.
diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go
index 6b2c397..f6c53b2 100644
--- a/apex/systemserver_classpath_fragment_test.go
+++ b/apex/systemserver_classpath_fragment_test.go
@@ -221,8 +221,6 @@
}
func TestPrebuiltSystemserverclasspathFragmentContents(t *testing.T) {
- // TODO(spandandas): Fix the rules for profile guided dexpreopt of deapexed prebuilt jars
- t.Skip()
result := android.GroupFixturePreparers(
prepareForTestWithSystemserverclasspathFragment,
prepareForTestWithMyapex,
@@ -294,8 +292,8 @@
"javalib/bar.jar.prof",
})
- assertProfileGuided(t, ctx, "foo", "android_common_myapex", false)
- assertProfileGuided(t, ctx, "bar", "android_common_myapex", true)
+ assertProfileGuidedPrebuilt(t, ctx, "myapex", "foo", false)
+ assertProfileGuidedPrebuilt(t, ctx, "myapex", "bar", true)
}
func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) {
@@ -381,8 +379,6 @@
}
func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) {
- // TODO(spandandas): Fix the rules for profile guided dexpreopt of deapexed prebuilt jars
- t.Skip()
result := android.GroupFixturePreparers(
prepareForTestWithSystemserverclasspathFragment,
prepareForTestWithMyapex,
@@ -447,8 +443,8 @@
"javalib/bar.jar.prof",
})
- assertProfileGuided(t, ctx, "foo", "android_common_myapex", false)
- assertProfileGuided(t, ctx, "bar", "android_common_myapex", true)
+ assertProfileGuidedPrebuilt(t, ctx, "myapex", "foo", false)
+ assertProfileGuidedPrebuilt(t, ctx, "myapex", "bar", true)
}
func assertProfileGuided(t *testing.T, ctx *android.TestContext, moduleName string, variant string, expected bool) {
@@ -458,3 +454,11 @@
t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual)
}
}
+
+func assertProfileGuidedPrebuilt(t *testing.T, ctx *android.TestContext, apexName string, moduleName string, expected bool) {
+ dexpreopt := ctx.ModuleForTests(apexName, "android_common_"+apexName).Rule("dexpreopt." + moduleName)
+ actual := strings.Contains(dexpreopt.RuleParams.Command, "--profile-file=")
+ if expected != actual {
+ t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual)
+ }
+}
diff --git a/apex/vndk_test.go b/apex/vndk_test.go
index e2aee96..894aece 100644
--- a/apex/vndk_test.go
+++ b/apex/vndk_test.go
@@ -8,66 +8,6 @@
"android/soong/android"
)
-func TestVndkApexForVndkLite(t *testing.T) {
- ctx := testApex(t, `
- apex_vndk {
- name: "com.android.vndk.current",
- key: "com.android.vndk.current.key",
- updatable: false,
- }
-
- apex_key {
- name: "com.android.vndk.current.key",
- public_key: "testkey.avbpubkey",
- private_key: "testkey.pem",
- }
-
- cc_library {
- name: "libvndk",
- srcs: ["mylib.cpp"],
- vendor_available: true,
- product_available: true,
- vndk: {
- enabled: true,
- },
- system_shared_libs: [],
- stl: "none",
- apex_available: [ "com.android.vndk.current" ],
- }
-
- cc_library {
- name: "libvndksp",
- srcs: ["mylib.cpp"],
- vendor_available: true,
- product_available: true,
- vndk: {
- enabled: true,
- support_system_process: true,
- },
- system_shared_libs: [],
- stl: "none",
- apex_available: [ "com.android.vndk.current" ],
- }
- `+vndkLibrariesTxtFiles("current"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.DeviceVndkVersion = proptools.StringPtr("")
- variables.KeepVndk = proptools.BoolPtr(true)
- }),
- )
- // VNDK-Lite contains only core variants of VNDK-Sp libraries
- ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", []string{
- "lib/libvndksp.so",
- "lib/libc++.so",
- "lib64/libvndksp.so",
- "lib64/libc++.so",
- "etc/llndk.libraries.29.txt",
- "etc/vndkcore.libraries.29.txt",
- "etc/vndksp.libraries.29.txt",
- "etc/vndkprivate.libraries.29.txt",
- "etc/vndkproduct.libraries.29.txt",
- })
-}
-
func TestVndkApexUsesVendorVariant(t *testing.T) {
bp := `
apex_vndk {
diff --git a/cc/androidmk.go b/cc/androidmk.go
index fe542b0..20673e8 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -83,8 +83,9 @@
// causing multiple ART APEXes (com.android.art and com.android.art.debug)
// to be installed. And this is breaking some older devices (like marlin)
// where system.img is small.
- Required: c.Properties.AndroidMkRuntimeLibs,
- Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
+ Required: c.Properties.AndroidMkRuntimeLibs,
+ OverrideName: c.BaseModuleName(),
+ Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
@@ -106,7 +107,6 @@
}
entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
if c.InVendorOrProduct() {
- entries.SetBool("LOCAL_USE_VNDK", true)
if c.IsVndk() && !c.static() {
entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())
// VNDK libraries available to vendor are not installed because
@@ -116,6 +116,11 @@
}
}
}
+ if c.InVendor() {
+ entries.SetBool("LOCAL_IN_VENDOR", true)
+ } else if c.InProduct() {
+ entries.SetBool("LOCAL_IN_PRODUCT", true)
+ }
if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
// Make the SDK variant uninstallable so that there are not two rules to install
// to the same location.
diff --git a/cc/cc.go b/cc/cc.go
index 4a8baa6..449d38f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -73,8 +73,7 @@
ctx.TopDown("afdo_deps", afdoDepsMutator)
ctx.BottomUp("afdo", afdoMutator).Parallel()
- ctx.TopDown("orderfile_deps", orderfileDepsMutator)
- ctx.BottomUp("orderfile", orderfileMutator).Parallel()
+ ctx.Transition("orderfile", &orderfileTransitionMutator{})
ctx.Transition("lto", <oTransitionMutator{})
@@ -1755,7 +1754,7 @@
}
func (ctx *moduleContextImpl) baseModuleName() string {
- return ctx.mod.ModuleBase.BaseModuleName()
+ return ctx.mod.BaseModuleName()
}
func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
@@ -4184,6 +4183,18 @@
return ""
}
+type sourceModuleName interface {
+ sourceModuleName() string
+}
+
+func (c *Module) BaseModuleName() string {
+ if smn, ok := c.linker.(sourceModuleName); ok && smn.sourceModuleName() != "" {
+ // if the prebuilt module sets a source_module_name in Android.bp, use that
+ return smn.sourceModuleName()
+ }
+ return c.ModuleBase.BaseModuleName()
+}
+
var Bool = proptools.Bool
var BoolDefault = proptools.BoolDefault
var BoolPtr = proptools.BoolPtr
diff --git a/cc/config/bionic.go b/cc/config/bionic.go
index a1e3851..ed724f5 100644
--- a/cc/config/bionic.go
+++ b/cc/config/bionic.go
@@ -24,6 +24,7 @@
bionicCrtBeginStaticBinary, bionicCrtEndStaticBinary = []string{"crtbegin_static"}, []string{"crtend_android"}
bionicCrtBeginSharedBinary, bionicCrtEndSharedBinary = []string{"crtbegin_dynamic"}, []string{"crtend_android"}
bionicCrtBeginSharedLibrary, bionicCrtEndSharedLibrary = []string{"crtbegin_so"}, []string{"crtend_so"}
+ bionicCrtPadSegmentSharedLibrary = []string{"crt_pad_segment"}
)
func (toolchainBionic) Bionic() bool { return true }
@@ -36,9 +37,10 @@
func (toolchainBionic) AvailableLibraries() []string { return nil }
-func (toolchainBionic) CrtBeginStaticBinary() []string { return bionicCrtBeginStaticBinary }
-func (toolchainBionic) CrtBeginSharedBinary() []string { return bionicCrtBeginSharedBinary }
-func (toolchainBionic) CrtBeginSharedLibrary() []string { return bionicCrtBeginSharedLibrary }
-func (toolchainBionic) CrtEndStaticBinary() []string { return bionicCrtEndStaticBinary }
-func (toolchainBionic) CrtEndSharedBinary() []string { return bionicCrtEndSharedBinary }
-func (toolchainBionic) CrtEndSharedLibrary() []string { return bionicCrtEndSharedLibrary }
+func (toolchainBionic) CrtBeginStaticBinary() []string { return bionicCrtBeginStaticBinary }
+func (toolchainBionic) CrtBeginSharedBinary() []string { return bionicCrtBeginSharedBinary }
+func (toolchainBionic) CrtBeginSharedLibrary() []string { return bionicCrtBeginSharedLibrary }
+func (toolchainBionic) CrtEndStaticBinary() []string { return bionicCrtEndStaticBinary }
+func (toolchainBionic) CrtEndSharedBinary() []string { return bionicCrtEndSharedBinary }
+func (toolchainBionic) CrtEndSharedLibrary() []string { return bionicCrtEndSharedLibrary }
+func (toolchainBionic) CrtPadSegmentSharedLibrary() []string { return bionicCrtPadSegmentSharedLibrary }
diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go
index 62f75d1..71e98fe 100644
--- a/cc/config/toolchain.go
+++ b/cc/config/toolchain.go
@@ -100,6 +100,7 @@
CrtEndStaticBinary() []string
CrtEndSharedBinary() []string
CrtEndSharedLibrary() []string
+ CrtPadSegmentSharedLibrary() []string
// DefaultSharedLibraries returns the list of shared libraries that will be added to all
// targets unless they explicitly specify system_shared_libs.
@@ -155,12 +156,13 @@
type toolchainNoCrt struct{}
-func (toolchainNoCrt) CrtBeginStaticBinary() []string { return nil }
-func (toolchainNoCrt) CrtBeginSharedBinary() []string { return nil }
-func (toolchainNoCrt) CrtBeginSharedLibrary() []string { return nil }
-func (toolchainNoCrt) CrtEndStaticBinary() []string { return nil }
-func (toolchainNoCrt) CrtEndSharedBinary() []string { return nil }
-func (toolchainNoCrt) CrtEndSharedLibrary() []string { return nil }
+func (toolchainNoCrt) CrtBeginStaticBinary() []string { return nil }
+func (toolchainNoCrt) CrtBeginSharedBinary() []string { return nil }
+func (toolchainNoCrt) CrtBeginSharedLibrary() []string { return nil }
+func (toolchainNoCrt) CrtEndStaticBinary() []string { return nil }
+func (toolchainNoCrt) CrtEndSharedBinary() []string { return nil }
+func (toolchainNoCrt) CrtEndSharedLibrary() []string { return nil }
+func (toolchainNoCrt) CrtPadSegmentSharedLibrary() []string { return nil }
func (toolchainBase) DefaultSharedLibraries() []string {
return nil
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index f95da0b..f497bf9 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -328,12 +328,13 @@
func (toolchainMusl) Musl() bool { return true }
-func (toolchainMusl) CrtBeginStaticBinary() []string { return muslCrtBeginStaticBinary }
-func (toolchainMusl) CrtBeginSharedBinary() []string { return muslCrtBeginSharedBinary }
-func (toolchainMusl) CrtBeginSharedLibrary() []string { return muslCrtBeginSharedLibrary }
-func (toolchainMusl) CrtEndStaticBinary() []string { return muslCrtEndStaticBinary }
-func (toolchainMusl) CrtEndSharedBinary() []string { return muslCrtEndSharedBinary }
-func (toolchainMusl) CrtEndSharedLibrary() []string { return muslCrtEndSharedLibrary }
+func (toolchainMusl) CrtBeginStaticBinary() []string { return muslCrtBeginStaticBinary }
+func (toolchainMusl) CrtBeginSharedBinary() []string { return muslCrtBeginSharedBinary }
+func (toolchainMusl) CrtBeginSharedLibrary() []string { return muslCrtBeginSharedLibrary }
+func (toolchainMusl) CrtEndStaticBinary() []string { return muslCrtEndStaticBinary }
+func (toolchainMusl) CrtEndSharedBinary() []string { return muslCrtEndSharedBinary }
+func (toolchainMusl) CrtEndSharedLibrary() []string { return muslCrtEndSharedLibrary }
+func (toolchainMusl) CrtPadSegmentSharedLibrary() []string { return nil }
func (toolchainMusl) DefaultSharedLibraries() []string { return MuslDefaultSharedLibraries }
diff --git a/cc/library.go b/cc/library.go
index ff30d40..d091261 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -974,6 +974,10 @@
if library.baseLinker.Properties.crt() {
deps.CrtBegin = append(deps.CrtBegin, ctx.toolchain().CrtBeginSharedLibrary()...)
deps.CrtEnd = append(deps.CrtEnd, ctx.toolchain().CrtEndSharedLibrary()...)
+
+ }
+ if library.baseLinker.Properties.crtPadSegment() {
+ deps.CrtEnd = append(deps.CrtEnd, ctx.toolchain().CrtPadSegmentSharedLibrary()...)
}
deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.SharedProperties.Shared.Whole_static_libs...)
deps.StaticLibs = append(deps.StaticLibs, library.SharedProperties.Shared.Static_libs...)
@@ -1350,10 +1354,12 @@
fileName+".lsdump")
}
-func getRefAbiDumpDir(isNdk bool) string {
+func getRefAbiDumpDir(isNdk, isLlndk bool) string {
var dirName string
if isNdk {
dirName = "ndk"
+ } else if isLlndk {
+ dirName = "vndk"
} else {
dirName = "platform"
}
@@ -1476,7 +1482,7 @@
addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String())
- dumpDir := getRefAbiDumpDir(isNdk)
+ dumpDir := getRefAbiDumpDir(isNdk, isLlndk)
binderBitness := ctx.DeviceConfig().BinderBitness()
// Check against the previous version.
prevVersionInt := prevRefAbiDumpVersion(ctx, dumpDir)
diff --git a/cc/linker.go b/cc/linker.go
index 85c128e..2c50db2 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -91,6 +91,10 @@
// compiling crt or libc.
Nocrt *bool `android:"arch_variant"`
+ // don't link in crt_pad_segment. This flag is currently only used internal to
+ // soong for testing and for vndk prebuilt shared libraries.
+ No_crt_pad_segment *bool `android:"arch_variant"`
+
// deprecated and ignored because lld makes it unnecessary. See b/189475744.
Group_static_libs *bool `android:"arch_variant"`
@@ -253,6 +257,10 @@
return blp.No_libcrt == nil || !*blp.No_libcrt
}
+func (blp *BaseLinkerProperties) crtPadSegment() bool {
+ return blp.No_crt_pad_segment == nil || !*blp.No_crt_pad_segment
+}
+
func NewBaseLinker(sanitize *sanitize) *baseLinker {
return &baseLinker{sanitize: sanitize}
}
diff --git a/cc/orderfile.go b/cc/orderfile.go
index 9192e81..38b8905 100644
--- a/cc/orderfile.go
+++ b/cc/orderfile.go
@@ -20,6 +20,8 @@
import (
"fmt"
+ "github.com/google/blueprint"
+
"android/soong/android"
)
@@ -190,66 +192,61 @@
return flags
}
-// Propagate profile orderfile flags down from binaries and shared libraries
-// We do not allow propagation for load flags because the orderfile is specific
-// to the module (binary / shared library)
-func orderfileDepsMutator(mctx android.TopDownMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok {
- if !m.orderfile.orderfileLinkEnabled() {
- return
- }
- mctx.WalkDeps(func(dep android.
- Module, parent android.Module) bool {
- tag := mctx.OtherModuleDependencyTag(dep)
- libTag, isLibTag := tag.(libraryDependencyTag)
-
- // Do not recurse down non-static dependencies
- if isLibTag {
- if !libTag.static() {
- return false
- }
- } else {
- if tag != objDepTag && tag != reuseObjTag {
- return false
- }
- }
-
- if dep, ok := dep.(*Module); ok {
- if m.orderfile.Properties.OrderfileInstrLink {
- dep.orderfile.Properties.OrderfileInstrLink = true
- }
- }
-
- return true
- })
+func orderfilePropagateViaDepTag(tag blueprint.DependencyTag) bool {
+ libTag, isLibTag := tag.(libraryDependencyTag)
+ // Do not recurse down non-static dependencies
+ if isLibTag {
+ return libTag.static()
+ } else {
+ return tag == objDepTag || tag == reuseObjTag || tag == staticVariantTag
}
}
-// Create orderfile variants for modules that need them
-func orderfileMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok && m.orderfile != nil {
- if !m.static() && m.orderfile.orderfileEnabled() {
- mctx.SetDependencyVariation("orderfile")
- return
+// orderfileTransitionMutator creates orderfile variants of cc modules.
+type orderfileTransitionMutator struct{}
+
+const ORDERFILE_VARIATION = "orderfile"
+
+func (o *orderfileTransitionMutator) Split(ctx android.BaseModuleContext) []string {
+ return []string{""}
+}
+
+func (o *orderfileTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.orderfile != nil {
+ if !orderfilePropagateViaDepTag(ctx.DepTag()) {
+ return ""
}
- variationNames := []string{""}
- if m.orderfile.Properties.OrderfileInstrLink {
- variationNames = append(variationNames, "orderfile")
+ if sourceVariation != "" {
+ return sourceVariation
}
- if len(variationNames) > 1 {
- modules := mctx.CreateVariations(variationNames...)
- for i, name := range variationNames {
- if name == "" {
- continue
- }
- variation := modules[i].(*Module)
- variation.Properties.PreventInstall = true
- variation.Properties.HideFromMake = true
- variation.orderfile.Properties.ShouldProfileModule = true
- variation.orderfile.Properties.OrderfileLoad = false
- }
+ // Propagate profile orderfile flags down from binaries and shared libraries
+ if m.orderfile.orderfileLinkEnabled() {
+ return ORDERFILE_VARIATION
}
}
+ return ""
+}
+
+func (o *orderfileTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.orderfile != nil {
+ return incomingVariation
+ }
+ return ""
+}
+
+func (o *orderfileTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
+ if variation == "" {
+ return
+ }
+
+ if m, ok := ctx.Module().(*Module); ok && m.orderfile != nil {
+ m.Properties.PreventInstall = true
+ m.Properties.HideFromMake = true
+ m.orderfile.Properties.ShouldProfileModule = true
+ // We do not allow propagation for load flags because the orderfile is specific
+ // to the module (binary / shared library)
+ m.orderfile.Properties.OrderfileLoad = false
+ }
}
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index e721c53..8f4b7df 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -17,6 +17,8 @@
import (
"path/filepath"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
)
@@ -36,9 +38,15 @@
type prebuiltLinkerInterface interface {
Name(string) string
prebuilt() *android.Prebuilt
+ sourceModuleName() string
}
type prebuiltLinkerProperties struct {
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
+
// a prebuilt library or binary. Can reference a genrule module that generates an executable file.
Srcs []string `android:"path,arch_variant"`
@@ -337,7 +345,11 @@
}
type prebuiltObjectProperties struct {
- Srcs []string `android:"path,arch_variant"`
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
+ Srcs []string `android:"path,arch_variant"`
}
type prebuiltObjectLinker struct {
@@ -351,6 +363,10 @@
return &p.Prebuilt
}
+func (p *prebuiltObjectLinker) sourceModuleName() string {
+ return proptools.String(p.properties.Source_module_name)
+}
+
var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil)
func (p *prebuiltObjectLinker) link(ctx ModuleContext,
@@ -520,3 +536,7 @@
}
return sanitized.None.Srcs
}
+
+func (p *prebuiltLinker) sourceModuleName() string {
+ return proptools.String(p.properties.Source_module_name)
+}
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 8b4174b..95fb7ed 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -15,6 +15,7 @@
package cc
import (
+ "fmt"
"runtime"
"testing"
@@ -509,3 +510,100 @@
}`
testCcError(t, `Android.bp:4:6: module "bintest" variant "android_arm64_armv8-a": srcs: multiple prebuilt source files`, bp)
}
+
+func TestMultiplePrebuilts(t *testing.T) {
+ bp := `
+ // an rdep
+ cc_library {
+ name: "libfoo",
+ shared_libs: ["libbar"],
+ }
+
+ // multiple variations of dep
+ // source
+ cc_library {
+ name: "libbar",
+ }
+ // prebuilt "v1"
+ cc_prebuilt_library_shared {
+ name: "libbar",
+ srcs: ["libbar.so"],
+ }
+ // prebuilt "v2"
+ cc_prebuilt_library_shared {
+ name: "libbar.v2",
+ stem: "libbar",
+ source_module_name: "libbar",
+ srcs: ["libbar.so"],
+ }
+
+ // selectors
+ apex_contributions {
+ name: "myapex_contributions",
+ contents: ["%v"],
+ }
+ all_apex_contributions {name: "all_apex_contributions"}
+ `
+ hasDep := func(ctx *android.TestContext, m android.Module, wantDep android.Module) bool {
+ t.Helper()
+ var found bool
+ ctx.VisitDirectDeps(m, func(dep blueprint.Module) {
+ if dep == wantDep {
+ found = true
+ }
+ })
+ return found
+ }
+
+ testCases := []struct {
+ desc string
+ selectedDependencyName string
+ expectedDependencyName string
+ }{
+ {
+ desc: "Source library is selected using apex_contributions",
+ selectedDependencyName: "libbar",
+ expectedDependencyName: "libbar",
+ },
+ {
+ desc: "Prebuilt library v1 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_libbar",
+ expectedDependencyName: "prebuilt_libbar",
+ },
+ {
+ desc: "Prebuilt library v2 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_libbar.v2",
+ expectedDependencyName: "prebuilt_libbar.v2",
+ },
+ }
+
+ for _, tc := range testCases {
+ preparer := android.GroupFixturePreparers(
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ android.RegisterApexContributionsBuildComponents(ctx)
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
+ }
+ }),
+ )
+ ctx := testPrebuilt(t, fmt.Sprintf(bp, tc.selectedDependencyName), map[string][]byte{
+ "libbar.so": nil,
+ "crtx.o": nil,
+ }, preparer)
+ libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
+ expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module()
+ android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", libfoo.Name(), tc.expectedDependencyName), true, hasDep(ctx, libfoo, expectedDependency))
+
+ // check installation rules
+ // the selected soong module should be exported to make
+ libbar := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module()
+ android.AssertBoolEquals(t, fmt.Sprintf("dependency %s should be exported to make\n", expectedDependency), true, !libbar.IsHideFromMake())
+
+ // check LOCAL_MODULE of the selected module name
+ // the prebuilt should have the same LOCAL_MODULE when exported to make
+ entries := android.AndroidMkEntriesForTest(t, ctx, libbar)[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_MODULE", "libbar", entries.EntryMap["LOCAL_MODULE"][0])
+ }
+}
diff --git a/cc/testing.go b/cc/testing.go
index bac41e7..9c2900c 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -77,6 +77,7 @@
no_libcrt: true,
sdk_version: "minimum",
nocrt: true,
+ no_crt_pad_segment: true,
system_shared_libs: [],
stl: "none",
check_elf_files: false,
@@ -385,6 +386,11 @@
}
cc_object {
+ name: "crt_pad_segment",
+ defaults: ["crt_defaults"],
+ }
+
+ cc_object {
name: "crtbrand",
defaults: ["crt_defaults"],
srcs: ["crtbrand.c"],
diff --git a/cc/vendor_snapshot_test.go b/cc/vendor_snapshot_test.go
index 890a533..0a55431 100644
--- a/cc/vendor_snapshot_test.go
+++ b/cc/vendor_snapshot_test.go
@@ -341,6 +341,7 @@
vendor: true,
nocrt: true,
no_libcrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
compile_multilib: "64",
@@ -458,6 +459,7 @@
vendor: true,
nocrt: true,
no_libcrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
}
@@ -467,6 +469,7 @@
vendor: true,
nocrt: true,
no_libcrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
shared_libs: ["libvndk", "libvendor_available", "libllndk"],
@@ -487,6 +490,7 @@
vendor: true,
nocrt: true,
no_libcrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
static_libs: ["libvendor"],
@@ -501,6 +505,7 @@
vendor: true,
nocrt: true,
no_libcrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
vndk: {
@@ -597,6 +602,7 @@
target_arch: "arm64",
compile_multilib: "both",
vendor: true,
+ no_crt_pad_segment: true,
shared_libs: [
"libvendor_without_snapshot",
"libvendor_available",
@@ -620,6 +626,7 @@
target_arch: "arm64",
compile_multilib: "both",
vendor: true,
+ no_crt_pad_segment: true,
overrides: ["libvendor"],
shared_libs: [
"libvendor_without_snapshot",
@@ -657,6 +664,7 @@
target_arch: "arm64",
compile_multilib: "32",
vendor: true,
+ no_crt_pad_segment: true,
arch: {
arm: {
src: "lib32.so",
@@ -683,6 +691,7 @@
target_arch: "arm64",
compile_multilib: "64",
vendor: true,
+ no_crt_pad_segment: true,
arch: {
arm64: {
src: "lib64.so",
@@ -722,6 +731,7 @@
target_arch: "arm64",
compile_multilib: "both",
vendor: true,
+ no_crt_pad_segment: true,
arch: {
arm64: {
src: "libvendor_available.so",
diff --git a/cc/vndk.go b/cc/vndk.go
index 0e0dba9..2b2ea64 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -377,22 +377,17 @@
return false
}
- // ignore prebuilt vndk modules that are newer than or equal to the platform vndk version
- platformVndkApiLevel := android.ApiLevelOrPanic(mctx, mctx.DeviceConfig().PlatformVndkVersion())
- if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(mctx, p.Version())) {
- return false
+ platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
+ if platformVndkVersion != "" {
+ // ignore prebuilt vndk modules that are newer than or equal to the platform vndk version
+ platformVndkApiLevel := android.ApiLevelOrPanic(mctx, platformVndkVersion)
+ if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(mctx, p.Version())) {
+ return false
+ }
}
}
if lib, ok := m.linker.(libraryInterface); ok {
- // VNDK APEX for VNDK-Lite devices will have VNDK-SP libraries from core variants
- if mctx.DeviceConfig().VndkVersion() == "" {
- // b/73296261: filter out libz.so because it is considered as LLNDK for VNDK-lite devices
- if mctx.ModuleName() == "libz" {
- return false
- }
- return m.ImageVariation().Variation == android.CoreVariation && lib.shared() && m.IsVndkSp() && !m.IsVndkExt()
- }
// VNDK APEX doesn't need stub variants
if lib.buildStubs() {
return false
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index eb1790f..43030b8 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -131,11 +131,14 @@
func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
- platformVndkApiLevel := android.ApiLevelOrPanic(ctx, ctx.DeviceConfig().PlatformVndkVersion())
- if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, p.Version())) {
- // This prebuilt VNDK module is not required for the current build
- ctx.Module().HideFromMake()
- return nil
+ platformVndkVersion := ctx.DeviceConfig().PlatformVndkVersion()
+ if platformVndkVersion != "" {
+ platformVndkApiLevel := android.ApiLevelOrPanic(ctx, platformVndkVersion)
+ if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, p.Version())) {
+ // This prebuilt VNDK module is not required for the current build
+ ctx.Module().HideFromMake()
+ return nil
+ }
}
if !p.MatchesWithDevice(ctx.DeviceConfig()) {
@@ -232,6 +235,7 @@
prebuilt.properties.Check_elf_files = BoolPtr(false)
prebuilt.baseLinker.Properties.No_libcrt = BoolPtr(true)
prebuilt.baseLinker.Properties.Nocrt = BoolPtr(true)
+ prebuilt.baseLinker.Properties.No_crt_pad_segment = BoolPtr(true)
// Prevent default system libs (libc, libm, and libdl) from being linked
if prebuilt.baseLinker.Properties.System_shared_libs == nil {
@@ -246,14 +250,6 @@
&prebuilt.properties,
)
- android.AddLoadHook(module, func(ctx android.LoadHookContext) {
- // empty BOARD_VNDK_VERSION implies that the device won't support
- // system only OTA. In this case, VNDK snapshots aren't needed.
- if ctx.DeviceConfig().VndkVersion() == "" {
- ctx.Module().Disable()
- }
- })
-
return module
}
diff --git a/java/androidmk.go b/java/androidmk.go
index c86dcf4..b523594 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -209,9 +209,10 @@
return []android.AndroidMkEntries{}
}
return []android.AndroidMkEntries{android.AndroidMkEntries{
- Class: "JAVA_LIBRARIES",
- OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
- Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
+ Class: "JAVA_LIBRARIES",
+ OverrideName: prebuilt.BaseModuleName(),
+ OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
+ Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index 2c13d99..7c45d30 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -1105,6 +1105,10 @@
return nil
}
+func (module *PrebuiltBootclasspathFragmentModule) UseProfileGuidedDexpreopt() bool {
+ return false
+}
+
var _ android.RequiredFilesFromPrebuiltApex = (*PrebuiltBootclasspathFragmentModule)(nil)
func prebuiltBootclasspathFragmentFactory() android.Module {
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 4c0a0a1..9db9b1b 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -282,6 +282,17 @@
d.installPath = android.PathForModuleInPartitionInstall(ctx, "", strings.TrimPrefix(dexpreopt.GetSystemServerDexLocation(ctx, dc, libraryName), "/"))
// generate the rules for creating the .odex and .vdex files for this system server jar
dexJarFile := di.PrebuiltExportPath(ApexRootRelativePathToJavaLib(libraryName))
+
+ d.inputProfilePathOnHost = nil // reset: TODO(spandandas): Make dexpreopter stateless
+ if android.InList(libraryName, di.GetDexpreoptProfileGuidedExportedModuleNames()) {
+ // Set the profile path to guide optimization
+ prof := di.PrebuiltExportPath(ApexRootRelativePathToJavaLib(libraryName) + ".prof")
+ if prof == nil {
+ ctx.ModuleErrorf("Could not find a .prof file in this prebuilt apex")
+ }
+ d.inputProfilePathOnHost = prof
+ }
+
d.dexpreopt(ctx, libraryName, dexJarFile)
}
@@ -354,6 +365,7 @@
var profileClassListing android.OptionalPath
var profileBootListing android.OptionalPath
profileIsTextListing := false
+
if d.inputProfilePathOnHost != nil {
profileClassListing = android.OptionalPathForPath(d.inputProfilePathOnHost)
} else if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) && !forPrebuiltApex(ctx) {
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 6ef2afe..dc3a0ec 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -537,11 +537,17 @@
var apiVersions android.Path
if proptools.Bool(d.properties.Api_levels_annotations_enabled) {
d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml)
- apiVersions = d.everythingArtifacts.apiVersionsXml
+ apiVersions = apiVersionsXml
} else {
ctx.VisitDirectDepsWithTag(metalavaAPILevelsModuleTag, func(m android.Module) {
if s, ok := m.(*Droidstubs); ok {
- apiVersions = s.everythingArtifacts.apiVersionsXml
+ if stubsType == Everything {
+ apiVersions = s.everythingArtifacts.apiVersionsXml
+ } else if stubsType == Exportable {
+ apiVersions = s.exportableArtifacts.apiVersionsXml
+ } else {
+ ctx.ModuleErrorf("%s stubs type does not generate api-versions.xml file", stubsType.String())
+ }
} else {
ctx.PropertyErrorf("api_levels_module",
"module %q is not a droidstubs module", ctx.OtherModuleName(m))
diff --git a/java/java.go b/java/java.go
index d536ca1..cd249ed 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1837,6 +1837,7 @@
func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
apiContributions := al.properties.Api_contributions
addValidations := !ctx.Config().IsEnvTrue("DISABLE_STUB_VALIDATION") &&
+ !ctx.Config().IsEnvTrue("WITHOUT_CHECK_API") &&
proptools.BoolDefault(al.properties.Enable_validation, true)
for _, apiContributionName := range apiContributions {
ctx.AddDependency(ctx.Module(), javaApiContributionTag, apiContributionName)
@@ -2089,6 +2090,11 @@
// that depend on this module, as well as to aidl for this module.
Export_include_dirs []string
}
+
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
}
type Import struct {
@@ -2162,12 +2168,16 @@
return j.properties.Jars
}
+func (j *Import) BaseModuleName() string {
+ return proptools.StringDefault(j.properties.Source_module_name, j.ModuleBase.Name())
+}
+
func (j *Import) Name() string {
return j.prebuilt.Name(j.ModuleBase.Name())
}
func (j *Import) Stem() string {
- return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name())
+ return proptools.StringDefault(j.properties.Stem, j.BaseModuleName())
}
func (a *Import) JacocoReportClassesFile() android.Path {
@@ -2453,6 +2463,10 @@
return requiredFilesFromPrebuiltApexForImport(name, &j.dexpreopter)
}
+func (j *Import) UseProfileGuidedDexpreopt() bool {
+ return proptools.Bool(j.importDexpreoptProperties.Dex_preopt.Profile_guided)
+}
+
// Add compile time check for interface implementation
var _ android.IDEInfo = (*Import)(nil)
var _ android.IDECustomizedModuleName = (*Import)(nil)
diff --git a/java/java_test.go b/java/java_test.go
index 0891ab6..42301d8 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -24,6 +24,7 @@
"strings"
"testing"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/aconfig"
@@ -2521,3 +2522,105 @@
apiScopePublic.stubsLibraryModuleName("foo"), "android_common",
apiScopePublic.apiLibraryModuleName("foo")))
}
+
+func TestMultiplePrebuilts(t *testing.T) {
+ bp := `
+ // an rdep
+ java_library {
+ name: "foo",
+ libs: ["bar"],
+ }
+
+ // multiple variations of dep
+ // source
+ java_library {
+ name: "bar",
+ srcs: ["bar.java"],
+ }
+ // prebuilt "v1"
+ java_import {
+ name: "bar",
+ jars: ["bar.jar"],
+ }
+ // prebuilt "v2"
+ java_import {
+ name: "bar.v2",
+ source_module_name: "bar",
+ jars: ["bar.v1.jar"],
+ }
+
+ // selectors
+ apex_contributions {
+ name: "myapex_contributions",
+ contents: ["%v"],
+ }
+ `
+ hasDep := func(ctx *android.TestResult, m android.Module, wantDep android.Module) bool {
+ t.Helper()
+ var found bool
+ ctx.VisitDirectDeps(m, func(dep blueprint.Module) {
+ if dep == wantDep {
+ found = true
+ }
+ })
+ return found
+ }
+
+ hasFileWithStem := func(m android.TestingModule, stem string) bool {
+ t.Helper()
+ for _, o := range m.AllOutputs() {
+ _, file := filepath.Split(o)
+ if file == stem+".jar" {
+ return true
+ }
+ }
+ return false
+ }
+
+ testCases := []struct {
+ desc string
+ selectedDependencyName string
+ expectedDependencyName string
+ }{
+ {
+ desc: "Source library is selected using apex_contributions",
+ selectedDependencyName: "bar",
+ expectedDependencyName: "bar",
+ },
+ {
+ desc: "Prebuilt library v1 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_bar",
+ expectedDependencyName: "prebuilt_bar",
+ },
+ {
+ desc: "Prebuilt library v2 is selected using apex_contributions",
+ selectedDependencyName: "prebuilt_bar.v2",
+ expectedDependencyName: "prebuilt_bar.v2",
+ },
+ }
+
+ for _, tc := range testCases {
+ ctx := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
+ }
+ }),
+ ).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName))
+
+ // check that rdep gets the correct variation of dep
+ foo := ctx.ModuleForTests("foo", "android_common")
+ expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_common")
+ android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", foo.Module().Name(), tc.expectedDependencyName), true, hasDep(ctx, foo.Module(), expectedDependency.Module()))
+
+ // check that output file of dep is always bar.jar
+ // The filename should be agnostic to source/prebuilt/prebuilt_version
+ android.AssertBoolEquals(t, fmt.Sprintf("could not find bar.jar in outputs of %s. All Outputs %v\n", tc.expectedDependencyName, expectedDependency.AllOutputs()), true, hasFileWithStem(expectedDependency, "bar"))
+
+ // check LOCAL_MODULE of the selected module name
+ // the prebuilt should have the same LOCAL_MODULE when exported to make
+ entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, expectedDependency.Module())[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_MODULE", "bar", entries.EntryMap["LOCAL_MODULE"][0])
+ }
+}
diff --git a/java/lint.go b/java/lint.go
index c3d723b..31e7f35 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -370,6 +370,12 @@
return
}
+ for _, flag := range l.properties.Lint.Flags {
+ if strings.Contains(flag, "--disable") || strings.Contains(flag, "--enable") || strings.Contains(flag, "--check") {
+ ctx.PropertyErrorf("lint.flags", "Don't use --disable, --enable, or --check in the flags field, instead use the dedicated disabled_checks, warning_checks, error_checks, or fatal_checks fields")
+ }
+ }
+
if l.minSdkVersion.CompareTo(l.compileSdkVersion) == -1 {
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
// Skip lint warning checks for NewApi warnings for libcore where they come from source
diff --git a/java/lint_test.go b/java/lint_test.go
index b7e6aad..751b139 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -260,3 +260,22 @@
}
}
}
+
+func TestCantControlCheckSeverityWithFlags(t *testing.T) {
+ bp := `
+ java_library {
+ name: "foo",
+ srcs: [
+ "a.java",
+ ],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ flags: ["--disabled", "NewApi"],
+ },
+ }
+ `
+ PrepareForTestWithJavaDefaultModules.
+ ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Don't use --disable, --enable, or --check in the flags field, instead use the dedicated disabled_checks, warning_checks, error_checks, or fatal_checks fields")).
+ RunTestWithBp(t, bp)
+}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 2bf6644..49e6727 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -3019,6 +3019,10 @@
return requiredFilesFromPrebuiltApexForImport(name, &module.dexpreopter)
}
+func (j *SdkLibraryImport) UseProfileGuidedDexpreopt() bool {
+ return proptools.Bool(j.importDexpreoptProperties.Dex_preopt.Profile_guided)
+}
+
// java_sdk_library_xml
type sdkLibraryXml struct {
android.ModuleBase
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index 30dd55f..59c5466 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -313,6 +313,10 @@
return nil
}
+func (module *prebuiltSystemServerClasspathModule) UseProfileGuidedDexpreopt() bool {
+ return false
+}
+
var _ android.RequiredFilesFromPrebuiltApex = (*prebuiltSystemServerClasspathModule)(nil)
func prebuiltSystemServerClasspathModuleFactory() android.Module {
diff --git a/python/scripts/precompile_python.py b/python/scripts/precompile_python.py
index e12e7d2..80e7c76 100644
--- a/python/scripts/precompile_python.py
+++ b/python/scripts/precompile_python.py
@@ -16,6 +16,7 @@
import argparse
import py_compile
import os
+import sys
import shutil
import tempfile
import zipfile
@@ -23,22 +24,31 @@
# This file needs to support both python 2 and 3.
-def process_one_file(name, inf, outzip):
- if not name.endswith('.py'):
- outzip.writestr(name, inf.read())
+def process_one_file(info, infile, outzip):
+ if not info.filename.endswith('.py'):
+ outzip.writestr(info, infile.read())
return
# Unfortunately py_compile requires the input/output files to be written
# out to disk.
with tempfile.NamedTemporaryFile(prefix="Soong_precompile_", delete=False) as tmp:
- shutil.copyfileobj(inf, tmp)
+ shutil.copyfileobj(infile, tmp)
in_name = tmp.name
with tempfile.NamedTemporaryFile(prefix="Soong_precompile_", delete=False) as tmp:
out_name = tmp.name
try:
- py_compile.compile(in_name, out_name, name, doraise=True)
+ # Ensure deterministic pyc by using the hash rather than timestamp.
+ # This is required to improve caching in accelerated builds.
+ # Only works on Python 3.7+ (see https://docs.python.org/3/library/py_compile.html#py_compile.PycInvalidationMode)
+ # which should cover most updated branches and developer machines.
+ if sys.version_info >= (3, 7):
+ py_compile.compile(in_name, out_name, info.filename, doraise=True, invalidation_mode=py_compile.PycInvalidationMode.CHECKED_HASH)
+ else:
+ py_compile.compile(in_name, out_name, info.filename, doraise=True)
with open(out_name, 'rb') as f:
- outzip.writestr(name + 'c', f.read())
+ info.filename = info.filename + 'c'
+ # Use ZipInfo rather than str to reuse timestamps for deterministic zip files.
+ outzip.writestr(info, f.read())
finally:
os.remove(in_name)
os.remove(out_name)
@@ -52,9 +62,9 @@
with open(args.dst_zip, 'wb') as outf, open(args.src_zip, 'rb') as inf:
with zipfile.ZipFile(outf, mode='w') as outzip, zipfile.ZipFile(inf, mode='r') as inzip:
- for name in inzip.namelist():
- with inzip.open(name, mode='r') as inzipf:
- process_one_file(name, inzipf, outzip)
+ for info in inzip.infolist():
+ with inzip.open(info.filename, mode='r') as inzipf:
+ process_one_file(info, inzipf, outzip)
if __name__ == "__main__":
diff --git a/rust/androidmk.go b/rust/androidmk.go
index 17fd2d8..e0cb3ce 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -63,8 +63,10 @@
entries.AddStrings("LOCAL_SHARED_LIBRARIES", mod.transitiveAndroidMkSharedLibs.ToList()...)
entries.AddStrings("LOCAL_STATIC_LIBRARIES", mod.Properties.AndroidMkStaticLibs...)
entries.AddStrings("LOCAL_SOONG_LINK_TYPE", mod.makeLinkType)
- if mod.UseVndk() {
- entries.SetBool("LOCAL_USE_VNDK", true)
+ if mod.InVendor() {
+ entries.SetBool("LOCAL_IN_VENDOR", true)
+ } else if mod.InProduct() {
+ entries.SetBool("LOCAL_IN_PRODUCT", true)
}
android.SetAconfigFileMkEntries(mod.AndroidModuleBase(), entries, mod.mergedAconfigFiles)
},
diff --git a/rust/vendor_snapshot_test.go b/rust/vendor_snapshot_test.go
index 4f45799..7ebe66b 100644
--- a/rust/vendor_snapshot_test.go
+++ b/rust/vendor_snapshot_test.go
@@ -553,6 +553,7 @@
vendor: true,
nocrt: true,
no_libcrt: true,
+ no_crt_pad_segment: true,
stl: "none",
system_shared_libs: [],
}
@@ -857,6 +858,7 @@
target_arch: "arm64",
compile_multilib: "32",
vendor: true,
+ no_crt_pad_segment: true,
arch: {
arm: {
src: "lib32.so",
@@ -870,6 +872,7 @@
target_arch: "arm64",
compile_multilib: "64",
vendor: true,
+ no_crt_pad_segment: true,
arch: {
arm64: {
src: "lib64.so",
@@ -882,6 +885,7 @@
target_arch: "arm64",
compile_multilib: "64",
vendor: true,
+ no_crt_pad_segment: true,
arch: {
arm64: {
src: "liblog.so",
@@ -913,6 +917,7 @@
target_arch: "arm64",
compile_multilib: "both",
vendor: true,
+ no_crt_pad_segment: true,
arch: {
arm64: {
src: "libvendor_available.so",