|
| 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 |
0 commit comments