https://gcc.gnu.org/g:8383ac6fcda32c79291a54f01fcdc688f8f832f0

commit r17-5429-g8383ac6fcda32c79291a54f01fcdc688f8f832f0
Author: Kyrylo Tkachov <[email protected]>
Date:   Tue Oct 13 15:05:37 2026 +0200

    build: let configure-gcc start once gmp is configured
    
    configure-gcc waits for gmp, mpfr, mpc and isl to be built.  In a
    bootstrap with the libraries in the tree, each stage builds them first,
    gmp then mpfr and isl then mpc, and gcc/configure, which is serial, can
    only start after all four are done.
    
    gcc/configure needs none of the four libraries built.  It only compiles
    conftests that include system.h, which includes gmp.h, and it does not
    link with GMPLIBS or ISLLIBS.  gmp.h is generated by gmp's configure,
    and mpfr.h and mpc.h are source files.
    
    The dependencies came from two changes:
    
      r0-121281-g458752def198a1 made configure-gcc depend on all-gmp because
      system.h had started to include gmp.h, so the declaration checks in
      gcc/configure failed with an in-tree gmp that was not yet configured.
      configure-gmp is enough for that.
    
      r5-5388-g45c89690541ea6 added all-mpfr, all-mpc and all-isl for the
      isl link test that r5-5495-g797d88589e5ccb then added to
      gcc/configure.  r7-6653-gf877b3adba2d94 removed the last such test.
    
    Make configure-gcc depend on configure-gmp only, as it already depends
    on configure-gettext rather than all-gettext.  Give all-gcc back its
    direct dependency on all-gmp, which it otherwise has only through
    mpfr and isl.
    
    gcc/configure then relies on gmp's configure to create gmp.h.  Check
    that gmp.h can be used before the first test that includes system.h,
    and stop with an error if not.  Without the check, a missing gmp.h
    would only make the declaration checks fail and give a wrong
    auto-host.h.
    
    gcc/configure now runs while the libraries build.  A bootstrap is 7%
    shorter on aarch64 GNU/Linux at -j144 and on x86_64 GNU/Linux at -j128,
    over two pairs of runs on each.  auto-host.h is the same in every
    stage, the stage comparison passes, and the full testsuite does not
    change.  A non-bootstrap build, and one against an external gmp, mpfr
    and mpc, give the same auto-host.h as before.  An in-tree build where
    gmp.h is removed after gmp is configured stops gcc/configure with the
    new error.
    
    ChangeLog:
    
            PR bootstrap/112422
            * Makefile.def (configure-gcc): Depend on configure-gmp rather
            than all-gmp, all-mpfr, all-mpc and all-isl.  Add a comment.
            (all-gcc): Depend on all-gmp.
            * Makefile.in: Regenerate.
    
    gcc/ChangeLog:
    
            PR bootstrap/112422
            * configure.ac: Check that gmp.h can be used.
            * configure: Regenerate.
    
    Signed-off-by: Kyrylo Tkachov <[email protected]>

Diff:
---
 Makefile.def     |  8 ++++----
 Makefile.in      | 60 +++++++++++++++++++-------------------------------------
 gcc/configure    | 32 ++++++++++++++++++++++++++++--
 gcc/configure.ac | 12 ++++++++++++
 4 files changed, 66 insertions(+), 46 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index c31ee798bba0..953af5c7c667 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -370,10 +370,9 @@ dependencies = { module=all-build-libcpp; 
on=all-build-libiberty; };
 
 // Host modules specific to gcc.
 dependencies = { module=configure-gcc; on=configure-gettext; };
-dependencies = { module=configure-gcc; on=all-gmp; };
-dependencies = { module=configure-gcc; on=all-mpfr; };
-dependencies = { module=configure-gcc; on=all-mpc; };
-dependencies = { module=configure-gcc; on=all-isl; };
+// gcc/configure only needs gmp.h, which configure-gmp generates.
+// gcc/configure.ac checks that gmp.h can be used.
+dependencies = { module=configure-gcc; on=configure-gmp; };
 dependencies = { module=configure-gcc; on=all-lto-plugin; };
 dependencies = { module=configure-gcc; on=all-binutils; };
 dependencies = { module=configure-gcc; on=all-gas; };
@@ -383,6 +382,7 @@ dependencies = { module=configure-gcc; on=all-libiconv; };
 dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
 dependencies = { module=all-gcc; on=all-libgrust; };
 dependencies = { module=all-gcc; on=all-gettext; };
+dependencies = { module=all-gcc; on=all-gmp; };
 dependencies = { module=all-gcc; on=all-mpfr; };
 dependencies = { module=all-gcc; on=all-mpc; };
 dependencies = { module=all-gcc; on=all-isl; };
diff --git a/Makefile.in b/Makefile.in
index d9dfdb15874c..0cd434249871 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -68633,46 +68633,16 @@ configure-stagetrain-gcc: 
maybe-configure-stagetrain-gettext
 configure-stagefeedback-gcc: maybe-configure-stagefeedback-gettext
 configure-stageautoprofile-gcc: maybe-configure-stageautoprofile-gettext
 configure-stageautofeedback-gcc: maybe-configure-stageautofeedback-gettext
-configure-gcc: maybe-all-gmp
-configure-stage1-gcc: maybe-all-stage1-gmp
-configure-stage2-gcc: maybe-all-stage2-gmp
-configure-stage3-gcc: maybe-all-stage3-gmp
-configure-stage4-gcc: maybe-all-stage4-gmp
-configure-stageprofile-gcc: maybe-all-stageprofile-gmp
-configure-stagetrain-gcc: maybe-all-stagetrain-gmp
-configure-stagefeedback-gcc: maybe-all-stagefeedback-gmp
-configure-stageautoprofile-gcc: maybe-all-stageautoprofile-gmp
-configure-stageautofeedback-gcc: maybe-all-stageautofeedback-gmp
-configure-gcc: maybe-all-mpfr
-configure-stage1-gcc: maybe-all-stage1-mpfr
-configure-stage2-gcc: maybe-all-stage2-mpfr
-configure-stage3-gcc: maybe-all-stage3-mpfr
-configure-stage4-gcc: maybe-all-stage4-mpfr
-configure-stageprofile-gcc: maybe-all-stageprofile-mpfr
-configure-stagetrain-gcc: maybe-all-stagetrain-mpfr
-configure-stagefeedback-gcc: maybe-all-stagefeedback-mpfr
-configure-stageautoprofile-gcc: maybe-all-stageautoprofile-mpfr
-configure-stageautofeedback-gcc: maybe-all-stageautofeedback-mpfr
-configure-gcc: maybe-all-mpc
-configure-stage1-gcc: maybe-all-stage1-mpc
-configure-stage2-gcc: maybe-all-stage2-mpc
-configure-stage3-gcc: maybe-all-stage3-mpc
-configure-stage4-gcc: maybe-all-stage4-mpc
-configure-stageprofile-gcc: maybe-all-stageprofile-mpc
-configure-stagetrain-gcc: maybe-all-stagetrain-mpc
-configure-stagefeedback-gcc: maybe-all-stagefeedback-mpc
-configure-stageautoprofile-gcc: maybe-all-stageautoprofile-mpc
-configure-stageautofeedback-gcc: maybe-all-stageautofeedback-mpc
-configure-gcc: maybe-all-isl
-configure-stage1-gcc: maybe-all-stage1-isl
-configure-stage2-gcc: maybe-all-stage2-isl
-configure-stage3-gcc: maybe-all-stage3-isl
-configure-stage4-gcc: maybe-all-stage4-isl
-configure-stageprofile-gcc: maybe-all-stageprofile-isl
-configure-stagetrain-gcc: maybe-all-stagetrain-isl
-configure-stagefeedback-gcc: maybe-all-stagefeedback-isl
-configure-stageautoprofile-gcc: maybe-all-stageautoprofile-isl
-configure-stageautofeedback-gcc: maybe-all-stageautofeedback-isl
+configure-gcc: maybe-configure-gmp
+configure-stage1-gcc: maybe-configure-stage1-gmp
+configure-stage2-gcc: maybe-configure-stage2-gmp
+configure-stage3-gcc: maybe-configure-stage3-gmp
+configure-stage4-gcc: maybe-configure-stage4-gmp
+configure-stageprofile-gcc: maybe-configure-stageprofile-gmp
+configure-stagetrain-gcc: maybe-configure-stagetrain-gmp
+configure-stagefeedback-gcc: maybe-configure-stagefeedback-gmp
+configure-stageautoprofile-gcc: maybe-configure-stageautoprofile-gmp
+configure-stageautofeedback-gcc: maybe-configure-stageautofeedback-gmp
 configure-gcc: maybe-all-lto-plugin
 configure-stage1-gcc: maybe-all-stage1-lto-plugin
 configure-stage2-gcc: maybe-all-stage2-lto-plugin
@@ -68763,6 +68733,16 @@ all-stagetrain-gcc: maybe-all-stagetrain-gettext
 all-stagefeedback-gcc: maybe-all-stagefeedback-gettext
 all-stageautoprofile-gcc: maybe-all-stageautoprofile-gettext
 all-stageautofeedback-gcc: maybe-all-stageautofeedback-gettext
+all-gcc: maybe-all-gmp
+all-stage1-gcc: maybe-all-stage1-gmp
+all-stage2-gcc: maybe-all-stage2-gmp
+all-stage3-gcc: maybe-all-stage3-gmp
+all-stage4-gcc: maybe-all-stage4-gmp
+all-stageprofile-gcc: maybe-all-stageprofile-gmp
+all-stagetrain-gcc: maybe-all-stagetrain-gmp
+all-stagefeedback-gcc: maybe-all-stagefeedback-gmp
+all-stageautoprofile-gcc: maybe-all-stageautoprofile-gmp
+all-stageautofeedback-gcc: maybe-all-stageautofeedback-gmp
 all-gcc: maybe-all-mpfr
 all-stage1-gcc: maybe-all-stage1-mpfr
 all-stage2-gcc: maybe-all-stage2-mpfr
diff --git a/gcc/configure b/gcc/configure
index 69efa53e31e0..93a1a63d5aa8 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -12284,6 +12284,34 @@ CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include 
$GMPINC"
 saved_CXXFLAGS="$CXXFLAGS"
 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.
+{ $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.  */
+#include <gmp.h>
+int
+main ()
+{
+mpz_t x; mpz_init (x);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+   as_fn_error $? "cannot compile with gmp.h using GMPINC ($GMPINC).
+An in-tree gmp must create gmp.h when it is configured." "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 # gcc_AC_CHECK_DECLS doesn't support overloaded functions, so use the
 # normal autoconf function for these.  But force definition of
 # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre
@@ -22067,7 +22095,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 22070 "configure"
+#line 22098 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22173,7 +22201,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 22176 "configure"
+#line 22204 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index ad789cb860c2..36a8e52fee23 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1572,6 +1572,18 @@ CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include 
$GMPINC"
 saved_CXXFLAGS="$CXXFLAGS"
 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.
+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_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)
+   AC_MSG_ERROR([cannot compile with gmp.h using GMPINC ($GMPINC).
+An in-tree gmp must create gmp.h when it is configured.])])
+
 # gcc_AC_CHECK_DECLS doesn't support overloaded functions, so use the
 # normal autoconf function for these.  But force definition of
 # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre

Reply via email to