Re: [PATCH] rust: kbuild: disambiguate `zerocopy` for `rusttest`

Miguel Ojeda <[email protected]> Mon, 3 Aug 2026 08:48:13 +0200
Newsgroups org.kernel.vger.linux-kbuild,org.kernel.vger.rust-for-linux,org.kernel.vger.stable
Message-ID <CANiq72mH9EkHr-0XNqbX1NpQLu+UTO00tieYrG_oXiNTuqaihA@mail.gmail.com>
On Wed, Jul 29, 2026 at 7:38=E2=80=AFPM Miguel Ojeda <[email protected]> wro=
te:
>
> From: Antoni Boucher <[email protected]>
>
> Starting with Rust 1.76.0, `zerocopy` was added as an (indirect)
> compiler dependency [1]. In turn, this meant that the `rustc-dev`
> component started including a precompiled `zerocopy` crate in the sysroot=
.
>
> This makes `rusttest` fail because the compiler finds several candidates:
>
>     error[E0464]: multiple candidates for `rmeta` dependency `zerocopy` f=
ound
>       --> rust/kernel/prelude.rs:64:9
>        |
>     64 | pub use zerocopy::{
>        |         ^^^^^^^^
>        |
>        =3D note: candidate #1: .../lib/rustlib/x86_64-unknown-linux-gnu/l=
ib/libzerocopy-dfef4cb07ca752aa.rmeta
>        =3D note: candidate #2: ./rust/test/libzerocopy.rlib
>
> We cannot use `--sysroot=3D/dev/null` for these, thus point to the depend=
ency
> explicitly.
>
> Assisted-by: LLM
> Not-yet-Signed-off-by: Antoni Boucher <[email protected]>
> Link: https://github.com/rust-lang/rust/pull/118546 [1]
> Cc: [email protected]
> Fixes: 567621523ab7 ("rust: zerocopy: enable support in kbuild")
> [ Investigated when it started happening, reworded to add that and to
>   follow our usual style and sent on behalf of Antoni, who found this
>   during his work to support Rust for Linux with the GCC backend, i.e.
>   with `rustc_codegen_gcc`. - Miguel ]
> Signed-off-by: Miguel Ojeda <[email protected]>

Applied to `rust-next` -- thanks!

I changed the Assisted-by tag with the details that Antoni gave me.

Cheers,
Miguel