Linux kernel Rust work is documented in two places: narrative guides explain setup and workflows, while generated rustdoc pages provide the API reference. Testing depends on what you are checking: documentation examples and Rust unit tests integrate with KUnit, host-side examples can run through rusttest, and Rust kselftests run on a system booted into the matching kernel.
Where should you look for Rust kernel documentation?
Start with the kernel’s Rust documentation for the Quick Start, General Information, Coding Guidelines, Architecture Support, and Testing guides. These pages explain how to prepare a build, work with kernel Rust code, and choose a testing workflow.
As an Amazon Associate I earn from qualifying purchases.
For item-level API details, use the generated Rust reference documentation. It is produced by rustdoc and complements, rather than replaces, the narrative guides. The kernel overview notes that a kernel configuration may generate HTML Rust documentation. The pregenerated site observed for this article identifies itself as Linux Kernel v7.3-rc6, so check the reference for the version you are targeting.
- Need setup or workflow guidance? Use the narrative guides in the kernel documentation.
- Need to browse documented Rust items and their source? Use the generated rustdoc reference.
What do you need before building Rust-enabled kernel code?
In the target kernel tree, begin with the prerequisite check recommended by the Quick Start:
#1 Best Overall
make LLVM=1 rustavailable
The build requires a compatible Rust toolchain and the Rust standard library source because the kernel build cross-compiles core. It also uses libclang to help bindgen understand kernel C code; bindgen generates bindings to the C side during the build. When the toolchain and other requirements are satisfied, CONFIG_RUST becomes available.
The guide describes a complete LLVM toolchain, invoked with make LLVM=1, as the best-supported setup. GCC works for some configurations, but the guide characterizes that route as experimental. Use the Quick Start for the kernel branch and distribution you are actually building: package names and suitable versions vary, so old package commands may not match your environment.
Rank #2
Build dependencies and developer tools are different
Some tools support building; others help with formatting, linting, documentation, or tests. The Quick Start describes rustfmt for formatting Rust kernel code and generated C bindings, Clippy for additional lint warnings, and rustdoc for generating HTML and testing examples embedded in documentation. The kernel documentation describes distribution packages, rustup, and kernel.org’s prebuilt LLVM+Rust toolchains as ways to obtain dependencies.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Which Rust testing route fits your work?
The kernel testing guide describes three distinct routes. Documentation examples and Rust #[test] suites are mapped to KUnit; kselftests are run from a system booted into the matching kernel. A separate rusttest target runs host-side tests and requires the kernel’s .config.
Rank #3
| What you want to test | Route | Where it runs and key requirements |
|---|---|---|
| Examples in Rust documentation | KUnit documentation tests | Compiled as Rust kernel objects and run against a built kernel; enable CONFIG_RUST_KERNEL_DOCTESTS and the relevant KUnit/Rust configuration. |
| Explicit Rust unit tests | Rust #[test] suites mapped to KUnit, or host-side rusttest |
KUnit suites should be guarded by a Kconfig option in rust/kernel/Kconfig.test. Host-side rusttest uses the kernel .config. |
| Userspace-facing Rust selftests | Rust kselftests | Located in tools/testing/selftests/rust; configure, build, then run on a system booted into the matching kernel. |
Run documentation examples with KUnit
Documentation examples are transformed into KUnit tests. This helps keep public examples aligned with the code and lets them exercise kernel APIs in a kernel test context. The guide’s example command is:
./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch x86_64 --kconfig_add CONFIG_RUST=y
Use the target tree’s Testing guide to check the required configuration, including CONFIG_KUNIT and CONFIG_RUST_KERNEL_DOCTESTS, and adjust architecture or build options for your setup.
Run Rust unit tests
Rust #[test] suites are also mapped to KUnit. The testing guide says each suite should be guarded by a Kconfig option in rust/kernel/Kconfig.test. For host-side testing, the documented target is:
Recommended Free Tools
make LLVM=1 rusttest
This route requires the kernel .config. The Quick Start notes that rusttest uses rustdoc’s example-testing feature, so it is not the same execution context as a KUnit test running against a built kernel.
Run Rust kselftests on a matching kernel
Rust kselftests live in tools/testing/selftests/rust. The testing guide points to tools/testing/selftests/rust/config for the required kernel options. Merge that configuration into the kernel configuration, build the kernel, boot a system into that matching kernel, and then run:
make TARGETS="rust" kselftest
Because kselftests execute from the running system, building them is not enough: run them on a system using the kernel built with the needed options.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How experimental is Rust support in Linux?
Rust support entered mainline in Linux 6.1 as an evaluation of whether Rust was suitable for kernel development. The Linux 6.17 overview still describes support as experimental, particularly for some configurations, and cautions that in-tree Rust drivers or modules should not be treated as production-ready. That is a version-specific statement from the 6.17 overview, not a guarantee about every later kernel release; consult the documentation for the branch you plan to use.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




