https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127376

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <[email protected]>:

https://gcc.gnu.org/g:84bba23575590b0fcd51094af3a38dd410d0cf69

commit r17-5360-g84bba23575590b0fcd51094af3a38dd410d0cf69
Author: Tamar Christina <[email protected]>
Date:   Mon Oct 19 20:54:17 2026 +0100

    build-system: strip checking flags when compiling GMP to fix LTO bootstrap
[PR127376]

    LTO bootstrap currently fails due to MPFR and GMP failing stage2 vs stage3
    comparison:

      mpfr/src/urandom.o differs
      mpfr/src/urandomb.o differs
      mpfr/src/vasprintf.o differs
      mpfr/src/yn.o differs
      mpfr/src/zeta.o differs
      mpfr/src/zeta_ui.o differs

    of pretty much every object file for mpfr and mpc.

    This is because in Makefile.tpl +579 we have

    STAGE1_TFLAGS += -fno-checking
    STAGE2_CFLAGS += -fno-checking
    STAGE2_TFLAGS += -fno-checking
    STAGE3_CFLAGS += -fchecking=1
    STAGE3_TFLAGS += -fchecking=1

    But with a LTO bootstrap the options leak into the LTO metadata due to the
    headers ending up with the checking flags inside them.

      stage2-gmp/gmp.h:2334  #define __GMP_CC " ... -fno-checking"
      stage3-gmp/gmp.h:2334  #define __GMP_CC " ... -fchecking=1"

    during an LTO bootstrap we call compare-lto which strips the options from
    .gnu.lto_.opts but they're also present in .gnu.lto_.decls.*.

    So we get a miscompare due to -fchecking differences.

    Since MPFR and GMP are C programs just prevent -fno-checking and
-fchecking=1
    from getting passed to them.

    This patch adds a little autogen macro and Scheme function to strip out
these
    flags only for mpfr and gmp.

    Bootstrapped Regtested on aarch64-none-linux-gnu,
    arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
    -m32, -m64

    with:

     - default bootstrap
     - profiledbootstrap
     - LTO bootstrap
     - LTO+O3
     - bootstrap lto locality
     - boostrap LTO lean

    ChangeLog:

            PR bootstrap/127376
            * Makefile.in: Renegerate.
            * Makefile.tpl: Strip checking flags for mpfr and gmp.

Reply via email to