Remove automatic RPATH
authorRichard Levitte <levitte@openssl.org>
Wed, 12 Oct 2016 15:18:11 +0000 (17:18 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 13 Oct 2016 00:21:51 +0000 (02:21 +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>
Configurations/unix-Makefile.tmpl
Makefile.shared

index 7f6caea17f643cc1c7a4306be0abb39f848d19bf..e7dcfae6a571339cff6a8e0c4818d7d67df5e4e7 100644 (file)
@@ -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} || "" -}
 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)
 DSO_CFLAGS={- $target{shared_cflag} || "" -}
 DSO_CXXFLAGS={- $target{shared_cxxflag} || "" -}
 DSO_LDFLAGS=$(LIB_LDFLAGS)
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)
        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
 
 #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 \
        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)
        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 \
        @if $(DETECT_GNU_LD); then \
                $(DO_GNU_APP); \
        else \
-               LDFLAGS="$(CFLAGS) $(LDFLAGS) -rpath $(LIBRPATH)"; \
+               LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
        fi; \
        $(LINK_APP)
 
        fi; \
        $(LINK_APP)
 
@@ -385,7 +385,7 @@ link_app.solaris:
        @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_APP); \
        else \
        @ if $(DETECT_GNU_LD); then \
                $(DO_GNU_APP); \
        else \
-               LDFLAGS="$(CFLAGS) $(LDFLAGS) -R $(LIBRPATH)"; \
+               LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
        fi; \
        $(LINK_APP)
 
        fi; \
        $(LINK_APP)
 
@@ -476,7 +476,7 @@ link_shlib.irix:
        fi; \
        $(LINK_SO_SHLIB)
 link_app.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
        $(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 \
        $(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)
 
        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:
        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)
 
 
        $(LINK_APP)