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

Build fails on Debian kernel 5.x: fatal error: 'generated/autoconf.h' file not found #243

Closed geofft closed 4 years ago

geofft commented 4 years ago

On a Debian stable machine with kernel headers for either 5.2.0-2-amd64 or 5.7.0-2-amd64 from unstable (5.2 from a while ago, 5.7 from today), with either clang 9 or 12 (apt.llvm.org, again from a while ago and today respectively):

root@lkm:~/linux-kernel-module-rust/hello-world# make CLANG=clang-12 KDIR=/lib/modules/5.7.0-2-amd64/build
make -C /lib/modules/5.7.0-2-amd64/build M=/root/linux-kernel-module-rust/hello-world CC=clang-12 CONFIG_CC_IS_CLANG=y
make[1]: Entering directory '/usr/src/linux-headers-5.7.0-2-amd64'
cd /root/linux-kernel-module-rust/hello-world; cargo build -Z build-std=core,alloc --target=x86_64-linux-kernel
   Compiling linux-kernel-module v0.1.0 (/root/linux-kernel-module-rust)
error: failed to run custom build command for `linux-kernel-module v0.1.0 (/root/linux-kernel-module-rust)`

Caused by:
  process didn't exit successfully: `/root/linux-kernel-module-rust/hello-world/target/debug/build/linux-kernel-module-b85ad71b343c44f6/build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=CC
  cargo:rerun-if-env-changed=abs_srctree
  cargo:rerun-if-env-changed=c_flags
  cargo:rerun-if-changed=src/bindings_helper.h

  --- stderr
  /usr/src/linux-headers-5.7.0-2-common/include/linux/kconfig.h:5:10: fatal error: 'generated/autoconf.h' file not found
  /usr/src/linux-headers-5.7.0-2-common/include/linux/kconfig.h:5:10: fatal error: 'generated/autoconf.h' file not found, err: true
  thread 'main' panicked at 'Unable to generate bindings: ()', /root/linux-kernel-module-rust/build.rs:177:39
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
make[3]: *** [/root/linux-kernel-module-rust/hello-world/Kbuild:10: /root/linux-kernel-module-rust/hello-world/target/x86_64-linux-kernel/debug/libhello_world.a] Error 101
make[2]: *** [/usr/src/linux-headers-5.7.0-2-common/Makefile:1745: /root/linux-kernel-module-rust/hello-world] Error 2
make[1]: *** [/usr/src/linux-headers-5.7.0-2-common/Makefile:180: sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.7.0-2-amd64'
make: *** [Makefile:9: all] Error 2

Honestly this sounds kind of familiar, like the long comment that was in kernel-cflags-finder.