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

This commit is contained in:
Peter Collingbourne
2020-02-18 18:12:37 +00:00
committed by Gerrit Code Review
5 changed files with 125 additions and 44 deletions

View File

@@ -95,6 +95,8 @@ type Deps struct {
HeaderLibs []string
RuntimeLibs []string
StaticUnwinderIfLegacy bool
ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string
ObjFiles []string
@@ -385,6 +387,7 @@ var (
lateSharedDepTag = DependencyTag{Name: "late shared", Library: true, Shared: true}
staticExportDepTag = DependencyTag{Name: "static", Library: true, ReexportFlags: true}
lateStaticDepTag = DependencyTag{Name: "late static", Library: true}
staticUnwinderDepTag = DependencyTag{Name: "static unwinder", Library: true}
wholeStaticDepTag = DependencyTag{Name: "whole static", Library: true, ReexportFlags: true}
headerDepTag = DependencyTag{Name: "header", Library: true}
headerExportDepTag = DependencyTag{Name: "header", Library: true, ReexportFlags: true}
@@ -1788,6 +1791,12 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}, depTag, lib)
}
if deps.StaticUnwinderIfLegacy && ctx.Config().UnbundledBuild() {
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, staticUnwinderDepTag, staticUnwinder(actx))
}
for _, lib := range deps.LateStaticLibs {
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
@@ -2161,6 +2170,14 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
}
if depTag == staticUnwinderDepTag {
if c.ApexProperties.Info.LegacyAndroid10Support {
depTag = StaticDepTag
} else {
return
}
}
// Extract ExplicitlyVersioned field from the depTag and reset it inside the struct.
// Otherwise, SharedDepTag and lateSharedDepTag with ExplicitlyVersioned set to true
// won't be matched to SharedDepTag and lateSharedDepTag.

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