I am trying to use bindgen to generate bindings to a C header file. But I encounter errors which I believe are due to it not resolving the
#include within the header file. I am assuming this is because I am packaging the kernel module wrong.
I started by packaging a kernel module that has a header file. It copies the header directory into a dev output.
In my rust project, I include the
exmap in the
nativeBuildInputs. My build.rs file picks up the
#include <linux/exmap.h> file correctly but it fails due to a clang diagnostic:
--- stderr /nix/store/719zzzaknzfn184bxr7jhkyg8r3hxb1b-exmap-dev/include/linux/exmap.h:15:3: error: unknown type name 'uint64_t' /nix/store/719zzzaknzfn184bxr7jhkyg8r3hxb1b-exmap-dev/include/linux/exmap.h:17:4: error: unknown type name 'uint64_t' .... thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ClangDiagnostic(...)
I have tried bindgen with this setup on other nix packages such as
liburing which work great. I cannot figure out what those packages do differently
linux/exmap.h file includes two kernel headers.:
#include <asm/ioctl.h> #include <linux/types.h>