Merge "Stop linking libdl.a into static bins" am: ce6b216c5e

am: d258b0fceb

Change-Id: I31204d498eea8d406615e6f072cba9275b40de3a
This commit is contained in:
Ryan Prichard
2019-10-28 13:47:17 -07:00
committed by android-build-merger
4 changed files with 6 additions and 4 deletions

View File

@@ -158,7 +158,7 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
if binary.static() { if binary.static() {
if ctx.selectedStl() == "libc++_static" { if ctx.selectedStl() == "libc++_static" {
deps.StaticLibs = append(deps.StaticLibs, "libm", "libc", "libdl") deps.StaticLibs = append(deps.StaticLibs, "libm", "libc")
} }
// static libraries libcompiler_rt, libc and libc_nomalloc need to be linked with // static libraries libcompiler_rt, libc and libc_nomalloc need to be linked with
// --start-group/--end-group along with libgcc. If they are in deps.StaticLibs, // --start-group/--end-group along with libgcc. If they are in deps.StaticLibs,

View File

@@ -2309,7 +2309,7 @@ func TestStaticExecutable(t *testing.T) {
variant := "android_arm64_armv8-a_core" variant := "android_arm64_armv8-a_core"
binModuleRule := ctx.ModuleForTests("static_test", variant).Rule("ld") binModuleRule := ctx.ModuleForTests("static_test", variant).Rule("ld")
libFlags := binModuleRule.Args["libFlags"] libFlags := binModuleRule.Args["libFlags"]
systemStaticLibs := []string{"libc.a", "libm.a", "libdl.a"} systemStaticLibs := []string{"libc.a", "libm.a"}
for _, lib := range systemStaticLibs { for _, lib := range systemStaticLibs {
if !strings.Contains(libFlags, lib) { if !strings.Contains(libFlags, lib) {
t.Errorf("Static lib %q was not found in %q", lib, libFlags) t.Errorf("Static lib %q was not found in %q", lib, libFlags)

View File

@@ -848,12 +848,14 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
// Determine the runtime library required // Determine the runtime library required
runtimeLibrary := "" runtimeLibrary := ""
var extraStaticDeps []string
toolchain := c.toolchain(mctx) toolchain := c.toolchain(mctx)
if Bool(c.sanitize.Properties.Sanitize.Address) { if Bool(c.sanitize.Properties.Sanitize.Address) {
runtimeLibrary = config.AddressSanitizerRuntimeLibrary(toolchain) runtimeLibrary = config.AddressSanitizerRuntimeLibrary(toolchain)
} else if Bool(c.sanitize.Properties.Sanitize.Hwaddress) { } else if Bool(c.sanitize.Properties.Sanitize.Hwaddress) {
if c.staticBinary() { if c.staticBinary() {
runtimeLibrary = config.HWAddressSanitizerStaticLibrary(toolchain) runtimeLibrary = config.HWAddressSanitizerStaticLibrary(toolchain)
extraStaticDeps = []string{"libdl"}
} else { } else {
runtimeLibrary = config.HWAddressSanitizerRuntimeLibrary(toolchain) runtimeLibrary = config.HWAddressSanitizerRuntimeLibrary(toolchain)
} }
@@ -887,7 +889,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{ mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
{Mutator: "link", Variation: "static"}, {Mutator: "link", Variation: "static"},
{Mutator: "image", Variation: c.imageVariation()}, {Mutator: "image", Variation: c.imageVariation()},
}...), staticDepTag, runtimeLibrary) }...), staticDepTag, append([]string{runtimeLibrary}, extraStaticDeps...)...)
} else if !c.static() && !c.header() { } else if !c.static() && !c.header() {
// dynamic executable and shared libs get shared runtime libs // dynamic executable and shared libs get shared runtime libs
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{ mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{

View File

@@ -175,7 +175,7 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
deps.StaticLibs = append(deps.StaticLibs, "libunwind_llvm") deps.StaticLibs = append(deps.StaticLibs, "libunwind_llvm")
} }
if ctx.staticBinary() { if ctx.staticBinary() {
deps.StaticLibs = append(deps.StaticLibs, "libm", "libc", "libdl") deps.StaticLibs = append(deps.StaticLibs, "libm", "libc")
} }
} }
case "": case "":