fishinabarrel / linux-kernel-module-rust

Framework for writing Linux kernel modules in safe Rust
GNU General Public License v2.0
1.33k stars 119 forks source link

Keep modinfo happy in newer kernels #230

Open geofft opened 4 years ago

geofft commented 4 years ago

I see this warning:

WARNING: could not find /home/ubuntu/linux-kernel-module-rust/hello-world/.hello_world.rust.o.cmd for /home/ubuntu/linux-kernel-module-rust/hello-world/hello_world.rust.o

Looking around a bit, I see torvalds/linux@70f30cfe5b892fcb7f98e7df72ed6ccfe3225628, which I'm now worried about:

    Going forward, the missing *.symvers or *.cmd is a fatal error.
    This should not happen because scripts/Makefile.modpost guards the
    -i option files with $(wildcard $(input-symdump)).

I think we need to either generate the .cmd file or explicitly tell modinfo to skip our .o file. (I assume the skip option exists because closed-source modules with precompiled .o files are a thing.)

I think this is generated as an -MD or thereabouts of input C files, and we could almost certainly do that easily for bindings.c. I'm less sure if we can do that for bindgen but presumably it's doable somehow with libclang....

Bobo1239 commented 4 years ago

This is affecting Arch Linux's 5.8 kernel now so I've looked around a bit.

I didn't find anything to tell modpost to skip our .rust.o. (Unless you meant the mod->skip field which was removed in torvalds/linux@0b19d54cae11bd5b9e208f52e42d88ad33a3b1d9 but wasn't exposed anyways.)

Fortunately it seems to suffice to just create an empty file with the correct name.

 %.rust.o: target/x86_64-linux-kernel/debug/lib%.a
        $(LD) -r -o $@ --whole-archive $<
+       touch $(dir $@)/.$(notdir $@).cmd

Along with some changes from your filter-out-plugins branch I'm able to build hello-world again on Arch.