From e186fc5231e4abb8affbabc2f4cabe93390857f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 17 May 2024 19:42:44 +0200 Subject: [PATCH] Build Rust for Linux in PR CI --- src/ci/docker/host-x86_64/rfl/Dockerfile | 11 ++++++++--- src/ci/docker/scripts/rfl-build.sh | 21 ++++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/ci/docker/host-x86_64/rfl/Dockerfile b/src/ci/docker/host-x86_64/rfl/Dockerfile index df214a67ef7c9..50efc43573e3f 100644 --- a/src/ci/docker/host-x86_64/rfl/Dockerfile +++ b/src/ci/docker/host-x86_64/rfl/Dockerfile @@ -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 \ @@ -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 diff --git a/src/ci/docker/scripts/rfl-build.sh b/src/ci/docker/scripts/rfl-build.sh index 89e1a499473bd..37b5334f2c1c2 100755 --- a/src/ci/docker/scripts/rfl-build.sh +++ b/src/ci/docker/scripts/rfl-build.sh @@ -2,18 +2,20 @@ 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 @@ -21,11 +23,12 @@ cd rfl 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 < linux/kernel/configs/rfl-for-rust-ci.config # CONFIG_RETHUNK is not set # CONFIG_X86_KERNEL_IBT is not set @@ -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