Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

Rust for Linux: Where to Find the Docs and Run Tests

The Linux kernel’s Rust guides cover setup and workflow; generated rustdoc provides the API reference. Choose KUnit, rusttest, or kselftests based on where and what you need to test.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • 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:

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.

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.

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

Which 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.

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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.Support on Ko-Fi

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.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.