From 69e8b6be0e2fddb4cc07fe929559c73072d5a749 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 17 Aug 2026 17:36:09 +0200 Subject: [PATCH 01/13] Add missing `--with-as` and `--with-ld` gcc config options --- src/ci/docker/scripts/build-gcc.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 6a96b82d3f924..c0f4f296ce577 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -43,6 +43,8 @@ hide_output ../gcc-$GCC/configure \ --prefix=/rustroot \ --enable-languages=c,c++ \ --disable-gnu-unique-object \ + --with-as="$BINUTILS_PATH/as" \ + --with-ld="$BINUTILS_PATH/ld" \ --enable-cxx-flags='-fno-reorder-blocks-and-partition' hide_output make -j$(nproc) hide_output make install From 708ce38e0c1a7af6d72ce905275559bf66501582 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 17 Aug 2026 23:20:43 +0200 Subject: [PATCH 02/13] Add newer binutils into the path when running cg_gcc tests --- src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index f2f78b04d7787..b0cd2d809ba03 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -16,7 +16,7 @@ python3 ../x.py build --set rust.debug=true opt-dist # Use GCC for building GCC components, as it seems to behave badly when built with Clang # Only build GCC on full builds, not try builds if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then - CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist \ + PATH="$BINUTILS_PATH":$PATH CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist \ gcc-dev \ gcc fi From 64d50bde95e3a50f790cfc34aa00df9792a6795a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 18 Aug 2026 00:17:13 +0200 Subject: [PATCH 03/13] Only build libgccjit with newer binutils --- src/ci/docker/scripts/build-gcc.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index c0f4f296ce577..6a96b82d3f924 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -43,8 +43,6 @@ hide_output ../gcc-$GCC/configure \ --prefix=/rustroot \ --enable-languages=c,c++ \ --disable-gnu-unique-object \ - --with-as="$BINUTILS_PATH/as" \ - --with-ld="$BINUTILS_PATH/ld" \ --enable-cxx-flags='-fno-reorder-blocks-and-partition' hide_output make -j$(nproc) hide_output make install From 6763ffb03158a653c24ad238e69540149d6106d3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 18 Aug 2026 11:59:14 +0200 Subject: [PATCH 04/13] Move binutils new version download into `dist.sh` --- .../host-x86_64/dist-x86_64-linux/dist.sh | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index b0cd2d809ba03..2705e6e0af61c 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -16,6 +16,29 @@ python3 ../x.py build --set rust.debug=true opt-dist # Use GCC for building GCC components, as it seems to behave badly when built with Clang # Only build GCC on full builds, not try builds if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then + # We have to build our own binutils for the GCC build, because the default CentOS 7 binutils are + # too old, and they do not support `SHF_GNU_RETAIN`. + BINUTILS="2.47" + BINUTILS_ROOT_PATH="/binutils-install" + export BINUTILS_PATH="$BINUTILS_ROOT_PATH/bin" + curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - + mkdir binutils-build + mkdir "$BINUTILS_ROOT_PATH" + cd binutils-build + hide_output ../binutils-$BINUTILS/configure --prefix="$BINUTILS_ROOT_PATH" + hide_output make -j$(nproc) + hide_output make install + + cd .. + rm -rf binutils-build binutils-$BINUTILS + + if echo '.section .test,"awR",@progbits' | "$BINUTILS_PATH"/as - -o /dev/null 2>/dev/null; then + echo "binutils assembler supports SHF_GNU_RETAIN" + else + echo "binutils assembler DOES NOT support SHF_GNU_RETAIN" + exit 1 + fi + PATH="$BINUTILS_PATH":$PATH CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist \ gcc-dev \ gcc From 765a9adefcfb4142627f3182c32990047da86504 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 18 Aug 2026 15:02:59 +0200 Subject: [PATCH 05/13] Don't create directory in `/` --- src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 2705e6e0af61c..0d6422cdd0cc8 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -19,7 +19,7 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then # We have to build our own binutils for the GCC build, because the default CentOS 7 binutils are # too old, and they do not support `SHF_GNU_RETAIN`. BINUTILS="2.47" - BINUTILS_ROOT_PATH="/binutils-install" + BINUTILS_ROOT_PATH="$(pwd)/binutils-install" export BINUTILS_PATH="$BINUTILS_ROOT_PATH/bin" curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - mkdir binutils-build From 338617c39a6e38ef9641f1d0a507f4caf2e56e59 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 18 Aug 2026 20:16:44 +0200 Subject: [PATCH 06/13] Add missing `hide_output` function --- .../host-x86_64/dist-x86_64-linux/dist.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 0d6422cdd0cc8..fdb2fed8b3ce9 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -16,6 +16,22 @@ python3 ../x.py build --set rust.debug=true opt-dist # Use GCC for building GCC components, as it seems to behave badly when built with Clang # Only build GCC on full builds, not try builds if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then + function hide_output { + { set +x; } 2>/dev/null + on_err=" + echo ERROR: An error was encountered with the build. + cat /tmp/build.log + exit 1 + " + trap "$on_err" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + PING_LOOP_PID=$! + "$@" &> /tmp/build.log + trap - ERR + kill $PING_LOOP_PID + set -x + } + # We have to build our own binutils for the GCC build, because the default CentOS 7 binutils are # too old, and they do not support `SHF_GNU_RETAIN`. BINUTILS="2.47" @@ -25,6 +41,7 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then mkdir binutils-build mkdir "$BINUTILS_ROOT_PATH" cd binutils-build + hide_output ../binutils-$BINUTILS/configure --prefix="$BINUTILS_ROOT_PATH" hide_output make -j$(nproc) hide_output make install From 899a691ddc71fc6736395a0516abbce2e3ca4632 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 18 Aug 2026 22:37:01 +0200 Subject: [PATCH 07/13] Remove writing into `/tmp/build.log` for binutils build --- src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index fdb2fed8b3ce9..5b389660aba7b 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -26,7 +26,6 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then trap "$on_err" ERR bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & PING_LOOP_PID=$! - "$@" &> /tmp/build.log trap - ERR kill $PING_LOOP_PID set -x From 79347dd363801a06263d237bc276c84c1f9a40d4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 19 Aug 2026 10:55:42 +0200 Subject: [PATCH 08/13] Fix `hide_output` in `dist.sh` --- .../host-x86_64/dist-x86_64-linux/dist.sh | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 5b389660aba7b..094618db66699 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -17,18 +17,16 @@ python3 ../x.py build --set rust.debug=true opt-dist # Only build GCC on full builds, not try builds if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then function hide_output { - { set +x; } 2>/dev/null - on_err=" - echo ERROR: An error was encountered with the build. - cat /tmp/build.log - exit 1 - " - trap "$on_err" ERR - bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & - PING_LOOP_PID=$! - trap - ERR - kill $PING_LOOP_PID - set -x + { set +x; } 2>/dev/null + local log; log="$(mktemp)" + trap "echo ERROR: An error was encountered with the build.; cat '$log'; exit 1" ERR + bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & + local ping_loop_pid=$! + "$@" &> "$log" + trap - ERR + kill "$ping_loop_pid" + rm -f "$log" + set -x } # We have to build our own binutils for the GCC build, because the default CentOS 7 binutils are From a141152e97d19603caaa40fedd8353eb6bf61844 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 19 Aug 2026 13:32:53 +0200 Subject: [PATCH 09/13] Disable `-Werror` when building binutils --- src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 094618db66699..13710fdcd3a21 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -39,7 +39,7 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then mkdir "$BINUTILS_ROOT_PATH" cd binutils-build - hide_output ../binutils-$BINUTILS/configure --prefix="$BINUTILS_ROOT_PATH" + hide_output ../binutils-$BINUTILS/configure --prefix="$BINUTILS_ROOT_PATH" --disable-werror hide_output make -j$(nproc) hide_output make install From 8d089168a8e52df55228ef595bb13e464556eef7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2026 12:17:58 +0200 Subject: [PATCH 10/13] Move building of binutils back into `build-gcc.sh` --- .../host-x86_64/dist-x86_64-linux/dist.sh | 37 ------------------- src/ci/docker/scripts/build-gcc.sh | 24 ++++++++++++ 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 13710fdcd3a21..b0cd2d809ba03 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -16,43 +16,6 @@ python3 ../x.py build --set rust.debug=true opt-dist # Use GCC for building GCC components, as it seems to behave badly when built with Clang # Only build GCC on full builds, not try builds if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then - function hide_output { - { set +x; } 2>/dev/null - local log; log="$(mktemp)" - trap "echo ERROR: An error was encountered with the build.; cat '$log'; exit 1" ERR - bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & - local ping_loop_pid=$! - "$@" &> "$log" - trap - ERR - kill "$ping_loop_pid" - rm -f "$log" - set -x - } - - # We have to build our own binutils for the GCC build, because the default CentOS 7 binutils are - # too old, and they do not support `SHF_GNU_RETAIN`. - BINUTILS="2.47" - BINUTILS_ROOT_PATH="$(pwd)/binutils-install" - export BINUTILS_PATH="$BINUTILS_ROOT_PATH/bin" - curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - - mkdir binutils-build - mkdir "$BINUTILS_ROOT_PATH" - cd binutils-build - - hide_output ../binutils-$BINUTILS/configure --prefix="$BINUTILS_ROOT_PATH" --disable-werror - hide_output make -j$(nproc) - hide_output make install - - cd .. - rm -rf binutils-build binutils-$BINUTILS - - if echo '.section .test,"awR",@progbits' | "$BINUTILS_PATH"/as - -o /dev/null 2>/dev/null; then - echo "binutils assembler supports SHF_GNU_RETAIN" - else - echo "binutils assembler DOES NOT support SHF_GNU_RETAIN" - exit 1 - fi - PATH="$BINUTILS_PATH":$PATH CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist \ gcc-dev \ gcc diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 6a96b82d3f924..a290dea4a4b25 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -4,6 +4,30 @@ set -eux source shared.sh +# We have to build our own binutils for the GCC build, because the default CentOS 7 binutils are +# too old, and they do not support `SHF_GNU_RETAIN`. +BINUTILS="2.47" +BINUTILS_ROOT_PATH="$(pwd)/binutils-install" +export BINUTILS_PATH="$BINUTILS_ROOT_PATH/bin" +curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - +mkdir binutils-build +mkdir "$BINUTILS_ROOT_PATH" +cd binutils-build + +hide_output ../binutils-$BINUTILS/configure --prefix="$BINUTILS_ROOT_PATH" --disable-werror +hide_output make -j$(nproc) +hide_output make install + +cd .. +rm -rf binutils-build binutils-$BINUTILS + +if echo '.section .test,"awR",@progbits' | "$BINUTILS_PATH"/as - -o /dev/null 2>/dev/null; then + echo "binutils assembler supports SHF_GNU_RETAIN" +else + echo "binutils assembler DOES NOT support SHF_GNU_RETAIN" + exit 1 +fi + # Note: in the future when bumping to version 10.1.0, also take care of the sed block below. # This version is specified in the Dockerfile GCC=$GCC_VERSION From ac82021b092a7dd713ee2662667e91a4de01c334 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2026 14:34:20 +0200 Subject: [PATCH 11/13] use full path for binutils location --- src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh | 10 +++++++--- src/ci/docker/scripts/build-gcc.sh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index b0cd2d809ba03..b4a3f65d666bb 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -16,7 +16,11 @@ python3 ../x.py build --set rust.debug=true opt-dist # Use GCC for building GCC components, as it seems to behave badly when built with Clang # Only build GCC on full builds, not try builds if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then - PATH="$BINUTILS_PATH":$PATH CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist \ - gcc-dev \ - gcc + # We add the binutils binary path to ensure that it uses the 2.47 version of binutils, + # which is needed for the `retain` attribute feature. + PATH="/tmp/binutils-install/bin:$PATH" \ + CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ \ + python3 ../x.py dist \ + gcc-dev \ + gcc fi diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index a290dea4a4b25..1a32433f54278 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -8,7 +8,7 @@ source shared.sh # too old, and they do not support `SHF_GNU_RETAIN`. BINUTILS="2.47" BINUTILS_ROOT_PATH="$(pwd)/binutils-install" -export BINUTILS_PATH="$BINUTILS_ROOT_PATH/bin" +BINUTILS_PATH="$BINUTILS_ROOT_PATH/bin" curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - mkdir binutils-build mkdir "$BINUTILS_ROOT_PATH" From cddac3fae71643436ef72deb10c4ac89c8bad2c7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2026 17:16:23 +0200 Subject: [PATCH 12/13] Add gcc support for retain attribute check --- .../docker/host-x86_64/dist-x86_64-linux/dist.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index b4a3f65d666bb..c8cde79c448ba 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -18,9 +18,20 @@ python3 ../x.py build --set rust.debug=true opt-dist if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then # We add the binutils binary path to ensure that it uses the 2.47 version of binutils, # which is needed for the `retain` attribute feature. - PATH="/tmp/binutils-install/bin:$PATH" \ - CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ \ + export PATH="/tmp/binutils-install/bin:$PATH" + + CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ \ python3 ../x.py dist \ gcc-dev \ gcc + + gcc_path="./build/$HOSTS/gcc/$HOSTS/install/bin/gcc" + if echo 'int x __attribute__((used, retain));' | "$gcc_path" -S -x c -o - - | grep -i '"a.*R"'; then + echo "retain attribute is supported" + else + echo "retain attribute is not supported" + # We display the generated asm just in case... + echo 'int x __attribute__((used, retain));' | "$gcc_path" -S -x c -o - - + exit 1 + fi fi From 4a468eb65fdc9eee60ef2e31d35803b2609061a2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2026 18:04:32 +0200 Subject: [PATCH 13/13] Fix tidy error --- src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index c8cde79c448ba..4935870dd8d65 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -26,7 +26,8 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then gcc gcc_path="./build/$HOSTS/gcc/$HOSTS/install/bin/gcc" - if echo 'int x __attribute__((used, retain));' | "$gcc_path" -S -x c -o - - | grep -i '"a.*R"'; then + if echo 'int x __attribute__((used, retain));' | \ + "$gcc_path" -S -x c -o - - | grep -i '"a.*R"'; then echo "retain attribute is supported" else echo "retain attribute is not supported"