Skip to content

Commit

Permalink
Build Rust for Linux in PR CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed May 17, 2024
1 parent 500eb30 commit e186fc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
11 changes: 8 additions & 3 deletions src/ci/docker/host-x86_64/rfl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
git \
cmake \
sudo \
gdb \
flex \
bison \
bc \
llvm-17-tools \
llvm-17 \
llvm-17-dev \
clang \
llvm-17-tools \
clang-17 \
lld-17 \
libelf-dev \
libedit-dev \
libssl-dev \
pkg-config \
Expand All @@ -31,6 +33,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

# RfL needs access to llvm-ar
ENV PATH="${PATH}:/usr/lib/llvm-17/bin"

# We are disabling CI LLVM since this builder is intentionally using a host
# LLVM, rather than the typical src/llvm-project LLVM.
ENV NO_DOWNLOAD_CI_LLVM 1
Expand Down
21 changes: 12 additions & 9 deletions src/ci/docker/scripts/rfl-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@

set -euo pipefail

LINUX_VERSION=v6.9
LINUX_VERSION=master

# Build rustc
../x.py --stage 1 build library/std
BUILT_RUSTC=$(realpath ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc)
# Build rustc and rustdoc
../x.py --stage 1 build library rustdoc

# Install rustup so that we have cargo for installing bindgen
# Install rustup so that we can use the built toolchain easily
curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
sh rustup.sh -y --default-toolchain stable --profile minimal

source /cargo/env

rustup toolchain link local ./build/x86_64-unknown-linux-gnu/stage1
rustup default local

mkdir -p rfl
cd rfl

# Download Linux
git clone --depth 1 --branch ${LINUX_VERSION} \
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

# Install bindgen
# Install bindgen. It needs to be compiled with the same version
# as will be used for the RfL build.
cargo install --locked \
--version $(linux/scripts/min-tool-version.sh bindgen) bindgen-cli

# Configure Linux
# Configure Rust for Linux
cat <<EOF > linux/kernel/configs/rfl-for-rust-ci.config
# CONFIG_RETHUNK is not set
# CONFIG_X86_KERNEL_IBT is not set
Expand All @@ -47,12 +50,12 @@ CONFIG_KUNIT=y
CONFIG_RUST_KERNEL_DOCTESTS=y
EOF

make -C linux LLVM=1 RUSTC=${BUILT_RUSTC} -j$(($(nproc) + 1)) \
make -C linux LLVM=1 -j$(($(nproc) + 1)) \
rustavailable \
defconfig \
rfl-for-rust-ci.config

make -C linux LLVM=1 RUSTC=${BUILT_RUSTC} -j$(($(nproc) + 1)) \
make -C linux LLVM=1 -j$(($(nproc) + 1)) \
samples/rust/rust_minimal.o \
samples/rust/rust_print.o \
drivers/net/phy/ax88796b_rust.o

0 comments on commit e186fc5

Please sign in to comment.