Statically link the unwinder into binaries packaged into an unbundled APEX with legacy_android10_support: true.

Bug: 149075752
Test: tapas com.android.conscrypt com.android.tethering arm64
Test: m out/target/product/generic_arm64/{,symbols/}apex/com.android.{tethering,conscrypt}/lib64/libc++.so
Test: Verified that unwinder was dynamically linked to tethering's
Test: libc++ and statically linked to conscrypt's.
Test: lunch flame-userdebug && m
Test: Verified that unwinder was dynamically linked to /system/lib64/libc++.so
Change-Id: I98eed7cb4316962b19b5c12e150c224c25d0e91d
This commit is contained in:
Peter Collingbourne
2020-02-12 17:13:25 -08:00
parent edb3174967
commit dc4f986b2a
5 changed files with 125 additions and 44 deletions

View File

@@ -151,6 +151,14 @@ func needsLibAndroidSupport(ctx BaseModuleContext) bool {
return version < 21
}
func staticUnwinder(ctx android.BaseModuleContext) string {
if ctx.Arch().ArchType == android.Arm {
return "libunwind_llvm"
} else {
return "libgcc_stripped"
}
}
func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
switch stl.Properties.SelectedStl {
case "libstdc++":
@@ -172,16 +180,16 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
}
if ctx.toolchain().Bionic() {
if ctx.staticBinary() {
deps.StaticLibs = append(deps.StaticLibs, "libm", "libc")
if ctx.Arch().ArchType == android.Arm {
deps.StaticLibs = append(deps.StaticLibs, "libunwind_llvm")
} else {
deps.StaticLibs = append(deps.StaticLibs, "libgcc_stripped")
}
deps.StaticLibs = append(deps.StaticLibs, "libm", "libc", staticUnwinder(ctx))
} else {
deps.StaticUnwinderIfLegacy = true
}
}
case "":
// None or error.
if ctx.toolchain().Bionic() && ctx.Module().Name() == "libc++" {
deps.StaticUnwinderIfLegacy = true
}
case "ndk_system":
// TODO: Make a system STL prebuilt for the NDK.
// The system STL doesn't have a prebuilt (it uses the system's libstdc++), but it does have