https://gcc.gnu.org/g:e30b1f37f3abcd52ff98971b265f2104eb34f520

commit r17-6635-ge30b1f37f3abcd52ff98971b265f2104eb34f520
Author: Kyrylo Tkachov <[email protected]>
Date:   Tue Nov 24 08:17:29 2026 +0100

    build: Skip the gmp.h check in the build-machine configure [PR128972]
    
    PR128972 reports that gcc/configure stops with "cannot compile with gmp.h
    using GMPINC ()" when a cross compiler builds a native compiler, that is
    when host != build.
    
    When host != build, gcc/configure runs a nested configure for the build
    machine.  The nested run clears GMPINC and defines GENERATOR_FILE so that
    system.h does not include gmp.h and the build compiler does not need gmp
    headers.  The "whether gmp.h can be used" check added by commit 8383ac6fcda
    includes gmp.h unconditionally.  In the nested run it therefore looks for
    gmp.h on the build machine with no -I flag, and fails if the build
    machine has no gmp development headers installed.
    
    Guard the check with GENERATOR_FILE in the same way as system.h.  The
    nested configure no longer tests gmp.h, and the host run still stops
    with the error if gmp.h cannot be used.
    
    Tested the generated configure with GMPINC unset and CPPFLAGS set to
    -DGENERATOR_FILE on a machine without gmp.h in the default include path.
    The old configure stops at the gmp.h check, the new one passes it.  Without
    GENERATOR_FILE the new configure still stops with the error.
    
    gcc/ChangeLog:
    
            PR bootstrap/128972
            * configure.ac: Skip the gmp.h check when GENERATOR_FILE is defined.
            * configure: Regenerate.
    
    Signed-off-by: Kyrylo Tkachov <[email protected]>

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

diff --git a/gcc/configure b/gcc/configure
index e45605b73404..d5cbd92f8918 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -12251,16 +12251,22 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} 
-I${srcdir}/../include $GMPINC"
 # The declaration checks include system.h, which includes gmp.h.  An
 # in-tree gmp is only configured, not built, when this script runs (see
 # configure-gcc in ../Makefile.def), so gmp.h must come from its
-# configure.  Stop here if gmp.h cannot be used.
+# configure.  Stop here if gmp.h cannot be used.  Like system.h, skip
+# the check when GENERATOR_FILE is defined, as it is in the nested
+# configure for the build machine, which must not use gmp.h.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gmp.h can be used" 
>&5
 $as_echo_n "checking whether gmp.h can be used... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
+#ifndef GENERATOR_FILE
 #include <gmp.h>
+#endif
 int
 main ()
 {
+#ifndef GENERATOR_FILE
 mpz_t x; mpz_init (x);
+#endif
   ;
   return 0;
 }
@@ -22059,7 +22065,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 22062 "configure"
+#line 22068 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22165,7 +22171,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 22168 "configure"
+#line 22174 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 490083859244..e5eb428b38ac 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1563,10 +1563,16 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include 
$GMPINC"
 # The declaration checks include system.h, which includes gmp.h.  An
 # in-tree gmp is only configured, not built, when this script runs (see
 # configure-gcc in ../Makefile.def), so gmp.h must come from its
-# configure.  Stop here if gmp.h cannot be used.
+# configure.  Stop here if gmp.h cannot be used.  Like system.h, skip
+# the check when GENERATOR_FILE is defined, as it is in the nested
+# configure for the build machine, which must not use gmp.h.
 AC_MSG_CHECKING([whether gmp.h can be used])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]],
-                                  [[mpz_t x; mpz_init (x);]])],
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifndef GENERATOR_FILE
+#include <gmp.h>
+#endif]],
+                                  [[#ifndef GENERATOR_FILE
+mpz_t x; mpz_init (x);
+#endif]])],
   [AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)
    AC_MSG_ERROR([cannot compile with gmp.h using GMPINC ($GMPINC).

Reply via email to