aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@google.com>2019-09-10 23:18:20 +0100
committerMartin Stjernholm <mast@google.com>2019-09-11 12:16:31 +0100
commit279de572d79d6eaccf298facc766745ce22d9312 (patch)
treee0ebedeffd69eeed8a9b19b05244197b70dd393d
parent84bd071cac28b71032bea5d1f604a9b25b395bc6 (diff)
downloadbuild_soong-279de572d79d6eaccf298facc766745ce22d9312.tar.gz
build_soong-279de572d79d6eaccf298facc766745ce22d9312.tar.bz2
build_soong-279de572d79d6eaccf298facc766745ce22d9312.zip
Treat libclang_rt.hwasan-* the same way as the other Bionic bootstrap libs.
Ensure that it ends up in the bionic/ subdir in the Runtime APEX and is symlinked from /system/lib(64). That makes it available in the default (platform) linker namespace and no longer requires it to be accessible through the runtime namespace. All this makes it consistent with how the other Bionic libs are handled, and avoids the need for various special cases in ld.config.txt files (to be cleaned up later). With this there might no longer be a need for a linker namespace for the Runtime APEX, and we could consider removing the kludge with the /apex/com.android.runtime/${LIB}/bionic subdirectories and the special case in getCopyManifestForNativeLibrary in apex.go. However, keeping it calls out the special treatment of those libraries, and allows a namespace to be added again if necessary. Test: Build and boot on taimen_hwasan-userdebug Test: adb shell /apex/com.android.art/bin/dexdump on taimen_hwasan-userdebug Test: atest CtsCompilationTestCases on taimen_hwasan-userdebug Bug: 140734238 Bug: 140790209 Change-Id: Ieb506bfa5d5c159db391273c7eba41d7909de286
-rw-r--r--apex/apex.go52
-rw-r--r--cc/binary.go2
-rw-r--r--cc/cc.go2
-rw-r--r--cc/library.go4
4 files changed, 29 insertions, 31 deletions
diff --git a/apex/apex.go b/apex/apex.go
index b32cc0f9..315e09f8 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -753,38 +753,36 @@ func (a *apexBundle) SetFlattened(flattened bool) {
a.properties.Flattened = flattened
}
-func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
+func getCopyManifestForNativeLibrary(ccMod *cc.Module, config android.Config, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
// Decide the APEX-local directory by the multilib of the library
// In the future, we may query this to the module.
- switch cc.Arch().ArchType.Multilib {
+ switch ccMod.Arch().ArchType.Multilib {
case "lib32":
dirInApex = "lib"
case "lib64":
dirInApex = "lib64"
}
- dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
- if !cc.Arch().Native {
- dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
- } else if cc.Target().NativeBridge == android.NativeBridgeEnabled {
- dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
- }
- if handleSpecialLibs {
- switch cc.Name() {
- case "libc", "libm", "libdl":
- // Special case for bionic libs. This is to prevent the bionic libs
- // from being included in the search path /apex/com.android.apex/lib.
- // This exclusion is required because bionic libs in the runtime APEX
- // are available via the legacy paths /system/lib/libc.so, etc. By the
- // init process, the bionic libs in the APEX are bind-mounted to the
- // legacy paths and thus will be loaded into the default linker namespace.
- // If the bionic libs are directly in /apex/com.android.apex/lib then
- // the same libs will be again loaded to the runtime linker namespace,
- // which will result double loading of bionic libs that isn't supported.
- dirInApex = filepath.Join(dirInApex, "bionic")
- }
- }
-
- fileToCopy = cc.OutputFile().Path()
+ dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
+ if !ccMod.Arch().Native {
+ dirInApex = filepath.Join(dirInApex, ccMod.Arch().ArchType.String())
+ } else if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
+ dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
+ }
+ if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), config) {
+ // Special case for Bionic libs and other libs installed with them. This is
+ // to prevent those libs from being included in the search path
+ // /apex/com.android.runtime/${LIB}. This exclusion is required because
+ // those libs in the Runtime APEX are available via the legacy paths in
+ // /system/lib/. By the init process, the libs in the APEX are bind-mounted
+ // to the legacy paths and thus will be loaded into the default linker
+ // namespace (aka "platform" namespace). If the libs are directly in
+ // /apex/com.android.runtime/${LIB} then the same libs will be loaded again
+ // into the runtime linker namespace, which will result in double loading of
+ // them, which isn't supported.
+ dirInApex = filepath.Join(dirInApex, "bionic")
+ }
+
+ fileToCopy = ccMod.OutputFile().Path()
return
}
@@ -920,7 +918,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if cc.HasStubsVariants() {
provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base())
}
- fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, handleSpecialLibs)
+ fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, ctx.Config(), handleSpecialLibs)
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil})
return true
} else {
@@ -1051,7 +1049,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Don't track further
return false
}
- fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, handleSpecialLibs)
+ fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, ctx.Config(), handleSpecialLibs)
filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil})
return true
}
diff --git a/cc/binary.go b/cc/binary.go
index 17e729ca..0d694051 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -454,7 +454,7 @@ func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
// The original path becomes a symlink to the corresponding file in the
// runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled || !ctx.Arch().Native
- if installToBootstrap(ctx.baseModuleName(), ctx.Config()) && !translatedArch && ctx.apexName() == "" && !ctx.inRecovery() {
+ if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !translatedArch && ctx.apexName() == "" && !ctx.inRecovery() {
if ctx.Device() && isBionic(ctx.baseModuleName()) {
binary.installSymlinkToRuntimeApex(ctx, file)
}
diff --git a/cc/cc.go b/cc/cc.go
index f97ef5ae..b1c8dee5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -677,7 +677,7 @@ func isBionic(name string) bool {
return false
}
-func installToBootstrap(name string, config android.Config) bool {
+func InstallToBootstrap(name string, config android.Config) bool {
if name == "libclang_rt.hwasan-aarch64-android" {
return inList("hwaddress", config.SanitizeDevice())
}
diff --git a/cc/library.go b/cc/library.go
index 9178a527..aef9ab67 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1013,8 +1013,8 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
// The original path becomes a symlink to the corresponding file in the
// runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled || !ctx.Arch().Native
- if installToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() && !translatedArch && !ctx.inRecovery() {
- if ctx.Device() && isBionic(ctx.baseModuleName()) {
+ if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() && !translatedArch && !ctx.inRecovery() {
+ if ctx.Device() {
library.installSymlinkToRuntimeApex(ctx, file)
}
library.baseInstaller.subDir = "bootstrap"