Rust-for-Linux / linux

Adding support for the Rust language to the Linux kernel.
https://rust-for-linux.com
Other
3.83k stars 399 forks source link

out of tree kernel module build is somehow broken #1054

Closed fneddy closed 5 months ago

fneddy commented 5 months ago

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

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 
  2. 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))
  3. 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.

fneddy commented 5 months ago

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

ojeda commented 5 months ago

No worries -- thanks for reporting!