diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-03-30 17:35:50 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2016-03-31 00:00:02 -0700 |
commit | d30e610ef24425596d1787755b6f952bb04b6c1d (patch) | |
tree | 715034a1f8e947536db74e4d5654546b92caa951 | |
parent | e71749280e895d588a229ba5a64fc8a4f5a71a85 (diff) | |
download | build_soong-d30e610ef24425596d1787755b6f952bb04b6c1d.tar.gz build_soong-d30e610ef24425596d1787755b6f952bb04b6c1d.tar.bz2 build_soong-d30e610ef24425596d1787755b6f952bb04b6c1d.zip |
Move runpaths out of global ldflags
The make macros add these to the linker lines even if the default
compiler flags are being skipped.
This also allows us to add another runpath for test binaries, which are
currently being installed in:
<out>/host/linux-x86/nativetest[64]/<test>/<binary>
So they need to use ../../lib[64] as a rpath.
Change-Id: Ia7e954cdf63bc627a8f71d01c953530355c248ab
-rw-r--r-- | cc/cc.go | 31 | ||||
-rw-r--r-- | cc/x86_darwin_host.go | 4 | ||||
-rw-r--r-- | cc/x86_linux_host.go | 4 |
3 files changed, 30 insertions, 9 deletions
@@ -1086,9 +1086,17 @@ type baseLinker struct { VariantIsStatic bool `blueprint:"mutated"` VariantIsStaticBinary bool `blueprint:"mutated"` } + + runPaths []string } -func (linker *baseLinker) begin(ctx BaseModuleContext) {} +func (linker *baseLinker) begin(ctx BaseModuleContext) { + if ctx.toolchain().Is64Bit() { + linker.runPaths = []string{"../lib64", "lib64"} + } else { + linker.runPaths = []string{"../lib", "lib"} + } +} func (linker *baseLinker) props() []interface{} { return []interface{}{&linker.Properties, &linker.dynamicProperties} @@ -1152,6 +1160,17 @@ func (linker *baseLinker) flags(ctx ModuleContext, flags Flags) Flags { } } + if ctx.Host() && !linker.static() { + rpath_prefix := `\$$ORIGIN/` + if ctx.Darwin() { + rpath_prefix = "@loader_path/" + } + + for _, rpath := range linker.runPaths { + flags.LdFlags = append(flags.LdFlags, "-Wl,-rpath,"+rpath_prefix+rpath) + } + } + if flags.Clang { flags.LdFlags = append(flags.LdFlags, toolchain.ToolchainClangLdflags()) } else { @@ -1781,6 +1800,16 @@ type testLinker struct { Properties TestLinkerProperties } +func (test *testLinker) begin(ctx BaseModuleContext) { + test.binaryLinker.begin(ctx) + + runpath := "../../lib" + if ctx.toolchain().Is64Bit() { + runpath += "64" + } + test.runPaths = append([]string{runpath}, test.runPaths...) +} + func (test *testLinker) props() []interface{} { return append(test.binaryLinker.props(), &test.Properties) } diff --git a/cc/x86_darwin_host.go b/cc/x86_darwin_host.go index 87e50b06..559a9a51 100644 --- a/cc/x86_darwin_host.go +++ b/cc/x86_darwin_host.go @@ -57,14 +57,10 @@ var ( darwinX86Ldflags = []string{ "-m32", - "-Wl,-rpath,@loader_path/../lib", - "-Wl,-rpath,@loader_path/lib", } darwinX8664Ldflags = []string{ "-m64", - "-Wl,-rpath,@loader_path/../lib64", - "-Wl,-rpath,@loader_path/lib64", } darwinClangCflags = append(clangFilterUnknownCflags(darwinCflags), []string{ diff --git a/cc/x86_linux_host.go b/cc/x86_linux_host.go index e05d2a52..e33862d3 100644 --- a/cc/x86_linux_host.go +++ b/cc/x86_linux_host.go @@ -56,14 +56,10 @@ var ( linuxX86Ldflags = []string{ "-m32", - `-Wl,-rpath,\$$ORIGIN/../lib`, - `-Wl,-rpath,\$$ORIGIN/lib`, } linuxX8664Ldflags = []string{ "-m64", - `-Wl,-rpath,\$$ORIGIN/../lib64`, - `-Wl,-rpath,\$$ORIGIN/lib64`, } linuxClangCflags = append(clangFilterUnknownCflags(linuxCflags), []string{ |