Hello everyone,
I'm trying to build the example Rust kernel modules from kernel source
[1] on Arch Linux. I use a simple Makefile to build them out of tree:
obj-m += rust_minimal.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
However, the build can't find some Rust metadata:
make -C /lib/modules/6.8.7-arch1-1/build
M=/home/lukas/Downloads/linux-6.8.7-arch1/samples/rust modules
make[1]: Entering directory '/usr/lib/modules/6.8.7-arch1-1/build'
RUSTC [M]
/home/lukas/Downloads/linux-6.8.7-arch1/samples/rust/rust_minimal.o
error: target file "./scripts/target.json" does not exist
Indeed, there is no target.json in /lib/modules/$(uname
-r)/build/scripts/, so I thought, maybe I need to use a special kernel
with Rust support. But building linux-rust from the AUR fails with the
same error message:
Installing Rust files...
install: cannot stat 'scripts/target.json': No such file or directory
==> ERROR: A failure occurred in package_linux-rust-headers().
Aborting...
And even the default kernel is passing the Linux kernel Rust support
check script as suggested in the kernel docs [2]:
lukas@Lukas-AMD:rust$ make -C /lib/modules/$(uname -r)/build rustavailable
make: Entering directory '/usr/lib/modules/6.8.7-arch1-1/build'
Rust is available!
make: Leaving directory '/usr/lib/modules/6.8.7-arch1-1/build'
So what am I doing wrong? Is the Arch Linux kernel currently missing
Rust metadata required for Rust support, like target.json? Or am I
missing some important prerequisites here? Any suggestions welcome!
Thanks,
lukaro
[1] https://github.com/Rust-for-Linux/linux/tree/rust-next/samples/rust
[2] https://docs.kernel.org/6.8/rust/quick-start.html