Skip to content

Commit c845431

Browse files
committed
rustc-cg-gcc: revert back to ubuntu 22.04 and rebuild libgccjit
Ubuntu 24.04 bump was a bad idea as runner are still using 22.04 and can't load the compiler (glibc is too old). Adding back our custom gcc build. refs compiler-explorer/compiler-explorer#8147 Signed-off-by: Marc Poulhiès <[email protected]>
1 parent e3614a5 commit c845431

File tree

2 files changed

+58
-8
lines changed

2 files changed

+58
-8
lines changed

Dockerfile.rust-cg-gcc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:24.04
1+
FROM ubuntu:22.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
44
RUN dpkg --add-architecture i386
@@ -13,7 +13,11 @@ RUN apt update -y -q && apt upgrade -y -q && apt update -y -q && \
1313
libc6-dev:i386 \
1414
make \
1515
patchelf \
16-
xz-utils
16+
xz-utils \
17+
libmpfr-dev \
18+
libgmp-dev \
19+
libmpc3 \
20+
libmpc-dev
1721

1822
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
1923

rust-cg-gcc/build.sh

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ GCC_URL="https://github.com/antoyo/gcc.git"
1919
GCC_BRANCH="master"
2020

2121
CG_GCC_BRANCH="master"
22-
CG_GCC_URL="https://github.com/rust-lang/rustc_codegen_gcc.git"
22+
CG_GCC_URL="https://github.com/rust-lang/gcc"
2323

2424
GCC_REVISION=$(get_remote_revision "${GCC_URL}" "heads/${GCC_BRANCH}")
2525
CG_GCC_REVISION=$(get_remote_revision "${CG_GCC_URL}" "heads/${CG_GCC_BRANCH}")
@@ -33,6 +33,53 @@ initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
3333

3434
OUTPUT=$(realpath "${OUTPUT}")
3535

36+
##
37+
## Build customized GCC with libgccjit
38+
##
39+
## We can't use prebuilt ones because our runner are using ubuntu 22.04 which
40+
## does not have a recent enough glibc (error at runtime).
41+
42+
git clone --depth 1 "${GCC_URL}" --branch "${GCC_BRANCH}"
43+
44+
rm -rf gcc-build gcc-install
45+
mkdir -p gcc-build "$PREFIX"
46+
47+
pushd gcc-build
48+
LANGUAGES=jit
49+
PKGVERSION="Compiler-Explorer-Build-${REVISION}"
50+
51+
CONFIG=("--enable-checking=release"
52+
"--enable-host-shared"
53+
"--build=x86_64-linux-gnu"
54+
"--host=x86_64-linux-gnu"
55+
"--target=x86_64-linux-gnu"
56+
"--disable-bootstrap"
57+
"--enable-multiarch"
58+
"--with-abi=m64"
59+
"--with-multilib-list=m32,m64,mx32"
60+
"--enable-multilib"
61+
"--enable-clocale=gnu"
62+
"--enable-languages=${LANGUAGES}"
63+
"--enable-ld=yes"
64+
"--enable-gold=yes"
65+
"--enable-libstdcxx-debug"
66+
"--enable-libstdcxx-time=yes"
67+
"--enable-linker-build-id"
68+
"--enable-lto"
69+
"--enable-plugins"
70+
"--enable-threads=posix"
71+
"--with-pkgversion=\"${PKGVERSION}\""
72+
"--with-pic")
73+
74+
../gcc/configure --prefix="${PREFIX}" "${CONFIG[@]}"
75+
76+
make -j"$(nproc)"
77+
make -j"$(nproc)" install-strip
78+
popd
79+
80+
libgccjit_path=$(dirname $(readlink -f `find "$PREFIX" -name libgccjit.so`))
81+
82+
#
3683
# Needed because the later y.sh will call "git am" and this needs user info.
3784
git config --global user.email "[email protected]"
3885
git config --global user.name "John Nope"
@@ -73,6 +120,9 @@ pushd rustc_codegen_gcc
73120

74121
# Do default config, as described in the "Quick start" guide on the project's
75122
# page.
123+
echo "gcc-path = \"$libgccjit_path\"" > config.toml
124+
echo "download-gccjit = false" >> config.toml
125+
76126
cp config.example.toml config.toml
77127

78128
./y.sh prepare
@@ -102,11 +152,7 @@ mkdir -p toolroot
102152
mv rustup/toolchains/*/* toolroot/
103153

104154
# libgccjit
105-
find -name "libgccjit.so" -exec mv {} toolroot/lib ';'
106-
107-
pushd toolroot/lib
108-
ln -s libgccjit.so libgccjit.so.0
109-
popd
155+
mv $PREFIX/lib/libgccjit.so* toolroot/lib
110156

111157
# cg_gcc backend
112158
mv ./rustc_codegen_gcc/target/release/librustc_codegen_gcc.so toolroot/lib

0 commit comments

Comments
 (0)