https://gcc.gnu.org/g:17ed44c96f6e5c0cc02d8cb29ff5943dd30ab3c1
commit r15-9151-g17ed44c96f6e5c0cc02d8cb29ff5943dd30ab3c1 Author: Iain Sandoe <i...@sandoe.co.uk> Date: Mon Mar 31 07:02:54 2025 +0100 config, toplevel, Darwin: Pass -B instead of -L to C++ commands. Darwin from 10.11 needs embedded rpaths to find the correct libraries at runtime. Recent increases in hardening have made it such that the dynamic loader will no longer fall back to using an installed libstdc++ when the (new) linked one is not found. This means we fail configure tests (that should pass) for runtimes that use C++. We can resolve this by passing '-B' to the C++ command lines instead of '-L' (-B implies -L on Darwin, but also causes a corresponding embedded rpath). ChangeLog: * configure: Regenerate. * configure.ac: Use -B instead of -L to specifiy the C++ runtime paths on Darwin. Signed-off-by: Iain Sandoe <i...@sandoe.co.uk> Diff: --- configure | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 16 ++++++++-- 2 files changed, 112 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 036142a8d061..bf574efd1d82 100755 --- a/configure +++ b/configure @@ -19081,7 +19081,101 @@ $as_echo "pre-installed" >&6; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target c++" >&5 +case $target in + *-*-darwin*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target c++" >&5 +$as_echo_n "checking where to find the target c++... " >&6; } +if test "x${build}" != "x${host}" ; then + if expr "x$CXX_FOR_TARGET" : "x/" > /dev/null; then + # We already found the complete path + ac_dir=`dirname $CXX_FOR_TARGET` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5 +$as_echo "pre-installed in $ac_dir" >&6; } + else + # Canadian cross, just use what we found + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5 +$as_echo "pre-installed" >&6; } + fi +else + ok=yes + case " ${configdirs} " in + *" gcc "*) ;; + *) ok=no ;; + esac + case ,${enable_languages}, in + *,c++,*) ;; + *) ok=no ;; + esac + if test $ok = yes; then + # An in-tree tool is available and we can use it + CXX_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/xg++ -B$$r/$(HOST_SUBDIR)/gcc/ -nostdinc++ `if test -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags; then $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes; else echo -funconfigured-libstdc++-v3 ; fi` -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: just compiled" >&5 +$as_echo "just compiled" >&6; } + elif expr "x$CXX_FOR_TARGET" : "x/" > /dev/null; then + # We already found the complete path + ac_dir=`dirname $CXX_FOR_TARGET` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5 +$as_echo "pre-installed in $ac_dir" >&6; } + elif test "x$target" = "x$host"; then + # We can use an host tool + CXX_FOR_TARGET='$(CXX)' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: host tool" >&5 +$as_echo "host tool" >&6; } + else + # We need a cross tool + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5 +$as_echo "pre-installed" >&6; } + fi +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target c++ for libstdc++" >&5 +$as_echo_n "checking where to find the target c++ for libstdc++... " >&6; } +if test "x${build}" != "x${host}" ; then + if expr "x$RAW_CXX_FOR_TARGET" : "x/" > /dev/null; then + # We already found the complete path + ac_dir=`dirname $RAW_CXX_FOR_TARGET` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5 +$as_echo "pre-installed in $ac_dir" >&6; } + else + # Canadian cross, just use what we found + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5 +$as_echo "pre-installed" >&6; } + fi +else + ok=yes + case " ${configdirs} " in + *" gcc "*) ;; + *) ok=no ;; + esac + case ,${enable_languages}, in + *,c++,*) ;; + *) ok=no ;; + esac + if test $ok = yes; then + # An in-tree tool is available and we can use it + RAW_CXX_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: just compiled" >&5 +$as_echo "just compiled" >&6; } + elif expr "x$RAW_CXX_FOR_TARGET" : "x/" > /dev/null; then + # We already found the complete path + ac_dir=`dirname $RAW_CXX_FOR_TARGET` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5 +$as_echo "pre-installed in $ac_dir" >&6; } + elif test "x$target" = "x$host"; then + # We can use an host tool + RAW_CXX_FOR_TARGET='$(CXX)' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: host tool" >&5 +$as_echo "host tool" >&6; } + else + # We need a cross tool + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5 +$as_echo "pre-installed" >&6; } + fi +fi + + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target c++" >&5 $as_echo_n "checking where to find the target c++... " >&6; } if test "x${build}" != "x${host}" ; then if expr "x$CXX_FOR_TARGET" : "x/" > /dev/null; then @@ -19126,7 +19220,7 @@ $as_echo "pre-installed" >&6; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target c++ for libstdc++" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target c++ for libstdc++" >&5 $as_echo_n "checking where to find the target c++ for libstdc++... " >&6; } if test "x${build}" != "x${host}" ; then if expr "x$RAW_CXX_FOR_TARGET" : "x/" > /dev/null; then @@ -19171,6 +19265,8 @@ $as_echo "pre-installed" >&6; } fi fi + ;; +esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target dlltool" >&5 $as_echo_n "checking where to find the target dlltool... " >&6; } if test "x${build}" != "x${host}" ; then diff --git a/configure.ac b/configure.ac index 6cf9893cab07..3e120b027e99 100644 --- a/configure.ac +++ b/configure.ac @@ -4061,12 +4061,24 @@ GCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR, [binutils/ar]) GCC_TARGET_TOOL(as, AS_FOR_TARGET, AS, [gas/as-new]) GCC_TARGET_TOOL(cc, CC_FOR_TARGET, CC, [gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/]) dnl see comments for CXX_FOR_TARGET_FLAG_TO_PASS -GCC_TARGET_TOOL(c++, CXX_FOR_TARGET, CXX, +case $target in + *-*-darwin*) + GCC_TARGET_TOOL(c++, CXX_FOR_TARGET, CXX, + [gcc/xg++ -B$$r/$(HOST_SUBDIR)/gcc/ -nostdinc++ `if test -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags; then $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes; else echo -funconfigured-libstdc++-v3 ; fi` -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs], + c++) + GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX, + [gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -B$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs], + c++) + ;; + *) + GCC_TARGET_TOOL(c++, CXX_FOR_TARGET, CXX, [gcc/xg++ -B$$r/$(HOST_SUBDIR)/gcc/ -nostdinc++ `if test -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags; then $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes; else echo -funconfigured-libstdc++-v3 ; fi` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs], c++) -GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX, + GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX, [gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs], c++) + ;; +esac GCC_TARGET_TOOL(dlltool, DLLTOOL_FOR_TARGET, DLLTOOL, [binutils/dlltool]) GCC_TARGET_TOOL(dsymutil, DSYMUTIL_FOR_TARGET, DSYMUTIL) GCC_TARGET_TOOL(gcc, GCC_FOR_TARGET, , [gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/])