Rust-for-Linux/linux

out of tree kernel module build is somehow broken

fneddy opened this issue · 2 comments

out of tree kernel module build is somehow broken

the problem

it seems that out of tree kernel module is not behaving as expected (or as I expect it). if i

  • download the newest vanilla stable source,
  • extract it,
  • enable rust,
  • compile the kernel,
  • try to build an out of tree rust module against it

it fails. I need to go back to the kernel source dir and redo the make AFTER i called once an out of tree kernel module build so the core crate is found.

steps to reproduce

  1. download and extract newest stable kernel
> curl ...
> tar xfk linux.tar.xz 
  1. compile kernel
> export LLVM=1
> cd $KDIR
> time make clean
> time make mrproper
> time make defconfig
> time make rust.config
> time make all -j $(($(nproc)-1))
  1. try to compile the out of tree kernel module
> cd $MODULE_DIR
> make -C $KDIR M=$PWD

error[E0463]: can't find crate for `core`
  |
  = note: the `target` target may not be installed
  = help: consider downloading the target with `rustup target add target`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

....

now if redo the make all in KDIR AFTER i triggered the out of tree module build everything works as expected and i can now build out of tree kernel modules.

> cd $KDIR
> time make all -j $(($(nproc)-1))
> cd $MODULE_DIR
> make -C $KDIR M=$PWD

this happens independent if export LLVM=1 or unset LLVM=1 is called before build.

nevermind ... did this in a script and PWD was NOT in my module_dir ...

No worries -- thanks for reporting!