https://gcc.gnu.org/g:56889bfec25e467deedb2750bdae7ec456a8f92c

commit r16-5592-g56889bfec25e467deedb2750bdae7ec456a8f92c
Author: Rainer Orth <[email protected]>
Date:   Tue Nov 25 22:25:48 2025 +0100

    build: Save/restore CXXFLAGS for zstd tests
    
    I recently encountered a bootstrap failure on trunk caused by the fact
    that an older out-of-tree version of ansidecl.h was found before the
    in-tree one in $top_srcdir/include, so some macros from that header
    that are used in gcc weren't defined.
    
    The out-of-tree version was located in $ZSTD_INC (-I/vol/gcc/include)
    which caused that directory to be included in gcc's CXXFLAGS like
    
    CXXFLAGS='-g -O2 -fchecking=1 -I/vol/gcc/include'
    
    causing it to be searched before $srcdir/../include.
    
    I could trace this to the zstd.h test in gcc/configure.ac which sets
    CXXFLAGS and LDFLAGS before the actual test, but doesn't reset them
    afterwards.
    
    So this patch does just that.
    
    Bootstrapped without regressions on i386-pc-solaris2.11 and
    x86_64-pc-linux-gnu.
    
    2025-10-22  Rainer Orth  <[email protected]>
    
            gcc:
            * configure.ac (gcc_cv_header_zstd_h): Save, restore CXXFLAGS,
            LDFLAGS.
            * configure: Regenerate.

Diff:
---
 gcc/configure    | 9 +++++++--
 gcc/configure.ac | 5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index eba199a85262..d7074355e42b 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -10492,6 +10492,8 @@ if test "x$ZSTD_LIB" != x \
   ZSTD_LDFLAGS=-L$ZSTD_LIB
 fi
 
+saved_CXXFLAGS="$CXXFLAGS"
+saved_LDFLAGS="$LDFLAGS"
 CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS"
 LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS"
 
@@ -10600,6 +10602,9 @@ elif test "x$with_zstd" != x; then
 fi
 fi
 
+CXXFLAGS="$saved_CXXFLAGS"
+LDFLAGS="$saved_LDFLAGS"
+
 
 
 for ac_func in times clock kill getrlimit setrlimit atoq \
@@ -21872,7 +21877,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21875 "configure"
+#line 21880 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21978,7 +21983,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21981 "configure"
+#line 21986 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 598c09761cbc..b6d9608d5994 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1502,6 +1502,8 @@ if test "x$ZSTD_LIB" != x \
   ZSTD_LDFLAGS=-L$ZSTD_LIB
 fi
 
+saved_CXXFLAGS="$CXXFLAGS"
+saved_LDFLAGS="$LDFLAGS"
 CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS"
 LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS"
 
@@ -1533,6 +1535,9 @@ elif test "x$with_zstd" != x; then
 fi
 fi
 
+CXXFLAGS="$saved_CXXFLAGS"
+LDFLAGS="$saved_LDFLAGS"
+
 dnl Disabled until we have a complete test for buggy enum bitfields.
 dnl gcc_AC_C_ENUM_BF_UNSIGNED

Reply via email to