Merge "Move imageMutator before archMutator"
diff --git a/android/apex.go b/android/apex.go
index 3da4828..1b0412b 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -138,7 +138,7 @@
}
const (
- availableToPlatform = "//apex_available:platform"
+ AvailableToPlatform = "//apex_available:platform"
availableToAnyApex = "//apex_available:anyapex"
)
@@ -149,7 +149,7 @@
return true
}
return InList(what, apex_available) ||
- (what != availableToPlatform && InList(availableToAnyApex, apex_available))
+ (what != AvailableToPlatform && InList(availableToAnyApex, apex_available))
}
func (m *ApexModuleBase) AvailableFor(what string) bool {
@@ -165,7 +165,7 @@
func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
for _, n := range m.ApexProperties.Apex_available {
- if n == availableToPlatform || n == availableToAnyApex {
+ if n == AvailableToPlatform || n == availableToAnyApex {
continue
}
if !mctx.OtherModuleExists(n) && !mctx.Config().AllowMissingDependencies() {
@@ -179,7 +179,7 @@
m.checkApexAvailableProperty(mctx)
sort.Strings(m.apexVariations)
variations := []string{}
- availableForPlatform := mctx.Module().(ApexModule).AvailableFor(availableToPlatform) || mctx.Host()
+ availableForPlatform := mctx.Module().(ApexModule).AvailableFor(AvailableToPlatform) || mctx.Host()
if availableForPlatform {
variations = append(variations, "") // Original variation for platform
}
@@ -228,6 +228,14 @@
apexNames[apexName] = apexNames[apexName] || directDep
}
+// TODO(b/146393795): remove this when b/146393795 is fixed
+func ClearApexDependency() {
+ m := apexNamesMap()
+ for k := range m {
+ delete(m, k)
+ }
+}
+
// Tests whether a module named moduleName is directly depended on by an APEX
// named apexName.
func DirectlyInApex(apexName string, moduleName string) bool {
diff --git a/apex/apex.go b/apex/apex.go
index 3d7b45d..8a336ba 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -488,9 +488,11 @@
properties apexBundleProperties
targetProperties apexTargetBundleProperties
- vndkProperties apexVndkProperties
overridableProperties overridableProperties
+ // specific to apex_vndk modules
+ vndkProperties apexVndkProperties
+
bundleModuleFile android.WritablePath
outputFile android.WritablePath
installDir android.InstallPath
@@ -722,7 +724,13 @@
}
func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
- certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
+ moduleName := ctx.ModuleName()
+ // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
+ // we check with the pseudo module name to see if its certificate is overridden.
+ if a.vndkApex {
+ moduleName = vndkApexName
+ }
+ certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
if overridden {
return ":" + certificate
}
@@ -1093,7 +1101,7 @@
// don't include it in this APEX
return false
}
- if !a.Host() && (cc.IsStubs() || cc.HasStubsVariants()) {
+ if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
// If the dependency is a stubs lib, don't include it in this APEX,
// but make sure that the lib is installed on the device.
// In case no APEX is having the lib, the lib is installed to the system
@@ -1278,6 +1286,7 @@
module.AddProperties(
&apexBundleProperties{},
&apexTargetBundleProperties{},
+ &overridableProperties{},
)
android.InitDefaultsModule(module)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index f90b505..34547a2 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -92,6 +92,7 @@
}
func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*android.TestContext, android.Config) {
+ android.ClearApexDependency()
config := android.TestArchConfig(buildDir, nil)
config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current")
config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test")
@@ -532,6 +533,62 @@
ensureListContains(t, noticeInputs, "custom_notice")
}
+func TestDefaults(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex_defaults {
+ name: "myapex-defaults",
+ key: "myapex.key",
+ prebuilts: ["myetc"],
+ native_shared_libs: ["mylib"],
+ java_libs: ["myjar"],
+ apps: ["AppFoo"],
+ }
+
+ prebuilt_etc {
+ name: "myetc",
+ src: "myprebuilt",
+ }
+
+ apex {
+ name: "myapex",
+ defaults: ["myapex-defaults"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "mylib",
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ java_library {
+ name: "myjar",
+ srcs: ["foo/bar/MyClass.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ compile_dex: true,
+ }
+
+ android_app {
+ name: "AppFoo",
+ srcs: ["foo/bar/MyClass.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ `)
+ ensureExactContents(t, ctx, "myapex", []string{
+ "etc/myetc",
+ "javalib/myjar.jar",
+ "lib64/mylib.so",
+ "app/AppFoo/AppFoo.apk",
+ })
+}
+
func TestApexManifest(t *testing.T) {
ctx, _ := testApex(t, `
apex {
@@ -683,6 +740,12 @@
// Ensure that genstub is invoked with --apex
ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_3_myapex").Rule("genStubSrc").Args["flags"])
+
+ ensureExactContents(t, ctx, "myapex", []string{
+ "lib64/mylib.so",
+ "lib64/mylib3.so",
+ "lib64/mylib4.so",
+ })
}
func TestApexWithExplicitStubsDependency(t *testing.T) {
@@ -1256,6 +1319,134 @@
}
}
+func TestCertificate(t *testing.T) {
+ t.Run("if unspecified, it defaults to DefaultAppCertificate", func(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }`)
+ rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("signapk")
+ expected := "vendor/foo/devkeys/test.x509.pem vendor/foo/devkeys/test.pk8"
+ if actual := rule.Args["certificates"]; actual != expected {
+ t.Errorf("certificates should be %q, not %q", expected, actual)
+ }
+ })
+ t.Run("override when unspecified", func(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex_keytest",
+ key: "myapex.key",
+ file_contexts: ":myapex-file_contexts",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ android_app_certificate {
+ name: "myapex.certificate.override",
+ certificate: "testkey.override",
+ }`)
+ rule := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest_image").Rule("signapk")
+ expected := "testkey.override.x509.pem testkey.override.pk8"
+ if actual := rule.Args["certificates"]; actual != expected {
+ t.Errorf("certificates should be %q, not %q", expected, actual)
+ }
+ })
+ t.Run("if specified as :module, it respects the prop", func(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ certificate: ":myapex.certificate",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ android_app_certificate {
+ name: "myapex.certificate",
+ certificate: "testkey",
+ }`)
+ rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("signapk")
+ expected := "testkey.x509.pem testkey.pk8"
+ if actual := rule.Args["certificates"]; actual != expected {
+ t.Errorf("certificates should be %q, not %q", expected, actual)
+ }
+ })
+ t.Run("override when specifiec as <:module>", func(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex_keytest",
+ key: "myapex.key",
+ file_contexts: ":myapex-file_contexts",
+ certificate: ":myapex.certificate",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ android_app_certificate {
+ name: "myapex.certificate.override",
+ certificate: "testkey.override",
+ }`)
+ rule := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest_image").Rule("signapk")
+ expected := "testkey.override.x509.pem testkey.override.pk8"
+ if actual := rule.Args["certificates"]; actual != expected {
+ t.Errorf("certificates should be %q, not %q", expected, actual)
+ }
+ })
+ t.Run("if specified as name, finds it from DefaultDevKeyDir", func(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ certificate: "testkey",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }`)
+ rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("signapk")
+ expected := "vendor/foo/devkeys/testkey.x509.pem vendor/foo/devkeys/testkey.pk8"
+ if actual := rule.Args["certificates"]; actual != expected {
+ t.Errorf("certificates should be %q, not %q", expected, actual)
+ }
+ })
+ t.Run("override when specified as <name>", func(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex_keytest",
+ key: "myapex.key",
+ file_contexts: ":myapex-file_contexts",
+ certificate: "testkey",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ android_app_certificate {
+ name: "myapex.certificate.override",
+ certificate: "testkey.override",
+ }`)
+ rule := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest_image").Rule("signapk")
+ expected := "testkey.override.x509.pem testkey.override.pk8"
+ if actual := rule.Args["certificates"]; actual != expected {
+ t.Errorf("certificates should be %q, not %q", expected, actual)
+ }
+ })
+}
+
func TestMacro(t *testing.T) {
ctx, _ := testApex(t, `
apex {
diff --git a/apex/builder.go b/apex/builder.go
index a90918d..d24885e 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -350,8 +350,8 @@
implicitInputs = append(implicitInputs, cannedFsConfig, a.fileContexts, a.private_key_file, a.public_key_file)
optFlags = append(optFlags, "--pubkey "+a.public_key_file.String())
- manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(a.Name())
- if overridden {
+ manifestPackageName := a.getOverrideManifestPackageName(ctx)
+ if manifestPackageName != "" {
optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
}
@@ -495,15 +495,17 @@
}
func (a *apexBundle) setCertificateAndPrivateKey(ctx android.ModuleContext) {
- cert := String(a.properties.Certificate)
- if cert != "" && android.SrcIsModule(cert) == "" {
- defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
- a.container_certificate_file = defaultDir.Join(ctx, cert+".x509.pem")
- a.container_private_key_file = defaultDir.Join(ctx, cert+".pk8")
- } else if cert == "" {
- pem, key := ctx.Config().DefaultAppCertificate(ctx)
- a.container_certificate_file = pem
- a.container_private_key_file = key
+ if a.container_certificate_file == nil {
+ cert := String(a.properties.Certificate)
+ if cert == "" {
+ pem, key := ctx.Config().DefaultAppCertificate(ctx)
+ a.container_certificate_file = pem
+ a.container_private_key_file = key
+ } else {
+ defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
+ a.container_certificate_file = defaultDir.Join(ctx, cert+".x509.pem")
+ a.container_private_key_file = defaultDir.Join(ctx, cert+".pk8")
+ }
}
}
@@ -534,3 +536,21 @@
}
}
}
+
+func (a *apexBundle) getOverrideManifestPackageName(ctx android.ModuleContext) string {
+ // For VNDK APEXes, check "com.android.vndk" in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
+ // to see if it should be overridden because their <apex name> is dynamically generated
+ // according to its VNDK version.
+ if a.vndkApex {
+ overrideName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(vndkApexName)
+ if overridden {
+ return strings.Replace(*a.properties.Apex_name, vndkApexName, overrideName, 1)
+ }
+ return ""
+ }
+ manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(a.Name())
+ if overridden {
+ return manifestPackageName
+ }
+ return ""
+}
diff --git a/apex/vndk.go b/apex/vndk.go
index 15f7f87..43fcfcd 100644
--- a/apex/vndk.go
+++ b/apex/vndk.go
@@ -26,7 +26,8 @@
)
const (
- vndkApexNamePrefix = "com.android.vndk.v"
+ vndkApexName = "com.android.vndk"
+ vndkApexNamePrefix = vndkApexName + ".v"
)
// apex_vndk creates a special variant of apex modules which contains only VNDK libraries.
diff --git a/cc/config/clang.go b/cc/config/clang.go
index eddc341..8618d09 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -132,6 +132,10 @@
// Disable -Winconsistent-missing-override until we can clean up the existing
// codebase for it.
"-Wno-inconsistent-missing-override",
+
+ // Warnings from clang-10
+ // Nested and array designated initialization is nice to have.
+ "-Wno-c99-designator",
}, " "))
pctx.StaticVariable("ClangExtraCppflags", strings.Join([]string{
@@ -161,6 +165,10 @@
// new warnings are fixed.
"-Wno-tautological-constant-compare",
"-Wno-tautological-type-limit-compare",
+ // http://b/145210666
+ "-Wno-reorder-init-list",
+ // http://b/145211066
+ "-Wno-implicit-int-float-conversion",
}, " "))
// Extra cflags for external third-party projects to disable warnings that
@@ -176,6 +184,13 @@
// Bug: http://b/29823425 Disable -Wnull-dereference until the
// new instances detected by this warning are fixed.
"-Wno-null-dereference",
+
+ // http://b/145211477
+ "-Wno-pointer-compare",
+ // http://b/145211022
+ "-Wno-xor-used-as-pow",
+ // http://b/145211022
+ "-Wno-final-dtor-non-final-class",
}, " "))
}
diff --git a/cc/config/global.go b/cc/config/global.go
index 0a09fa4..bae5555 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -126,8 +126,8 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r365631b"
- ClangDefaultShortVersion = "9.0.7"
+ ClangDefaultVersion = "clang-r370808"
+ ClangDefaultShortVersion = "10.0.1"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index d529622..00338b9 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -261,6 +261,7 @@
// We're knowingly doing some otherwise unsightly things with builtin
// functions here. We're just generating stub libraries, so ignore it.
"-Wno-incompatible-library-redeclaration",
+ "-Wno-incomplete-setjmp-declaration",
"-Wno-builtin-requires-header",
"-Wno-invalid-noreturn",
"-Wall",
diff --git a/cc/sanitize.go b/cc/sanitize.go
index b4082d3..c4aeb96 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -494,6 +494,15 @@
// Disable fortify for fuzzing builds. Generally, we'll be building with
// UBSan or ASan here and the fortify checks pollute the stack traces.
flags.Local.CFlags = append(flags.Local.CFlags, "-U_FORTIFY_SOURCE")
+
+ // Build fuzzer-sanitized libraries with an $ORIGIN DT_RUNPATH. Android's
+ // linker uses DT_RUNPATH, not DT_RPATH. When we deploy cc_fuzz targets and
+ // their libraries to /data/fuzz/<arch>/lib, any transient shared library gets
+ // the DT_RUNPATH from the shared library above it, and not the executable,
+ // meaning that the lookup falls back to the system. Adding the $ORIGIN to the
+ // DT_RUNPATH here means that transient shared libraries can be found
+ // colocated with their parents.
+ flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN`)
}
if Bool(sanitize.Properties.Sanitize.Cfi) {
diff --git a/cc/xom.go b/cc/xom.go
index e1cac53..ce817aa 100644
--- a/cc/xom.go
+++ b/cc/xom.go
@@ -68,7 +68,10 @@
if !disableXom || (xom.Properties.Xom != nil && *xom.Properties.Xom) {
// XOM is only supported on AArch64 when using lld.
if ctx.Arch().ArchType == android.Arm64 && ctx.useClangLld(ctx) {
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-execute-only")
+ flags.Local.LdFlags = append(flags.Local.LdFlags,
+ "-Wl,--execute-only",
+ "-Wl,-z,separate-code",
+ )
}
}
diff --git a/java/androidmk.go b/java/androidmk.go
index f4e3c34..11fea82 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -24,7 +24,7 @@
func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
if !library.IsForPlatform() {
- // If the platform variant is available, don't emit hostdex modules from the APEX variants
+ // Don't emit hostdex modules from the APEX variants
hostDexNeeded = false
}
@@ -62,8 +62,14 @@
var entriesList []android.AndroidMkEntries
mainEntries := android.AndroidMkEntries{Disabled: true}
+
// For a java library built for an APEX, we don't need Make module
- if library.IsForPlatform() {
+ hideFromMake := !library.IsForPlatform()
+ // If not available for platform, don't emit to make.
+ if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
+ hideFromMake = true
+ }
+ if !hideFromMake {
mainEntries = android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(library.outputFile),
diff --git a/java/app.go b/java/app.go
index 7595e36..9fa7179 100755
--- a/java/app.go
+++ b/java/app.go
@@ -636,7 +636,7 @@
fixedConfig := android.PathForModuleOut(ctx, "test_config_fixer", "AndroidTest.xml")
rule := android.NewRuleBuilder()
rule.Command().BuiltTool(ctx, "test_config_fixer").
- FlagWithArg("--manifest ", a.manifestPath.String()).
+ FlagWithInput("--manifest ", a.manifestPath).
FlagWithArg("--package-name ", *a.overridableAppProperties.Package_name).
Input(a.testConfig).
Output(fixedConfig)
diff --git a/java/config/config.go b/java/config/config.go
index fee6341..06c99f1 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -46,6 +46,7 @@
"core-oj",
"core-libart",
"updatable-media",
+ "ike",
}
)
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index ad84cde..e9e4a45 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "strings"
"android/soong/android"
)
@@ -152,11 +153,23 @@
// Collect dex jar paths for modules that had hiddenapi encode called on them.
if h, ok := module.(hiddenAPIIntf); ok {
if jar := h.bootDexJar(); jar != nil {
- // For a java lib included in an APEX, only take the one built for
- // the platform variant, and skip the variants for APEXes.
- // Otherwise, the hiddenapi tool will complain about duplicated classes
- if a, ok := module.(android.ApexModule); ok {
- if android.InAnyApex(module.Name()) && !a.IsForPlatform() {
+ // Don't add multiple variants of the same library to bootDexJars, otherwise
+ // hiddenapi tool will complain about duplicated classes. Such multiple variants
+ // of the same library can happen when the library is included in one or more APEXes.
+ // TODO(b/146308764): remove this heuristic
+ if a, ok := module.(android.ApexModule); ok && android.InAnyApex(module.Name()) {
+ if a.AvailableFor("//apex_available:platform") && !a.IsForPlatform() {
+ // skip the apex variants if the jar is available for the platform
+ return
+ }
+ apexName := a.ApexName()
+ if strings.Contains(apexName, "test") {
+ // skip the if the jar is in test APEX
+ return
+ }
+
+ if strings.Contains(apexName, "com.android.art") && apexName != "com.android.art.release" {
+ // skip the ART APEX variants other than com.android.art.release
return
}
}
diff --git a/java/java.go b/java/java.go
index d8db5f8..59bfaf7 100644
--- a/java/java.go
+++ b/java/java.go
@@ -559,6 +559,16 @@
return j.sdkVersion()
}
+func (j *Module) AvailableFor(what string) bool {
+ if what == android.AvailableToPlatform && Bool(j.deviceProperties.Hostdex) {
+ // Exception: for hostdex: true libraries, the platform variant is created
+ // even if it's not marked as available to platform. In that case, the platform
+ // variant is used only for the hostdex and not installed to the device.
+ return true
+ }
+ return j.ApexModuleBase.AvailableFor(what)
+}
+
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
if ctx.Device() {
sdkDep := decodeSdkDep(ctx, sdkContext(j))
diff --git a/rust/config/arm64_device.go b/rust/config/arm64_device.go
index 0264052..60796d8 100644
--- a/rust/config/arm64_device.go
+++ b/rust/config/arm64_device.go
@@ -27,7 +27,8 @@
"-Wl,--icf=safe",
"-Wl,-z,max-page-size=4096",
- "-Wl,-execute-only",
+ "-Wl,--execute-only",
+ "-Wl,-z,separate-code",
}
Arm64ArchVariantRustFlags = map[string][]string{