Remove automatic RPATH
authorRichard Levitte <levitte@openssl.org>
Wed, 12 Oct 2016 15:18:11 +0000 (17:18 +0200)
committerRichard Levitte <richard@levitte.org>
Thu, 13 Oct 2016 00:24:40 +0000 (02:24 +0200)
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 <rsalz@openssl.org>
(cherry picked from commit 075f7e2c6062a33352f570eeafe3c95e41419521)

Configurations/unix-Makefile.tmpl
Makefile.shared

index 021f8c1f64f59269e709369426fea86160173a92..85f399616b1f6fa81ad1217551aad09a5d903a82 100644 (file)
@@ -173,20 +173,7 @@ LDFLAGS= {- $target{lflags} -}
 PLIB_LDFLAGS= {- $target{plib_lflags} -}
 EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
 LIB_CFLAGS={- $target{shared_cflag} || "" -}
-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_LDFLAGS=$(LIB_LDFLAGS)
 BIN_CFLAGS={- $target{bin_cflags} -}
index 77dae6e791e33bf9fe89f1950c0de645ac4047bb..e82ed1d956db8548b5c231a9b61f1c48d999cd92 100644 (file)
@@ -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)