From 80cc60a7ea59a2edf33c7cbbc3c6cfa2a0bcb78b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 14 Aug 2026 21:26:24 +0200 Subject: [PATCH] Correctly test the custom GCC built in CI --- .../host-x86_64/dist-x86_64-linux/dist.sh | 11 ++++++++ src/ci/docker/scripts/build-gcc.sh | 26 +++++-------------- 2 files changed, 18 insertions(+), 19 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 46d34cd001a..0ccfd0d7659 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,4 +18,15 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist \ gcc-dev \ gcc + # We confirm that the built GCC has support for the `retain` attribute. + # FIXME: Maybe get the path from `.x.py` instead? + 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 diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 9a70071242d..29502ec56a7 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -6,22 +6,22 @@ source shared.sh BINUTILS="2.47" curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - -cd binutils-$BINUTILS -hide_output ./configure --prefix=/rustroot +mkdir binutils-build +cd binutils-build +hide_output ../binutils-$BINUTILS/configure --prefix=/rustroot hide_output make -j$(nproc) hide_output make install -if echo '.section .test,"awR",@progbits' | /rustroot/bin/as - -o /dev/null 2>/dev/null; then +cd .. +rm -rf binutils-build binutils-$BINUTILS + +if echo '.section .test,"awR",@progbits' | 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 -AS_PATH="/rustroot/bin/as" -LD_PATH="/rustroot/bin/ld" - -cd .. # 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 @@ -61,9 +61,6 @@ export PATH=/rustroot/bin:$PATH # which is included in librustc_driver.so hide_output ../gcc-$GCC/configure \ --prefix=/rustroot \ - --with-bintuils=/rustroot/bin \ - --with-as=$AS_PATH \ - --with-ld=$LD_PATH \ --enable-languages=c,c++ \ --disable-gnu-unique-object \ --enable-cxx-flags='-fno-reorder-blocks-and-partition' @@ -71,15 +68,6 @@ hide_output make -j$(nproc) hide_output make install ln -s gcc /rustroot/bin/cc -if echo 'int x __attribute__((used, retain));' | /rustroot/bin/gcc -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));' | /rustroot/bin/gcc -S -x c -o - - - exit 1 -fi - cd .. rm -rf gcc-build rm -rf gcc-$GCC