From 075f7e2c6062a33352f570eeafe3c95e41419521 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 12 Oct 2016 17:18:11 +0200 Subject: [PATCH] Remove automatic RPATH Before OpenSSL 1.1.0, binaries were installed in a non-standard location by default, and runpath directories were therefore added in those binaries, to make sure the executables would be able to find the shared libraries they were linked with. With OpenSSL 1.1.0 and on, binaries are installed in standard directories by default, and the addition of runpath directories is therefore not needed any more. Reviewed-by: Rich Salz --- Configurations/unix-Makefile.tmpl | 15 +-------------- Makefile.shared | 14 +++++++------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 7f6caea17f..e7dcfae6a5 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -176,20 +176,7 @@ PLIB_LDFLAGS= {- $target{plib_lflags} -} EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -} LIB_CFLAGS={- $target{shared_cflag} || "" -} LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -} -LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} - # Unlike other OSes (like Solaris, Linux, Tru64, - # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD - # and FreeBSD) "demand" RPATH set on .so objects. - # Apparently application RPATH is not global and - # does not apply to .so linked with other .so. - # Problem manifests itself when libssl.so fails to - # load libcrypto.so. One can argue that we should - # engrave this into Makefile.shared rules or into - # BSD-* config lines above. Meanwhile let's try to - # be cautious and pass -rpath to linker only when - # $prefix is not /usr. - . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$| - ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -} +LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -} DSO_CFLAGS={- $target{shared_cflag} || "" -} DSO_CXXFLAGS={- $target{shared_cxxflag} || "" -} DSO_LDFLAGS=$(LIB_LDFLAGS) diff --git a/Makefile.shared b/Makefile.shared index 77dae6e791..e82ed1d956 100644 --- a/Makefile.shared +++ b/Makefile.shared @@ -176,7 +176,7 @@ DO_GNU_SO=\ ALLSYMSFLAGS='-Wl,--whole-archive'; \ NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ $(DO_GNU_SO_COMMON) -DO_GNU_APP=LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)" +DO_GNU_APP=LDFLAGS="$(CFLAGS) $(LDFLAGS)" #This is rather special. It's a special target with which one can link #applications without bothering with any features that have anything to @@ -220,7 +220,7 @@ link_shlib.bsd: fi; $(LINK_SO_SHLIB) link_app.bsd: @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \ - LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBPATH)"; \ + LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \ fi; $(LINK_APP) # For Darwin AKA Mac OS/X (dyld) @@ -352,7 +352,7 @@ link_app.alpha-osf1: @if $(DETECT_GNU_LD); then \ $(DO_GNU_APP); \ else \ - LDFLAGS="$(CFLAGS) $(LDFLAGS) -rpath $(LIBRPATH)"; \ + LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \ fi; \ $(LINK_APP) @@ -385,7 +385,7 @@ link_app.solaris: @ if $(DETECT_GNU_LD); then \ $(DO_GNU_APP); \ else \ - LDFLAGS="$(CFLAGS) $(LDFLAGS) -R $(LIBRPATH)"; \ + LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \ fi; \ $(LINK_APP) @@ -476,7 +476,7 @@ link_shlib.irix: fi; \ $(LINK_SO_SHLIB) link_app.irix: - @LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"; \ + @LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \ $(LINK_APP) # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so @@ -514,7 +514,7 @@ link_shlib.hpux: $(LINK_SO_SHLIB) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX link_app.hpux: @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \ - LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \ + LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:"; \ fi; \ $(LINK_APP) @@ -540,7 +540,7 @@ link_shlib.aix: rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SOVER 2>&1 > /dev/null ; \ $(LINK_SO_SHLIB_VIA_O) link_app.aix: - LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \ + LDFLAGS="$(CFLAGS) -Wl,-bsvr4 $(LDFLAGS)"; \ $(LINK_APP) -- 2.34.1