From d30a1d0dfdc6debb8fd113bb86fce2a5e43329f4 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Mon, 20 Jul 2026 16:41:46 +0200 Subject: [PATCH 1/5] gcc: add version 16.1.0 Co-Authored-By: Claude Opus 4.8 --- gcc-16.1.0-0.build.sh | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 gcc-16.1.0-0.build.sh diff --git a/gcc-16.1.0-0.build.sh b/gcc-16.1.0-0.build.sh new file mode 100755 index 0000000..c8ed8cc --- /dev/null +++ b/gcc-16.1.0-0.build.sh @@ -0,0 +1,76 @@ +#! /bin/bash + +# Note: Depending on the value in /proc/sys/vm/overcommit_memory (0|2) +# results of make check differ, but neither one succeeds. + +PKG=gcc +VERSION=16.1.0 +BUILD=0 +# URL=https://ftp.gnu.org/gnu/gcc/gcc-${VERSION}/gcc-${VERSION}.tar.gz +URL=https://beehive.molgen.mpg.de/a2a3608820463d4c33a0ed03936e2e3c/gcc-16.1.0.tar.gz + +PREFIX=/pkg/$PKG-$VERSION-$BUILD +if [ -n "$TESTING" ]; then PREFIX=/dev/shm/$PKG-$VERSION-$BUILD ; fi + +set -xe +umask 022 + +BUILD_TMPDIR=/dev/shm/$PKG-$VERSION-$BUILD.build.tmp +test -d $BUILD_TMPDIR && ( chmod -R u+rwx $BUILD_TMPDIR || true ; rm -rf $BUILD_TMPDIR ) +mkdir -p $BUILD_TMPDIR/home +export TMPDIR=$BUILD_TMPDIR +export HOME=$BUILD_TMPDIR/home + +exec $PREFIX/profile <<-EOF + PATH=$PREFIX/bin:\$PATH + export LD_LIBRARY_PATH=$PREFIX/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH} + if [ -d $PREFIX/.compatlibs ]; then export LD_LIBRARY_PATH=$PREFIX/.compatlibs\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH} ; fi +EOF +. $PREFIX/profile + +NPROC=$(( $(nproc) * 4 / 5 + 1 )) +export MAKEFLAGS="-j $NPROC" + +BUILDDIR=$PREFIX/build + +mkdir -p $BUILDDIR +cd $BUILDDIR + +test -e gcc-${VERSION}.tar.gz || wget --no-verbose $URL +test -d gcc-$VERSION || tar xvf gcc-${VERSION}.tar.gz +cd gcc-$VERSION +mkdir -p objdir +cd objdir +# Note on languages: go and lto are not part of the mpi default install, +# here they are enabled just for testing/fun +$BUILDDIR/gcc-$VERSION/configure \ + --prefix=$PREFIX \ + --enable-shared \ + --enable-threads=posix \ + --enable-__cxa_atexit \ + --enable-clocale=gnu \ + --enable-languages=c,fortran,c++,objc,obj-c++,go,lto \ + --disable-multilib \ + --with-system-zlib \ + --with-diagnostics-color=auto-if-env + +make +# /dev/shm/gcc-8.4.0-0/build/gcc-8.4.0/objdir/check.log +make -k check |& tee check.log +make install + +cd $PREFIX +mkdir -vp lib +ln -sfv ${PREFIX}/bin/cpp lib/ +ln -sfv gcc bin/cc + +install -v -dm755 lib/bfd-plugins +ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/$VERSION/liblto_plugin.so lib/bfd-plugins/ + +# and dump these ... +rm -v lib64/*-gdb.py + +exit From 543bfbae0d2e78cef6bfa0ff6f2d95738049b30e Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Mon, 20 Jul 2026 17:09:53 +0200 Subject: [PATCH 2/5] gcc-16.1.0-0: Serialize linking to reduce memory pressure With NPROC ~= 205 on the 256-core build nodes the final links of the per-language compilers run concurrently and thrash memory (see the overcommit note at the top of the script). --enable-link-serialization=1 serializes those large link steps while leaving compilation parallel. Co-Authored-By: Claude Opus 4.8 --- gcc-16.1.0-0.build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc-16.1.0-0.build.sh b/gcc-16.1.0-0.build.sh index c8ed8cc..f7e464a 100755 --- a/gcc-16.1.0-0.build.sh +++ b/gcc-16.1.0-0.build.sh @@ -53,6 +53,7 @@ $BUILDDIR/gcc-$VERSION/configure \ --enable-__cxa_atexit \ --enable-clocale=gnu \ --enable-languages=c,fortran,c++,objc,obj-c++,go,lto \ + --enable-link-serialization=1 \ --disable-multilib \ --with-system-zlib \ --with-diagnostics-color=auto-if-env From 24b4ffd5d98824dd2c7591e7b742a71545930a36 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Mon, 20 Jul 2026 17:10:09 +0200 Subject: [PATCH 3/5] gcc-16.1.0-0: LTO-optimize the compiler via bootstrap-lto Builds the stage2/stage3 compiler binaries with LTO on top of the default 3-stage bootstrap, yielding a faster installed gcc at the cost of longer build time. Worth it for a compiler installed once and used institute-wide. Co-Authored-By: Claude Opus 4.8 --- gcc-16.1.0-0.build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc-16.1.0-0.build.sh b/gcc-16.1.0-0.build.sh index f7e464a..8c0dc46 100755 --- a/gcc-16.1.0-0.build.sh +++ b/gcc-16.1.0-0.build.sh @@ -55,6 +55,7 @@ $BUILDDIR/gcc-$VERSION/configure \ --enable-languages=c,fortran,c++,objc,obj-c++,go,lto \ --enable-link-serialization=1 \ --disable-multilib \ + --with-build-config=bootstrap-lto \ --with-system-zlib \ --with-diagnostics-color=auto-if-env From a873de024cbce4561c368f52492b9ab03453095d Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Mon, 20 Jul 2026 17:10:22 +0200 Subject: [PATCH 4/5] gcc-16.1.0-0: Enable the Rust front end (gccrs) Adds rust to --enable-languages. Note gccrs is experimental and its build requires rustc and cargo present on the build host; if those are missing (or too old) the build will fail and this commit can be reverted. Co-Authored-By: Claude Opus 4.8 --- gcc-16.1.0-0.build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc-16.1.0-0.build.sh b/gcc-16.1.0-0.build.sh index 8c0dc46..4e40609 100755 --- a/gcc-16.1.0-0.build.sh +++ b/gcc-16.1.0-0.build.sh @@ -52,7 +52,7 @@ $BUILDDIR/gcc-$VERSION/configure \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-clocale=gnu \ - --enable-languages=c,fortran,c++,objc,obj-c++,go,lto \ + --enable-languages=c,fortran,c++,objc,obj-c++,go,lto,rust \ --enable-link-serialization=1 \ --disable-multilib \ --with-build-config=bootstrap-lto \ From 6dac0c674f046d4fb3f1664993a4295dfae7f60b Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Tue, 4 Aug 2026 09:52:06 +0200 Subject: [PATCH 5/5] gcc-16.1.0-0: Use bootstrap-lto-lean instead of bootstrap-lto bootstrap-lto fails the stage2/stage3 bootstrap comparison: Comparing stages 2 and 3 Bootstrap comparison failure! gcc/rust/rust-desugar-apit.o differs gcc/tree-ssa-sccvn.o differs make[2]: *** [Makefile:29036: compare] Error 1 make[2]: Leaving directory '/pkg/gcc-16.1.0-0/build/gcc-16.1.0/objdir' make[1]: *** [Makefile:29016: stage3-bubble] Error 2 make[1]: Leaving directory '/pkg/gcc-16.1.0-0/build/gcc-16.1.0/objdir' make: *** [Makefile:1140: all] Error 2 Full log: /scratch/tmp/gcc-16.1.0-0.build.log The Rust front end is not at fault -- tree-ssa-sccvn.o is core middle end. Analysis of the two objects left behind in objdir shows the mismatch is confined to data that only exists in slim LTO objects. Both have an identical list of 439 sections and all per-function GIMPLE body streams are byte identical; only the IPA summary streams differ: section stage2 stage3 .gnu.lto_.jmpfuncs 0x4018 0x401d .gnu.lto_.ipa_modref 0x1bdb 0x1bcb .gnu.lto_.decls 0x4a59a 0x4a76b .gnu.lto_.opts 0xe7 0xe6 The .opts difference is a red herring. objdir/Makefile:620,622 builds stage2 with -fno-checking and stage3 with -fchecking=1 to avoid redundant IL verification, and that flag is recorded in .gnu.lto_.opts, which is why bootstrap-lto uses contrib/compare-lto (it strips that section) rather than cmp. Recompiling gcc/tree-ssa-sccvn.cc twice with the same stage2 compiler, varying only that flag, yields objects that differ solely in .gnu.lto_.opts, and compare-lto passes. So the summary stream difference is real, not a comparison artefact. Code generation itself agrees. Compiling the same file with the stage1 and the stage2 compiler without -flto gives byte identical .text, .rodata and .data. The stage1 and stage2 compilers thus emit the same machine code and the same GIMPLE, and disagree only on IPA jump function and modref summaries -- layout sensitive ordering exposed because the stage2 compiler is itself LTO and IPA optimised while stage1 is not. A plain bootstrap would compare clean; the failure is an artefact of LTO-compiling stage2. bootstrap-lto-lean avoids this. config/bootstrap-lto-lean.mk adds -flto=jobserver to STAGE3_CFLAGS only, so stage1 and stage2 stay non-LTO, and it sets do-compare = /bin/true because plain stage2 objects can never compare equal to slim LTO stage3 objects anyway. The STAGEtrain_*/STAGEfeedback_* lines in that file apply to profiledbootstrap only and are inert here. Since all depends on stage3-bubble, stage3 is the final stage and is what make install installs, so the installed compiler is still LTO optimised -- the full benefit of commit 24b4ffd5d988 is kept, at one LTO pass instead of two. What is given up is the stage2/stage3 self check, which bootstrap-lto could not deliver here in any case; make check remains the validation. Neither config LTO-optimises the target libraries, as both touch only *_CFLAGS and not *_TFLAGS. The underlying nondeterminism in IPA summary streaming under an LTO bootstrap looks worth reporting upstream. Co-Authored-By: Claude Opus 5 --- gcc-16.1.0-0.build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc-16.1.0-0.build.sh b/gcc-16.1.0-0.build.sh index 4e40609..c08fb90 100755 --- a/gcc-16.1.0-0.build.sh +++ b/gcc-16.1.0-0.build.sh @@ -55,7 +55,7 @@ $BUILDDIR/gcc-$VERSION/configure \ --enable-languages=c,fortran,c++,objc,obj-c++,go,lto,rust \ --enable-link-serialization=1 \ --disable-multilib \ - --with-build-config=bootstrap-lto \ + --with-build-config=bootstrap-lto-lean \ --with-system-zlib \ --with-diagnostics-color=auto-if-env