Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,23 @@ 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 \
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.
export PATH="/tmp/binutils-install/bin:$PATH"

CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ \
python3 ../x.py dist \
gcc-dev \
gcc

@antoyo antoyo Aug 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the GCC smoke-test anymore for the retain attribute.
Please add it back.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How? It's built somewhere in a lost location with x.py because we can't build gcc with newer binutils.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing the locally built gcc is anyway a bit sketchy (we shouldn't even build gcc in the first place, only libgccjit.so), since the dylib is what we then use.

That being said, if you already had the smoke test working, then adding it to dist.sh probably won't really hurt anything. It should be able to guess the path, it should be always the same.


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
24 changes: 24 additions & 0 deletions src/ci/docker/scripts/build-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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
Expand Down
Loading