Skip to content

Commit d402830

Browse files
committed
Auto merge of #125209 - Kobzol:rfl-ci, r=Mark-Simulacrum
Add Rust for Linux `auto` CI job This PR adds an `auto` CI job that checks if Rust for Linux (RfL) still compiles with the latest version of the compiler and the standard library. If not, we should ideally ping the RfL ping group. try-job: rfl
2 parents a316785 + 144760e commit d402830

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM ubuntu:22.04
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
# libclang1 is required for libclang.so, required by bindgen
6+
# clang, llvm and lld is required by RfL to compile host code
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
g++ \
9+
make \
10+
ninja-build \
11+
file \
12+
curl \
13+
ca-certificates \
14+
python3 \
15+
git \
16+
cmake \
17+
flex \
18+
bison \
19+
bc \
20+
clang-15 \
21+
libclang1-15 \
22+
llvm-15 \
23+
lld-15 \
24+
libelf-dev \
25+
libedit-dev \
26+
libssl-dev \
27+
pkg-config \
28+
zlib1g-dev \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
COPY scripts/sccache.sh /scripts/
32+
RUN sh /scripts/sccache.sh
33+
34+
# RfL needs access to cland, lld and llvm tools
35+
ENV PATH="${PATH}:/usr/lib/llvm-15/bin"
36+
37+
ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu
38+
39+
COPY /scripts/rfl-build.sh /tmp/rfl-build.sh
40+
ENV SCRIPT bash /tmp/rfl-build.sh

src/ci/docker/scripts/rfl-build.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
LINUX_VERSION=c13320499ba0efd93174ef6462ae8a7a2933f6e7
6+
7+
# Build rustc, rustdoc and cargo
8+
../x.py build --stage 1 library rustdoc
9+
../x.py build --stage 0 cargo
10+
11+
# Install rustup so that we can use the built toolchain easily, and also
12+
# install bindgen in an easy way.
13+
curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
14+
sh rustup.sh -y --default-toolchain none
15+
16+
source /cargo/env
17+
18+
BUILD_DIR=$(realpath ./build)
19+
rustup toolchain link local "${BUILD_DIR}"/x86_64-unknown-linux-gnu/stage1
20+
rustup default local
21+
22+
mkdir -p rfl
23+
cd rfl
24+
25+
# Remove existing directory to make local builds easier
26+
rm -rf linux || true
27+
28+
# Download Linux at a specific commit
29+
mkdir -p linux
30+
git -C linux init
31+
git -C linux remote add origin https://github.com/torvalds/linux.git
32+
git -C linux fetch --depth 1 origin ${LINUX_VERSION}
33+
git -C linux checkout FETCH_HEAD
34+
35+
# Install bindgen
36+
"${BUILD_DIR}"/x86_64-unknown-linux-gnu/stage0/bin/cargo install \
37+
--version $(linux/scripts/min-tool-version.sh bindgen) \
38+
bindgen-cli
39+
40+
# Configure Rust for Linux
41+
cat <<EOF > linux/kernel/configs/rfl-for-rust-ci.config
42+
# CONFIG_WERROR is not set
43+
44+
CONFIG_RUST=y
45+
46+
CONFIG_SAMPLES=y
47+
CONFIG_SAMPLES_RUST=y
48+
49+
CONFIG_SAMPLE_RUST_MINIMAL=m
50+
CONFIG_SAMPLE_RUST_PRINT=y
51+
52+
CONFIG_RUST_PHYLIB_ABSTRACTIONS=y
53+
CONFIG_AX88796B_PHY=y
54+
CONFIG_AX88796B_RUST_PHY=y
55+
56+
CONFIG_KUNIT=y
57+
CONFIG_RUST_KERNEL_DOCTESTS=y
58+
EOF
59+
60+
make -C linux LLVM=1 -j$(($(nproc) + 1)) \
61+
rustavailable \
62+
defconfig \
63+
rfl-for-rust-ci.config
64+
65+
make -C linux LLVM=1 -j$(($(nproc) + 1)) \
66+
samples/rust/rust_minimal.o \
67+
samples/rust/rust_print.o \
68+
drivers/net/phy/ax88796b_rust.o

src/ci/github-actions/jobs.yml

+5
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,8 @@ auto:
465465
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler
466466
SCRIPT: python x.py dist bootstrap --include-default-paths
467467
<<: *job-windows-8c
468+
469+
# Tests integration with Rust for Linux.
470+
# Builds stage 1 compiler and tries to compile a few RfL examples with it.
471+
- image: rfl
472+
<<: *job-linux-8c

0 commit comments

Comments
 (0)