From c5cc931918c330ffed7cfb8cd677bc6ba795a825 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Thu, 11 Jul 2024 18:37:31 -0700 Subject: [PATCH] Config,Darwin: Allow for configuring Darwin to use embedded runpath. 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). --- configure | 19 +++++++++++++++++-- configure.ac | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 6f777b3..3ef87a0 100755 --- a/configure +++ b/configure @@ -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 @@ -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 @@ -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 @@ -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; @@ -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 diff --git a/configure.ac b/configure.ac index 6195366..de95703 100644 --- a/configure.ac +++ b/configure.ac @@ -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