Skip to content

Commit 0f50c8e

Browse files
avargitster
authored andcommitted
Makefile: remove the NO_R_TO_GCC_LINKER flag
Change our default CC_LD_DYNPATH invocation to something GCC likes these days. Since the GCC 4.6 release unknown flags haven't been passed through to ld(1). Thus our previous default of CC_LD_DYNPATH=-R would cause an error on modern GCC unless NO_R_TO_GCC_LINKER was set. This CC_LD_DYNPATH flag is really obscure, and I don't expect anyone except those working on git development ever use this. It's not needed to simply link to libraries like say libpcre, but *only* for those cases where we're linking to such a library not present in the OS's library directories. See e.g. ldconfig(8) on Linux for more details. I use this to compile my git with a LIBPCREDIR=$HOME/g/pcre2/inst as I'm building that from source, but someone maintaining an OS package is almost certainly not going to use this. They're just going to set USE_LIBPCRE=YesPlease after installing the libpcre dependency, which'll point to OS libraries which ld(1) will find without the help of CC_LD_DYNPATH. Another thing that helps mitigate any potential breakage is that we detect the right type of invocation in configure.ac, which e.g. HP/UX uses[1], as does IBM's AIX package[2]. From what I can tell both AIX and Solaris packagers are building git with GCC, so I'm not adding a corresponding config.mak.uname default to cater to their OS-native linkers. Now for an overview of past development in this area: Our use of "-R" dates back to 455a7f3 ("More portability.", 2005-09-30). Soon after that in bbfc63d ("gcc does not necessarily pass runtime libpath with -R", 2006-12-27) the NO_R_TO_GCC flag was added, allowing optional use of "-Wl,-rpath=". Then in f5b904d ("Makefile: Allow CC_LD_DYNPATH to be overriden", 2008-08-16) the ability to override this flag to something else entirely was added, as some linkers use neither "-Wl,-rpath," nor "-R". From what I can tell we should, with the benefit of hindsight, have made this change back in 2006. GCC & ld supported this type of invocation back then, or since at least binutils-gdb.git's[3] a1ad915dc4 ("[...]Add support for -rpath[...]", 1994-07-20). Further reading and prior art can be found at [4][5][6][7]. Making a plain "-R" an error seems from reading those reports to have been introduced in GCC 4.6 released on March 25, 2011[8], but I couldn't confirm this with absolute certainty, its release notes are ambiguous on the subject, and I couldn't be bothered to try to build & bisect it against GCC 4.5. 1. https://public-inbox.org/git/[email protected]/ 2. https://www.ibm.com/developerworks/aix/library/aix-toolbox/alpha.html 3. git://sourceware.org/git/binutils-gdb.git 4. tsuna/boost.m4#15 5. https://bugzilla.gnome.org/show_bug.cgi?id=641416 6. https://stackoverflow.com/questions/12629042/g-4-6-real-error-unrecognized-option-r 7. https://curl.haxx.se/mail/archive-2014-11/0005.html 8. https://gcc.gnu.org/gcc-4.6/changes.html Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab15ad1 commit 0f50c8e

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

Makefile

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ all::
265265
#
266266
# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
267267
#
268-
# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
269-
# that tells runtime paths to dynamic libraries;
270-
# "-Wl,-rpath=/path/lib" is used instead.
271-
#
272268
# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
273269
# as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
274270
#
@@ -1160,6 +1156,7 @@ endif
11601156
# which'll override these defaults.
11611157
CFLAGS = -g -O2 -Wall
11621158
LDFLAGS =
1159+
CC_LD_DYNPATH = -Wl,-rpath,
11631160
BASIC_CFLAGS = -I.
11641161
BASIC_LDFLAGS =
11651162

@@ -1287,16 +1284,6 @@ ifeq ($(uname_S),Darwin)
12871284
PTHREAD_LIBS =
12881285
endif
12891286

1290-
ifndef CC_LD_DYNPATH
1291-
ifdef NO_R_TO_GCC_LINKER
1292-
# Some gcc does not accept and pass -R to the linker to specify
1293-
# the runtime dynamic library path.
1294-
CC_LD_DYNPATH = -Wl,-rpath,
1295-
else
1296-
CC_LD_DYNPATH = -R
1297-
endif
1298-
endif
1299-
13001287
ifdef NO_LIBGEN_H
13011288
COMPAT_CFLAGS += -DNO_LIBGEN_H
13021289
COMPAT_OBJS += compat/basename.o

0 commit comments

Comments
 (0)