On Tue, Apr 1, 2025 at 9:26 AM Iain Sandoe <iains....@gmail.com> wrote: > > Another misconfigure (Darwin-only) found by a combination of increases > in system security contraints and the COBOL runtime. We will now fail > any C++ configure test that needs the binary to run. > > Tested on x86_64-darwin17,21,24 and on x86_64, powerpc64le, aarch64-linux > confirmed manually that the CXX_FOR_TARGET commands are unchanged for Linux. > OK for trunk (and backports)?
OK where necessary - it does only affect darwin so I assume you do the necessary testing there. Thanks, Richard. > thanks, > Iain > > --- 8< --- > > 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> > --- > configure | 100 +++++++++++++++++++++++++++++++++++++++++++++++++-- > configure.ac | 16 +++++++-- > 2 files changed, 112 insertions(+), 4 deletions(-) > > diff --git a/configure b/configure > index 036142a8d06..bf574efd1d8 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 6cf9893cab0..3e120b027e9 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/]) > -- > 2.39.2 (Apple Git-143) >