From 57621b29c4097a154b0319cddebcf82e5a6f5a27 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 20 Jan 2021 20:33:11 +0900 Subject: [PATCH] LOCAL_REQUIRED_MODULES from apex has ":32" or ":64" suffix Currently, when a module is included in an APEX, the dependencies of the modules are listed in LOCAL_REQUIRED_MODULES of the APEX. There are two purposes for this: 1) for native dependencies, they are installed to $(TARGET_OUT)/apex/ directories which isn't packaged as an *.img. However, as a side effect of the installation, their symbol files are placed under $(TARGET_OUT)/symbols directory to aid debugging. 2) to implement the symlink optimization. When the APEX is not updatable, the dependencies are not included inside the APEX, but installed directly to /system partition because the same files might be used outside of the APEX. The files in the APEX are replaced with symlinks to the system copy. So far, the module name like "libfoo" was directly used in LOCAL_REQUIRED_MODULES. This becomes problematic when only a single arch variant of the module is used by the APEX. The build system will install both arch variants to the system partition. This change fixes the problem by appending ":32" or ":64" suffix when composing LOCAL_REQUIRED_MODULES. Bug: N/A Test: m Test: Cherry-pick I285c5d1bb9b27265c8589f2588d95eafa324d412 and its dependencies from internal master. `m nothing` doesn't show the artifact path requirement error. Change-Id: I78feae1d5b18f93b0f984d3b1558812fd1689a96 --- apex/androidmk.go | 14 ++++++++++++-- apex/apex.go | 3 +++ apex/apex_test.go | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apex/androidmk.go b/apex/androidmk.go index 0b114f83b..44082836f 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -126,8 +126,18 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo moduleName := a.fullModuleName(apexBundleName, &fi) - if !android.InList(moduleName, moduleNames) { - moduleNames = append(moduleNames, moduleName) + // This name will be added to LOCAL_REQUIRED_MODULES of the APEX. We need to be + // arch-specific otherwise we will end up installing both ABIs even when only + // either of the ABI is requested. + aName := moduleName + switch fi.multilib { + case "lib32": + aName = aName + ":32" + case "lib64": + aName = aName + ":64" + } + if !android.InList(aName, moduleNames) { + moduleNames = append(moduleNames, aName) } if linkToSystemLib { diff --git a/apex/apex.go b/apex/apex.go index 5cd18ed28..7d79f267c 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -440,6 +440,8 @@ type apexFile struct { transitiveDep bool isJniLib bool + multilib string + // TODO(jiyong): remove this module android.Module } @@ -459,6 +461,7 @@ func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidM ret.requiredModuleNames = module.RequiredModuleNames() ret.targetRequiredModuleNames = module.TargetRequiredModuleNames() ret.hostRequiredModuleNames = module.HostRequiredModuleNames() + ret.multilib = module.Target().Arch.ArchType.Multilib } return ret } diff --git a/apex/apex_test.go b/apex/apex_test.go index fc746724a..4f8865a0d 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -5536,7 +5536,7 @@ func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) { ensureNotContains(t, androidMk, "LOCAL_MODULE := prebuilt_myotherlib.myapex\n") ensureNotContains(t, androidMk, "LOCAL_MODULE := myotherlib.myapex\n") // `myapex` should have `myotherlib` in its required line, not `prebuilt_myotherlib` - ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += mylib.myapex myotherlib apex_manifest.pb.myapex apex_pubkey.myapex\n") + ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += mylib.myapex:64 myotherlib:64 apex_manifest.pb.myapex apex_pubkey.myapex\n") } func TestApexWithJniLibs(t *testing.T) {