Skip to content

Commit 8fe73ef

Browse files
committed
Darwin, rpaths: Add --with-darwin-extra-rpath.
This is provided to allow distributions to add a single additional runpath to allow for cases where the installed GCC library directories are then symlinked to a common dirctory outside of any of the GCC installations. For example: /opt/distro/lib: libgfortran.dylib -> /opt/distro/lib/gcc-11.3/lib/libgfortran.dylib So that libraries which are designed to be found in the runpath we would then add --with-darwin-add-rpath=/opt/distro/lib to the configure line. This patch makes the configuration a little more forgiving of using --disable-darwin-at-rpath (although for platform versions >= 10.11 this will result in misconfigured target libraries). gcc/ChangeLog: * configure.ac: Add --with-darwin-extra-rpath option. * config/darwin.h: Handle DARWIN_EXTRA_RPATH. * config.in: Regenerate. * configure: Regenerate.
1 parent 6a6d381 commit 8fe73ef

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

gcc/config.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@
4949
#endif
5050

5151

52+
/* Specify a runpath directory, additional to those provided by the compiler
53+
*/
54+
#ifndef USED_FOR_TARGET
55+
#undef DARWIN_ADD_RPATH
56+
#endif
57+
58+
59+
/* Should add an extra runpath directory */
60+
#ifndef USED_FOR_TARGET
61+
#undef DARWIN_DO_EXTRA_RPATH
62+
#endif
63+
64+
5265
/* Define to enable the use of a default assembler. */
5366
#ifndef USED_FOR_TARGET
5467
#undef DEFAULT_ASSEMBLER

gcc/config/darwin.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,19 @@ extern GTY(()) int darwin_ms_struct;
321321
%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) "
322322
#endif
323323

324+
/* We might elect to add a path even when this compiler does not use embedded
325+
run paths, so that we can use libraries from an alternate compiler that is
326+
using embedded runpaths. */
327+
#if DARWIN_DO_EXTRA_RPATH
328+
# define DARWIN_EXTRA_RPATH \
329+
"%{!r:%{!nostdlib:%{!nodefaultrpaths:\
330+
%:version-compare(>= 10.5 mmacosx-version-min= -rpath) \
331+
%:version-compare(>= 10.5 mmacosx-version-min= " DARWIN_ADD_RPATH ") \
332+
}}}"
333+
#else
334+
# define DARWIN_EXTRA_RPATH ""
335+
#endif
336+
324337
#define SUBSUBTARGET_OVERRIDE_OPTIONS \
325338
do { \
326339
darwin_override_options (); \
@@ -415,6 +428,7 @@ extern GTY(()) int darwin_ms_struct;
415428
DARWIN_NOPIE_SPEC \
416429
DARWIN_RDYNAMIC \
417430
DARWIN_NOCOMPACT_UNWIND \
431+
DARWIN_EXTRA_RPATH \
418432
DARWIN_RPATH_LINK \
419433
"}}}}}}} %<pie %<no-pie %<rdynamic %<X %<rpath %<nodefaultrpaths "
420434

gcc/configure

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ with_pic
10121012
enable_fast_install
10131013
enable_libtool_lock
10141014
enable_darwin_at_rpath
1015+
with_darwin_extra_rpath
10151016
enable_ld
10161017
enable_gold
10171018
with_plugin_ld
@@ -1873,6 +1874,9 @@ Optional Packages:
18731874
--with-pic try to use only PIC/non-PIC objects [default=use
18741875
both]
18751876
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
1877+
--with-darwin-extra-rpath=[ARG]
1878+
Specify a runpath directory, additional to those
1879+
provided by the compiler
18761880
--with-plugin-ld=[ARG] specify the plugin linker
18771881
--with-glibc-version=M.N
18781882
assume GCC used with glibc version M.N or later
@@ -19976,7 +19980,7 @@ else
1997619980
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1997719981
lt_status=$lt_dlunknown
1997819982
cat > conftest.$ac_ext <<_LT_EOF
19979-
#line 19979 "configure"
19983+
#line 19983 "configure"
1998019984
#include "confdefs.h"
1998119985

1998219986
#if HAVE_DLFCN_H
@@ -20082,7 +20086,7 @@ else
2008220086
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
2008320087
lt_status=$lt_dlunknown
2008420088
cat > conftest.$ac_ext <<_LT_EOF
20085-
#line 20085 "configure"
20089+
#line 20089 "configure"
2008620090
#include "confdefs.h"
2008720091

2008820092
#if HAVE_DLFCN_H
@@ -23410,6 +23414,26 @@ else
2341023414
ENABLE_DARWIN_AT_RPATH_FALSE=
2341123415
fi
2341223416

23417+
DARWIN_DO_EXTRA_RPATH=0
23418+
23419+
# Check whether --with-darwin-extra-rpath was given.
23420+
if test "${with_darwin_extra_rpath+set}" = set; then :
23421+
withval=$with_darwin_extra_rpath; if test x"$withval" != x; then
23422+
DARWIN_ADD_RPATH="$withval"
23423+
DARWIN_DO_EXTRA_RPATH=1
23424+
fi
23425+
fi
23426+
23427+
23428+
cat >>confdefs.h <<_ACEOF
23429+
#define DARWIN_DO_EXTRA_RPATH $DARWIN_DO_EXTRA_RPATH
23430+
_ACEOF
23431+
23432+
23433+
cat >>confdefs.h <<_ACEOF
23434+
#define DARWIN_ADD_RPATH "$DARWIN_ADD_RPATH"
23435+
_ACEOF
23436+
2341323437

2341423438
# Identify the assembler which will work hand-in-glove with the newly
2341523439
# built GCC, so that we can examine its features. This is the assembler

gcc/configure.ac

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,19 @@ AC_SUBST(objdir)
26332633
AC_SUBST(enable_fast_install)
26342634

26352635
AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
2636+
DARWIN_DO_EXTRA_RPATH=0
2637+
AC_ARG_WITH(darwin-extra-rpath,
2638+
[AS_HELP_STRING(
2639+
[[--with-darwin-extra-rpath=[ARG]]],
2640+
[Specify a runpath directory, additional to those provided by the compiler])],
2641+
[if test x"$withval" != x; then
2642+
DARWIN_ADD_RPATH="$withval"
2643+
DARWIN_DO_EXTRA_RPATH=1
2644+
fi])
2645+
AC_DEFINE_UNQUOTED(DARWIN_DO_EXTRA_RPATH, $DARWIN_DO_EXTRA_RPATH,
2646+
[Should add an extra runpath directory])
2647+
AC_DEFINE_UNQUOTED(DARWIN_ADD_RPATH, "$DARWIN_ADD_RPATH",
2648+
[Specify a runpath directory, additional to those provided by the compiler])
26362649

26372650
# Identify the assembler which will work hand-in-glove with the newly
26382651
# built GCC, so that we can examine its features. This is the assembler

0 commit comments

Comments
 (0)