Skip to content
12 changes: 12 additions & 0 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 @@ -18,4 +18,16 @@ 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"
c_code='int x __attribute__((used, retain));'
if echo "$c_code" | "$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 "$c_code" | "$gcc_path" -S -x c -o - -
exit 1
fi
fi
22 changes: 22 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,27 @@ 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"

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.

Suggested change
BINUTILS="2.47"
# 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"

curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf -
mkdir binutils-build
cd binutils-build
hide_output ../binutils-$BINUTILS/configure --prefix=/rustroot
hide_output make -j$(nproc)
hide_output make install

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


# 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 Expand Up @@ -36,6 +57,7 @@ sed -i'' 's|ftp://gcc\.gnu\.org/pub/gcc/infrastructure|https://ci-mirrors.rust-l
mkdir ../gcc-build
cd ../gcc-build

export PATH=/rustroot/bin:$PATH
# '-fno-reorder-blocks-and-partition' is required to
# enable BOLT optimization of the C++ standard library,
# which is included in librustc_driver.so
Expand Down
Loading