Skip to content

Commit dce8c06

Browse files
committed
ci: Move dist-aarch64-linux to an aarch64 runner
Move the dist-aarch64-linux CI job to an aarch64 runner instead of cross-compiling it from an x86 one. This will make it possible to perform optimisations such as LTO, PGO and BOLT later on.
1 parent b44e14f commit dce8c06

File tree

8 files changed

+241
-43
lines changed

8 files changed

+241
-43
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# We document platform support for minimum glibc 2.17 and kernel 3.2.
2+
# CentOS 7 has headers for kernel 3.10, but that's fine as long as we don't
3+
# actually use newer APIs in rustc or std without a fallback. It's more
4+
# important that we match glibc for ELF symbol versioning.
5+
FROM centos:7
6+
7+
WORKDIR /build
8+
9+
# CentOS 7 EOL is June 30, 2024, but the repos remain in the vault.
10+
RUN sed -i /etc/yum.repos.d/*.repo -e 's!^mirrorlist!#mirrorlist!' \
11+
-e 's!^#baseurl=http://mirror.centos.org/!baseurl=https://vault.centos.org/!'
12+
RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
13+
14+
RUN yum upgrade -y && \
15+
yum install -y \
16+
automake \
17+
bzip2 \
18+
file \
19+
gcc \
20+
gcc-c++ \
21+
git \
22+
glibc-devel \
23+
libedit-devel \
24+
libstdc++-devel \
25+
make \
26+
ncurses-devel \
27+
openssl-devel \
28+
patch \
29+
perl \
30+
perl-core \
31+
pkgconfig \
32+
python3 \
33+
unzip \
34+
wget \
35+
xz \
36+
zlib-devel \
37+
&& yum clean all
38+
39+
RUN mkdir -p /rustroot/bin
40+
41+
ENV PATH=/rustroot/bin:$PATH
42+
ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib32:/rustroot/lib
43+
ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
44+
WORKDIR /tmp
45+
RUN mkdir /home/user
46+
COPY host-aarch64/dist-aarch64-linux/shared.sh /tmp/
47+
48+
# Need at least GCC 5.1 to compile LLVM
49+
COPY host-aarch64/dist-aarch64-linux/build-gcc.sh /tmp/
50+
RUN ./build-gcc.sh && yum remove -y gcc gcc-c++
51+
52+
ENV CC=gcc CXX=g++
53+
54+
# LLVM 17 needs cmake 3.20 or higher.
55+
COPY scripts/cmake.sh /tmp/
56+
RUN ./cmake.sh
57+
58+
# Build LLVM+Clang
59+
COPY host-aarch64/dist-aarch64-linux/build-clang.sh /tmp/
60+
RUN ./build-clang.sh
61+
ENV CC=clang CXX=clang++
62+
63+
# Build zstd to enable `llvm.libzstd`.
64+
COPY host-aarch64/dist-aarch64-linux/build-zstd.sh /tmp/
65+
RUN ./build-zstd.sh
66+
67+
COPY scripts/sccache.sh /scripts/
68+
RUN sh /scripts/sccache.sh
69+
70+
ENV PGO_HOST=aarch64-unknown-linux-gnu
71+
ENV HOSTS=aarch64-unknown-linux-gnu
72+
73+
ENV CPATH=/usr/include/aarch64-linux-gnu/:$CPATH
74+
75+
ENV RUST_CONFIGURE_ARGS \
76+
--build=aarch64-unknown-linux-gnu \
77+
--enable-full-tools \
78+
--enable-profiler \
79+
--enable-sanitizers \
80+
--enable-compiler-docs \
81+
--set target.aarch64-unknown-linux-gnu.linker=clang \
82+
--set target.aarch64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \
83+
--set target.aarch64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
84+
--set llvm.link-shared=true \
85+
--set llvm.thin-lto=false \
86+
--set llvm.libzstd=true \
87+
--set llvm.ninja=false \
88+
--set rust.debug-assertions=false \
89+
--set rust.jemalloc \
90+
--set rust.use-lld=true \
91+
--set rust.codegen-units=1
92+
93+
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
94+
95+
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang
96+
ENV DIST_SRC 1
97+
ENV LIBCURL_NO_PKG_CONFIG 1
98+
ENV DIST_REQUIRE_ALL_TOOLS 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
source shared.sh
6+
7+
# Try to keep the LLVM version here in sync with src/ci/scripts/install-clang.sh
8+
LLVM=llvmorg-19.1.5
9+
10+
mkdir llvm-project
11+
cd llvm-project
12+
13+
curl -L https://github.com/llvm/llvm-project/archive/$LLVM.tar.gz | \
14+
tar xzf - --strip-components=1
15+
16+
mkdir clang-build
17+
cd clang-build
18+
19+
# For whatever reason the default set of include paths for clang is different
20+
# than that of gcc. As a result we need to manually include our sysroot's
21+
# include path, /rustroot/include, to clang's default include path.
22+
INC="/rustroot/include:/usr/include"
23+
24+
# We need compiler-rt for the profile runtime (used later to PGO the LLVM build)
25+
# but sanitizers aren't currently building. Since we don't need those, just
26+
# disable them. BOLT is used for optimizing LLVM.
27+
hide_output \
28+
cmake ../llvm \
29+
-DCMAKE_BUILD_TYPE=Release \
30+
-DCMAKE_INSTALL_PREFIX=/rustroot \
31+
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
32+
-DCOMPILER_RT_BUILD_XRAY=OFF \
33+
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
34+
-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF \
35+
-DLLVM_TARGETS_TO_BUILD=AArch64 \
36+
-DLLVM_INCLUDE_BENCHMARKS=OFF \
37+
-DLLVM_INCLUDE_TESTS=OFF \
38+
-DLLVM_INCLUDE_EXAMPLES=OFF \
39+
-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt" \
40+
-DC_INCLUDE_DIRS="$INC"
41+
42+
hide_output make -j$(nproc)
43+
hide_output make install
44+
45+
cd ../..
46+
rm -rf llvm-project
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
source shared.sh
5+
6+
# Note: in the future when bumping to version 10.1.0, also take care of the sed block below.
7+
GCC=9.5.0
8+
9+
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.xz | xzcat | tar xf -
10+
cd gcc-$GCC
11+
12+
# FIXME(#49246): Remove the `sed` below.
13+
#
14+
# On 2018 March 21st, two Travis builders' cache for Docker are suddenly invalidated. Normally this
15+
# is fine, because we just need to rebuild the Docker image. However, it reveals a network issue:
16+
# downloading from `ftp://gcc.gnu.org/` from Travis (using passive mode) often leads to "Connection
17+
# timed out" error, and even when the download completed, the file is usually corrupted. This causes
18+
# nothing to be landed that day.
19+
#
20+
# We observed that the `gcc-4.8.5.tar.bz2` above can be downloaded successfully, so as a stability
21+
# improvement we try to download from the HTTPS mirror instead. Turns out this uncovered the third
22+
# bug: the host `gcc.gnu.org` and `cygwin.com` share the same IP, and the TLS certificate of the
23+
# latter host is presented to `wget`! Therefore, we choose to download from the insecure HTTP server
24+
# instead here.
25+
#
26+
# Note: in version 10.1.0, the URL used in `download_prerequisites` has changed from using FTP to
27+
# using HTTP. When bumping to that gcc version, we can likely remove the sed replacement below, or
28+
# the expression will need to be updated. That new URL is available at:
29+
# https://github.com/gcc-mirror/gcc/blob/6e6e3f144a33ae504149dc992453b4f6dea12fdb/contrib/download_prerequisites#L35
30+
#
31+
sed -i'' 's|ftp://gcc\.gnu\.org/|https://gcc.gnu.org/|g' ./contrib/download_prerequisites
32+
33+
./contrib/download_prerequisites
34+
mkdir ../gcc-build
35+
cd ../gcc-build
36+
37+
# '-fno-reorder-blocks-and-partition' is required to
38+
# enable BOLT optimization of the C++ standard library,
39+
# which is included in librustc_driver.so
40+
hide_output ../gcc-$GCC/configure \
41+
--prefix=/rustroot \
42+
--enable-languages=c,c++ \
43+
--disable-gnu-unique-object \
44+
--enable-cxx-flags='-fno-reorder-blocks-and-partition'
45+
hide_output make -j$(nproc)
46+
hide_output make install
47+
ln -s gcc /rustroot/bin/cc
48+
49+
cd ..
50+
rm -rf gcc-build
51+
rm -rf gcc-$GCC
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
hide_output() {
5+
set +x
6+
on_err="
7+
echo ERROR: An error was encountered with the build.
8+
cat /tmp/zstd_build.log
9+
exit 1
10+
"
11+
trap "$on_err" ERR
12+
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
13+
PING_LOOP_PID=$!
14+
"$@" &> /tmp/zstd_build.log
15+
trap - ERR
16+
kill $PING_LOOP_PID
17+
rm /tmp/zstd_build.log
18+
set -x
19+
}
20+
21+
ZSTD=1.5.6
22+
curl -L https://github.com/facebook/zstd/releases/download/v$ZSTD/zstd-$ZSTD.tar.gz | tar xzf -
23+
24+
cd zstd-$ZSTD
25+
CFLAGS=-fPIC hide_output make -j$(nproc) VERBOSE=1
26+
hide_output make install
27+
28+
cd ..
29+
rm -rf zstd-$ZSTD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
hide_output() {
3+
set +x
4+
on_err="
5+
echo ERROR: An error was encountered with the build.
6+
cat /tmp/build.log
7+
exit 1
8+
"
9+
trap "$on_err" ERR
10+
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
11+
PING_LOOP_PID=$!
12+
"$@" &> /tmp/build.log
13+
trap - ERR
14+
kill $PING_LOOP_PID
15+
set -x
16+
}

src/ci/docker/host-x86_64/dist-aarch64-linux/Dockerfile

-32
This file was deleted.

src/ci/docker/host-x86_64/dist-aarch64-linux/aarch64-linux-gnu.defconfig

-10
This file was deleted.

src/ci/github-actions/jobs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ auto:
138138
- name: dist-aarch64-linux
139139
env:
140140
CODEGEN_BACKENDS: llvm,cranelift
141-
<<: *job-linux-4c
141+
<<: *job-aarch64-linux
142142

143143
- name: dist-android
144144
<<: *job-linux-4c

0 commit comments

Comments
 (0)