- Install cargo-xbuild and the
rust-src
rustup
component:
cargo install cargo-xbuild
rustup component add --toolchain=nightly rust-src
- cd to one of the examples
cd hello-world
- Build the static object with cargo xbuild, pointing it at our custom target
RUST_TARGET_PATH=$(pwd)/.. cargo xbuild --target x86_64-linux-kernel-module
- Build the kernel module using the Linux kernel build system (kbuild)
make
- Load and unload the module!
sudo insmod helloworld.ko
sudo rmmod helloworld
dmesg | tail