Re: Linking with -R (rpath) not supported on Darwin

4 messages, 4 authors, 2016-06-15 · open the first message on its own page

Re: Linking with -R (rpath) not supported on Darwin

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:38

Benoit SIGOURE [off-list ref] writes:
It didn't harm but the build process should be more careful to not use
options that are not supported by the compiler.  And it's not a
matter of using -Wl,-rpath instead.
As I do not have an access to a Darwin box (nor anybody sent me
a free Mac yet), I do not have any interest in fixing it myself
nor more importantly any means to verify the result.  That makes
it _your_ build process that should be more careful ;-).

You know where -R is coming from and can find out what options
_your_ platform wants, so why not send in a patch _before_
complaining?

[PATCH] Be nice with compilers that do not support runtime paths at all.

From: Benoit Sigoure <hidden>
Date: 2016-06-15 22:43:38

On Darwin for instance, there is no -R or -Wl,-rpath thing to fiddle with,
it's simply not supported by the dynamic loader.  This patch introduces a
NO_RPATH define which is enabled by default for Darwin.
---
 Makefile |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index a1fe443..7c6c453 100644
--- a/Makefile
+++ b/Makefile
@@ -100,6 +100,9 @@ all::
 # that tells runtime paths to dynamic libraries;
 # "-Wl,-rpath=/path/lib" is used instead.
 #
+# Define NO_RPATH if your dynamic loader doesn't support runtime paths at
+# all.
+#
 # Define USE_NSEC below if you want git to care about sub-second file mtimes
 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
@@ -507,6 +510,7 @@ ifeq ($(uname_S),Darwin)
 			BASIC_LDFLAGS += -L/opt/local/lib
 		endif
 	endif
+        NO_RPATH = YesPlease
 endif
 
 ifdef NO_R_TO_GCC_LINKER
@@ -521,7 +525,10 @@ ifndef NO_CURL
 	ifdef CURLDIR
 		# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
 		BASIC_CFLAGS += -I$(CURLDIR)/include
-		CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) -lcurl
+		CURL_LIBCURL = -L$(CURLDIR)/$(lib) -lcurl
+ifndef NO_RPATH
+		CURL_LIBCURL += $(CC_LD_DYNPATH)$(CURLDIR)/$(lib)
+endif
 	else
 		CURL_LIBCURL = -lcurl
 	endif
@@ -539,7 +546,10 @@ endif
 
 ifdef ZLIB_PATH
 	BASIC_CFLAGS += -I$(ZLIB_PATH)/include
-	EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
+	EXTLIBS += -L$(ZLIB_PATH)/$(lib)
+ifndef NO_RPATH
+	EXTLIBS += $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
+endif
 endif
 EXTLIBS += -lz
 
@@ -547,7 +557,10 @@ ifndef NO_OPENSSL
 	OPENSSL_LIBSSL = -lssl
 	ifdef OPENSSLDIR
 		BASIC_CFLAGS += -I$(OPENSSLDIR)/include
-		OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
+		OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib)
+ifndef NO_RPATH
+		OPENSSL_LINK = $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
+endif
 	else
 		OPENSSL_LINK =
 	endif
@@ -564,7 +577,10 @@ endif
 ifdef NEEDS_LIBICONV
 	ifdef ICONVDIR
 		BASIC_CFLAGS += -I$(ICONVDIR)/include
-		ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
+		ICONV_LINK = -L$(ICONVDIR)/$(lib)
+ifndef NO_RPATH
+		ICONV_LINK = $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
+endif
 	else
 		ICONV_LINK =
 	endif
-- 
1.5.3.4.209.g9e417

Re: [PATCH] Be nice with compilers that do not support runtime paths at all.

From: Steven Grimm <hidden>
Date: 2016-06-15 22:43:38

Benoit Sigoure wrote:
On Darwin for instance, there is no -R or -Wl,-rpath thing to fiddle with,
it's simply not supported by the dynamic loader.  This patch introduces a
NO_RPATH define which is enabled by default for Darwin.
  
I compile git on a MacBook Pro (OS X 10.4, gcc 4.0.1 build 5367 from the 
normal Xcode install that comes on the OS install DVD) on a regular 
basis. The makefile works fine for me. I suspect there's something else 
going on here.

-Steve

Re: [PATCH] Be nice with compilers that do not support runtime paths at all.

From: Brian Gernhardt <hidden>
Date: 2016-06-15 22:43:38

On Oct 3, 2007, at 6:49 PM, Steven Grimm wrote:
Benoit Sigoure wrote:
quoted
On Darwin for instance, there is no -R or -Wl,-rpath thing to  
fiddle with,
it's simply not supported by the dynamic loader.  This patch  
introduces a
NO_RPATH define which is enabled by default for Darwin.
I compile git on a MacBook Pro (OS X 10.4, gcc 4.0.1 build 5367  
from the normal Xcode install that comes on the OS install DVD) on  
a regular basis. The makefile works fine for me. I suspect there's  
something else going on here.
The rpath code is only used if you define one of the following options:

CURLDIR
ZLIB_PATH
OPENSSLDIR
ICONVDIR

The default Darwin options don't define any of these, it just relies  
on finding those libraries in the library path (including /sw or /opt/ 
local if you have them installed).

~~ Brian G.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help