@@ -4,8 +4,8 @@ set -euo pipefail
4
4
5
5
LINUX_VERSION=4c7864e81d8bbd51036dacf92fb0a400e13aaeee
6
6
7
- # Build rustc, rustdoc and cargo
8
- ../x.py build --stage 1 library rustdoc
7
+ # Build rustc, rustdoc, cargo, clippy-driver and rustfmt
8
+ ../x.py build --stage 2 library rustdoc clippy rustfmt
9
9
../x.py build --stage 0 cargo
10
10
11
11
# Install rustup so that we can use the built toolchain easily, and also
@@ -16,7 +16,7 @@ sh rustup.sh -y --default-toolchain none
16
16
source /cargo/env
17
17
18
18
BUILD_DIR=$( realpath ./build)
19
- rustup toolchain link local " ${BUILD_DIR} " /x86_64-unknown-linux-gnu/stage1
19
+ rustup toolchain link local " ${BUILD_DIR} " /x86_64-unknown-linux-gnu/stage2
20
20
rustup default local
21
21
22
22
mkdir -p rfl
@@ -62,11 +62,47 @@ make -C linux LLVM=1 -j$(($(nproc) + 1)) \
62
62
defconfig \
63
63
rfl-for-rust-ci.config
64
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 \
65
+ BUILD_TARGETS= "
66
+ samples/rust/rust_minimal.o
67
+ samples/rust/rust_print.o
68
+ drivers/net/phy/ax88796b_rust.o
69
69
rust/doctests_kernel_generated.o
70
+ "
71
+
72
+ # Build a few Rust targets
73
+ #
74
+ # This does not include building the C side of the kernel nor linking,
75
+ # which can find other issues, but it is much faster.
76
+ #
77
+ # This includes transforming `rustdoc` tests into KUnit ones thanks to
78
+ # `CONFIG_RUST_KERNEL_DOCTESTS=y` above (which, for the moment, uses the
79
+ # unstable `--test-builder` and `--no-run`).
80
+ make -C linux LLVM=1 -j$(( $(nproc) + 1 )) \
81
+ $BUILD_TARGETS
70
82
83
+ # Generate documentation
71
84
make -C linux LLVM=1 -j$(( $(nproc) + 1 )) \
72
85
rustdoc
86
+
87
+ # Build macro expanded source (`-Zunpretty=expanded`)
88
+ #
89
+ # This target also formats the macro expanded code, thus it is also
90
+ # intended to catch ICEs with formatting `-Zunpretty=expanded` output
91
+ # like https://github.com/rust-lang/rustfmt/issues/6105.
92
+ make -C linux LLVM=1 -j$(( $(nproc) + 1 )) \
93
+ samples/rust/rust_minimal.rsi
94
+
95
+ # Re-build with Clippy enabled
96
+ #
97
+ # This should not introduce Clippy errors, since `CONFIG_WERROR` is not
98
+ # set (thus no `-Dwarnings`) and the kernel uses `-W` for all Clippy
99
+ # lints, including `clippy::all`. However, it could catch ICEs.
100
+ make -C linux LLVM=1 -j$(( $(nproc) + 1 )) CLIPPY=1 \
101
+ $BUILD_TARGETS
102
+
103
+ # Format the code
104
+ #
105
+ # This returns successfully even if there were changes, i.e. it is not
106
+ # a check.
107
+ make -C linux LLVM=1 -j$(( $(nproc) + 1 )) \
108
+ rustfmt
0 commit comments