Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Linux kernel Rust work is documented in two places: narrative guides explain setup and workflow, while generated rustdoc pages let you browse the Rust API and its source. Testing also has three distinct routes: documentation examples and Rust unit tests can run through KUnit, while Rust kselftests run on a system booted into the matching kernel.

Where Linux kernel Rust documentation lives

Start with the kernel’s Rust documentation overview. It links to the Quick Start, General Information, Coding Guidelines, Architecture Support, and Testing guides. These narrative pages explain how to configure a kernel tree, work with Rust code, and choose a test workflow.

The generated API reference serves a different purpose: it lets you browse documented Rust items and their source. The overview describes it as HTML that the kernel may generate with rustdoc for a given kernel configuration, and points to the pregenerated reference at rust.docs.kernel.org. The observed generated site version was Linux Kernel v7.3-rc6; the reference may track a different version from the kernel tree you are using, so verify that its APIs match your branch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare a Rust-enabled kernel build

Use the Quick Start for prerequisites that match your kernel branch and development environment. Rather than relying on an old distribution-specific package recipe, begin by checking whether the build system recognizes the required tools:

#1 Best Overall
make LLVM=1 rustavailable

The kernel needs Rust standard-library source because it cross-compiles core. It also needs libclang for bindgen to understand kernel C code; bindgen generates Rust bindings to that C code during the build. When a suitable toolchain and the other requirements are met, CONFIG_RUST becomes available.

The Quick Start identifies a complete LLVM toolchain, used with make LLVM=1, as the best-supported setup. GCC works for some configurations, but the guide describes that path as experimental in this context. Exact package names and versions vary by distribution and kernel branch, so use the Quick Start for the tree you intend to build.

Build tools and developer tools are not the same thing

Rust support also involves tools used during development, but they do not all serve as build prerequisites:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • rustfmt formats Rust kernel code and generated C bindings.
  • Clippy provides additional lint warnings.
  • rustdoc generates HTML documentation and tests examples embedded in documented code.

The Quick Start describes distribution packages, rustup, and kernel.org’s prebuilt LLVM+Rust toolchains as ways to obtain dependencies. Choose versions for the target branch rather than assuming a package command from another distribution will apply.

Rank #3
Linux Kernel Development
  • Used Book in Good Condition

Choose the test route that matches your code

The kernel’s Rust testing guide separates documentation tests, Rust #[test] suites, and Rust kselftests. The key distinction is where the test runs and what it is meant to validate.

Test route What it checks Where it runs
KUnit documentation tests Examples in Rust documentation, transformed into KUnit tests As Rust kernel objects against a built kernel
Rust #[test] tests Explicit Rust test suites Through KUnit in the kernel, or with the documented host-side rusttest target
Rust kselftests Rust selftests under tools/testing/selftests/rust On a system running the matching kernel

Test examples in documentation with KUnit

Documentation examples are transformed into KUnit tests and compiled as Rust kernel objects. This route helps check that examples remain aligned with kernel code and can exercise kernel APIs through KUnit. The guide demonstrates this command for an x86_64 build:

./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch x86_64 --kconfig_add CONFIG_RUST=y

The relevant configuration options include CONFIG_KUNIT and CONFIG_RUST_KERNEL_DOCTESTS. Check the testing guide for the exact configuration and command details for your tree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run Rust #[test] suites

Rust #[test] tests are also mapped to KUnit. Each suite should be guarded by a Kconfig option in rust/kernel/Kconfig.test. For host-side tests, the guide documents:

make LLVM=1 rusttest

This target requires the kernel’s .config. The Quick Start notes that rusttest uses rustdoc’s example-testing feature, so it is a host-side route distinct from running KUnit tests as part of a kernel build.

Run Rust kselftests on the matching kernel

Rust kselftests are located in tools/testing/selftests/rust. The guide points to tools/testing/selftests/rust/config for required kernel options. Merge that configuration before building, then run the test target from a system booted into the matching kernel:

make TARGETS="rust" kselftest

This is the route to use when you need to exercise the selftests in the context of a running kernel, rather than test documentation examples or host-side Rust tests.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What Rust support means for kernel versions

Rust support was merged into mainline in Linux v6.1 to evaluate whether Rust was suitable for kernel development. The official v6.17 overview describes support as experimental, particularly for some configurations, and says there are no in-tree Rust drivers or modules suitable or intended for production use. That is a version-specific statement, not a timeless description: check the documentation for the kernel version you plan to use before drawing conclusions about its maturity or available code.

For everyday work, use the narrative guides for setup and workflow, the generated reference for API browsing, and the testing guide to select a test path. Confirm options and commands against the target kernel tree, since toolchain requirements and test configuration can change across branches.

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.