Skip to content

Commit a1a2a0e

Browse files
authored
Merge pull request #18 from Rust-for-Linux/fix/ci
Fix CI
2 parents 05dba5f + 7dc2186 commit a1a2a0e

4 files changed

Lines changed: 100 additions & 1 deletion

File tree

.github/workflows/ci.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ jobs:
9393
# TODO: remove if this patch is indeed not necessary. (It seems the patch is now included upstream.)
9494
# - run: git -C linux apply ../ci/x86-boot-Use-std-gnu11-to-fix-build-with-GCC-15.patch
9595

96+
# TODO: remove when fixed upstream.
97+
- run: git -C linux apply ../ci/0001-Use-inline-always-for-bitfield-test-conversions.patch
98+
99+
# TODO: remove when fixed upstream.
100+
- run: git -C linux apply ../ci/0002-Path-qualify-zerocopy-extern-in-rusttestlib-kernel.patch
101+
96102
# Setup: `busybox`.
97103
- run: |
98104
git clone --depth 1 -b 1_30_1 https://github.com/mirror/busybox
@@ -254,7 +260,11 @@ jobs:
254260
grep '] rust_print: Info message (level 6) with args$' qemu-stdout
255261
grep '] rust_print: A line that is continued with args$' qemu-stdout
256262
257-
- run: grep '] ok 7 rust_doctests_kernel$' qemu-stdout
263+
- run: |
264+
# Print the result line for debugging.
265+
grep -E '\] ok [0-9]+ rust_doctests_kernel$' qemu-stdout || true
266+
267+
grep '] ok 8 rust_doctests_kernel$' qemu-stdout
258268
259269
- run: python ci/check_panics.py qemu-stdout
260270

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Antoni Boucher <bouanto@zoho.com>
3+
Date: Mon, 20 Jul 2026 00:00:00 -0500
4+
Subject: [PATCH] Use #[inline(always)] for bitfield test conversions
5+
6+
The `From<MemoryType>`/`From<Priority>` impls in the `bitfield` KUnit
7+
tests forward to `Bounded::from_expr`, which uses `build_assert!`. That
8+
assertion is meant to be optimized out on the (statically valid) success
9+
path. rustc_codegen_gcc only manages to fold it away once the constant
10+
enum values from the test bodies are visible, which requires the whole
11+
call chain to be inlined. The generated `bitfield!` setters and
12+
`from_expr` are already `#[inline(always)]`; these two `From` impls are
13+
the only remaining out-of-line links, so an out-of-line copy carrying an
14+
un-eliminated call to `rust_build_error` is emitted and the vmlinux link
15+
fails with `undefined reference to rust_build_error`.
16+
17+
Force-inlining these conversions lets the constants reach `build_assert!`
18+
so the branch is folded away, matching the codegen LLVM already produces.
19+
---
20+
rust/kernel/bitfield.rs | 2 ++
21+
1 file changed, 2 insertions(+)
22+
23+
diff --git a/rust/kernel/bitfield.rs b/rust/kernel/bitfield.rs
24+
--- a/rust/kernel/bitfield.rs
25+
+++ b/rust/kernel/bitfield.rs
26+
@@ -581,6 +581,7 @@
27+
}
28+
29+
impl From<MemoryType> for Bounded<u64, 4> {
30+
+ #[inline(always)]
31+
fn from(mt: MemoryType) -> Bounded<u64, 4> {
32+
Bounded::from_expr(mt as u64)
33+
}
34+
@@ -606,6 +607,7 @@
35+
}
36+
37+
impl From<Priority> for Bounded<u16, 2> {
38+
+ #[inline(always)]
39+
fn from(p: Priority) -> Bounded<u16, 2> {
40+
Bounded::from_expr(p as u16)
41+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Antoni Boucher <bouanto@zoho.com>
3+
Date: Mon, 20 Jul 2026 00:00:00 -0500
4+
Subject: [PATCH] rust: path-qualify the zerocopy extern in rusttestlib-kernel
5+
6+
Since nightly-2025-11-23 the Rust sysroot ships a precompiled `zerocopy`
7+
crate (`libzerocopy-<hash>.rmeta`). `rusttestlib-kernel` builds the kernel
8+
crate as a host test library with a bare `--extern zerocopy` and
9+
`-L rust/test`, so rustc finds two candidates for the crate -- the
10+
in-tree `rust/test/libzerocopy.rlib` and the sysroot one -- and fails:
11+
12+
error[E0464]: multiple candidates for `rmeta` dependency `zerocopy` found
13+
14+
The other rules that name `zerocopy` are unaffected: the rustdoc/doctest
15+
rules pass `--sysroot=/dev/null`, and `rusttest-macros` only pulls
16+
`zerocopy` in transitively through `--extern kernel`, which rustc
17+
resolves unambiguously by crate hash.
18+
19+
Point the direct dependency at the in-tree rlib so the sysroot copy is
20+
never considered. This only shows up with a recent toolchain, which the
21+
GCC backend uses (rustc_codegen_gcc pins nightly-2026-07-14); the LLVM
22+
backend still builds against an older nightly without the sysroot crate.
23+
---
24+
rust/Makefile | 2 +-
25+
1 file changed, 1 insertion(+), 1 deletion(-)
26+
27+
diff --git a/rust/Makefile b/rust/Makefile
28+
--- a/rust/Makefile
29+
+++ b/rust/Makefile
30+
@@ -342,7 +342,7 @@ rusttestlib-pin_init: $(src)/pin-init/src/lib.rs rusttestlib-macros \
31+
rusttestlib-kernel: private rustc_target_flags = --extern ffi \
32+
--extern build_error --extern macros --extern pin_init \
33+
--extern bindings --extern uapi \
34+
- --extern zerocopy --extern zerocopy_derive
35+
+ --extern zerocopy=$(objtree)/$(obj)/test/libzerocopy.rlib --extern zerocopy_derive
36+
rusttestlib-kernel: $(src)/kernel/lib.rs rusttestlib-bindings rusttestlib-uapi \
37+
rusttestlib-build_error rusttestlib-pin_init $(obj)/$(libmacros_name) \
38+
$(obj)/bindings.o rusttestlib-zerocopy rusttestlib-zerocopy_derive FORCE

rfl-rust.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ AX88796B_RUST_PHY=y
1717

1818
CONFIG_KUNIT=y
1919
CONFIG_RUST_KERNEL_DOCTESTS=y
20+
21+
# Other test suites from the `kernel` crate (i.e. `kunit_tests`, `#[test]`).
22+
CONFIG_RUST_KUNIT_TESTS=y
23+
CONFIG_RUST_ALLOCATOR_KUNIT_TEST=y
24+
CONFIG_RUST_KVEC_KUNIT_TEST=y
25+
CONFIG_RUST_BITMAP_KUNIT_TEST=y
26+
CONFIG_RUST_KUNIT_SELFTEST=y
27+
CONFIG_RUST_STR_KUNIT_TEST=y
28+
CONFIG_RUST_ATOMICS_KUNIT_TEST=y
29+
CONFIG_RUST_BITFIELD_KUNIT_TEST=y

0 commit comments

Comments
 (0)