BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Linux 6.1 Officially Adds Support for Rust in the Kernel

Linux 6.1 Officially Adds Support for Rust in the Kernel

After over two years in development, support for using Rust for kernel development has entered a stable Linux release, Linux 6.1, which became available a couple of weeks ago.

Previous to its official release, Rust support has been available in linux-next, the git tree resulting from merging all of the developers and maintainers trees, for over a year. With the stable release, Rust has become the second language officially accepted for Linux kernel development, along with C.

Initial Rust support is just the absolute minimum to get Rust code building in the kernel, say Rust for Linux maintainers. This possibly means that Rust support is not ready yet for prime-time development and that a number of changes at the infrastructure level are to be expected in coming releases. Still, there has been quite some work work going on on a few actual drivers that should become available in the next future. These include a Rust nvme driver, a 9p server, and Apple Silicon GPU drivers.

Rust for Linux is only available on the architectures supported by LLVM/Clang (https://github.com/Rust for Linux/linux/blob/rust/Documentation/rust/arch-support.rst), which is required to compile Rust. Thus, LLVM/Clang must be used to build the whole Linux kernel instead of the more traditional GNU toolchain. This limits supported architecture to a handful, including arm, arm64, x86, powerps, mips, and others. For detailed instructions about building Linux with the appropriate flag for each supported platform, check the official documentation (https://github.com/Rust for Linux/linux/blob/rust/Documentation/kbuild/llvm.rst).

One of the key parts of Rust for Linux is bridging the Rust world, where the compiler can provide memory safety guarantees, and the C world, where no such guarantees exist. To enable the use of functions and types available in C, Rust for Linux creates bindings, which are a set of Rust declarations translating their C-layer counterparts into Rust.

In addition to bindings, Rust for Linux also uses abstractions, which are Rust wrappers built around C code available in the kernel. Abstractions are meant to allow developers to write Rust drivers without directly accessing the C bindings, but they are only available for a limited number of kernel APIs at the moment. However, their number will grow as Rust for Linux will be further developed, say the maintainers.

About the Author

Rate this Article

Adoption
Style

BT