Skip to content

Enable Rust in the Linux kernel

Description:

Enable Rust in the kernel build for rust modules support.

Here i attached some possible changes to the config and PKGBUILD files.

This will add rustc and llvm as a makedepend.

Additional info:

  • package version(s): 6.9.7.arch1-1
  • it requires the rust toolchain version 1.76 as of kernel 6.9
    • it is setup automatically by running

      rustup override set $(scripts/min-tool-version.sh rustc)

      rustup component add rust-src

      cargo install --locked --version $(scripts/min-tool-version.sh bindgen) bindgen-cli

  • When building, pass LLVM=1 to the make command.
  • config file
    • just enable rust from nconfig
  • PKGBUILD example
    • from my limited testing if make htdocs is enabled the build freezes, as of now i don't know why ("WARNING: Duplicate C declaration") but after a while it starts back. As of now i have no idea of why id does that, it must be fixed.
  • Linux kernel documentation for Rust

Steps to reproduce:

  1. Build the kernel with the default PKGBUILD
  2. Try to load a kernel module written in Rust
  3. It fails to load
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information