On Mon, Oct 19, 2026 at 04:25:59PM -0700, Deborah Brouwer wrote:
> Make the zerocopy and zerocopy_derive crates available for use when
> building the bindings and uapi crates and their tests.
> 
> This will be used by the Tyr driver that needs the traits IntoBytes and
> Immutable to safely copy the struct byte-for-byte to userspace.
> 
> Signed-off-by: Deborah Brouwer <[email protected]>
> ---
>  rust/Makefile | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)

`scripts/generate_rust_analyzer.py` also needs to pass `zerocopy` and
`zerocopy_derive` in the `deps` lists of `bindings` and `uapi` (similar
to commit 3c847e17225a ("rust: add `pin-init` as a dependency to
`bindings` and `uapi`")).

Without that update, `make rust-analyzer` generates a `rust-project.json`
where `bindings` and `uapi` only depend on `core`, `ffi`, and `pin_init`,
so `rust-analyzer` fails to resolve `zerocopy_derive::most_traits` in
`uapi` and does not see the derived traits on `drm_panthor_gpu_info` in
`tyr`.

With `scripts/generate_rust_analyzer.py` updated as well, a subject
prefix like `rust: add zerocopy and zerocopy_derive to bindings and uapi`
might fit better too.

> diff --git a/rust/Makefile b/rust/Makefile
> index da1a7409d984..f59815fac293 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -361,12 +361,18 @@ rusttestlib-kernel: $(src)/kernel/lib.rs 
> rusttestlib-bindings rusttestlib-uapi \
>      $(obj)/bindings.o rusttestlib-zerocopy rusttestlib-zerocopy_derive FORCE
>       +$(call if_changed,rustc_test_library)
>  
> -rusttestlib-bindings: private rustc_target_flags = --extern ffi --extern 
> pin_init
> -rusttestlib-bindings: $(src)/bindings/lib.rs rusttestlib-ffi 
> rusttestlib-pin_init FORCE
> +rusttestlib-bindings: private rustc_target_flags = --extern ffi --extern 
> pin_init \
> +     --extern zerocopy=$(objtree)/$(obj)/test/libzerocopy.rlib \
> +     --extern 
> zerocopy_derive=$(objtree)/$(obj)/test/$(libzerocopy_derive_name)
> +rusttestlib-bindings: $(src)/bindings/lib.rs rusttestlib-ffi 
> rusttestlib-pin_init \
> +     rusttestlib-zerocopy rusttestlib-zerocopy_derive FORCE
>       +$(call if_changed,rustc_test_library)

Nit: non-recipe continuation lines in `rust/Makefile` use 4 spaces for
indentation rather than tabs (same for `rusttestlib-uapi`,
`$(obj)/bindings.o`, and `$(obj)/uapi.o` below).

Alice

Reply via email to