Skip to content

Commit

Permalink
Config,Darwin: Allow for configuring Darwin to use embedded runpath.
Browse files Browse the repository at this point in the history
Recent Darwin versions place contraints on the use of run paths
specified in environment variables.  This breaks some assumptions
in the GCC build.

This change allows the user to configure a Darwin build to use
'@rpath/libraryname.dylib' in library names and then to add an
embedded runpath to executables (and libraries with dependents).

The embedded runpath is added by default unless the user adds
'-nodefaultrpaths' to the link line.

For an installed compiler, it means that any executable built with
that compiler will reference the runtimes installed with the
compiler (equivalent to hard-coding the library path into the name
of the library).

During build-time configurations  any "-B" entries will be added to
the runpath thus the newly-built libraries will be found by exes.

Since the install name is set in libtool, that decision needs to be
available here (but might also cause dependent ones in Makefiles,
so we need to export a conditional).

This facility is not available for Darwin 8 or earlier, however the
existing environment variable runpath does work there.

We default this on for systems where the external DYLD_LIBRARY_PATH
does not work and off for Darwin 8 or earlier.  For systems that can
use either method, if the value is unset, we use the default (which
is currently DYLD_LIBRARY_PATH).
  • Loading branch information
iains authored and ianlancetaylor committed Jul 12, 2024
1 parent dbb5fd8 commit c5cc931
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 17 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@ PIC_FLAG
WARN_FLAGS
EXTRA_FLAGS
BACKTRACE_FILE
ENABLE_DARWIN_AT_RPATH_FALSE
ENABLE_DARWIN_AT_RPATH_TRUE
OTOOL64
OTOOL
LIPO
Expand Down Expand Up @@ -11393,7 +11395,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11396 "configure"
#line 11398 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
Expand Down Expand Up @@ -11499,7 +11501,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11502 "configure"
#line 11504 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
Expand Down Expand Up @@ -11738,6 +11740,15 @@ CC="$lt_save_CC"
if test x$enable_darwin_at_rpath = xyes; then
ENABLE_DARWIN_AT_RPATH_TRUE=
ENABLE_DARWIN_AT_RPATH_FALSE='#'
else
ENABLE_DARWIN_AT_RPATH_TRUE='#'
ENABLE_DARWIN_AT_RPATH_FALSE=
fi
# Check whether --enable-largefile was given.
if test "${enable_largefile+set}" = set; then :
enableval=$enable_largefile;
Expand Down Expand Up @@ -13662,6 +13673,10 @@ if test -z "${HAVE_DWZ_TRUE}" && test -z "${HAVE_DWZ_FALSE}"; then
as_fn_error $? "conditional \"HAVE_DWZ\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_ELF_TRUE}" && test -z "${HAVE_ELF_FALSE}"; then
as_fn_error $? "conditional \"HAVE_ELF\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
LT_INIT
AM_PROG_LIBTOOL

AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])

AC_SYS_LARGEFILE

backtrace_supported=yes
Expand Down

0 comments on commit c5cc931

Please sign in to comment.