Rust-for-Linux/linux

Failed to build `rust-out-of-tree-module`

Gwzlchn opened this issue · 0 comments

Hi, i am newbie in Rust-for-linux and learning to write kernel module using Rust. I try to start with building rust-out-of-tree-module after building the rust-kernel successfully, but building the module failed.
The error message is as follows, it says that target file "./rust/target.json" does not exist, but I cannot find target.json in the build directory or source directory. How can I build the module successfully?

make ARCH=arm64  CROSS_COMPILE=aarch64-linux-gnu- KDIR=../rust-kernel-build/
make -C ../rust-kernel-build/ M=$PWD
make[1]: Entering directory '/home/wangzl/Project/virt/linux-kernel/rust-kernel-build'
  RUSTC [M] /home/wangzl/Project/virt/linux-kernel/rust-out-of-tree-module/rust_out_of_tree.o
error: target file "./rust/target.json" does not exist

...
make: *** [Makefile:6: default] Error 2

Thank you


My building rust4kernel steps are as follows

  1. create a new rust-kernel-build dir
  2. generate .config from kernel source dir into kernel build dir:
    make ARCH=arm64 O=../rust-kernel-build CROSS_COMPILE=aarch64-linux-gnu- defconfig
  3. build all targets, including modules and Image
    make ARCH=arm64 O=../rust-kernel-build CROSS_COMPILE=aarch64-linux-gnu-
    The generated image can be successfully booted from qemu.
  4. jump to rust-out-of-tree-module dir, build the modules and received the error message
    make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- KDIR=../rust-kernel-build/