This article is more than 1 year old
Rusty Linux kernel draws closer with new patch adding support for Rust as second language
Experimental – but good enough to start writing 'drivers and other modules'
A new patch was this week submitted to the Linux Kernel mailing list, progressing the Rust for Linux Kernel project.
The new patch will "add support for Rust as a second language to the Linux kernel," alongside the current C language. The previous patch was in July this year.
Notable in this latest patch is use of the stable release of the Rust compiler, though the project still requires some compiler features that are unstable.
"We will keep upgrading until we do not rely on any unstable features," wrote project lead Miguel Ojeda.
Ojeda is sponsored by Google via the ISRG (Internet Security Research Group, best known for Let's Encrypt) to work on Rust for Linux and other security efforts. Although security is not the only reason, Rust for the Linux Kernel is considered a security project. As ISRG executive director Josh Aas explained, "by making it possible to write parts of the Linux kernel in Rust, which is memory-safe, we can entirely eliminate memory safety vulnerabilities from certain components, such as drivers."
The new patch also adds abstractions for various kernel features.
Ojeda noted that Red Hat has come up with a support statement for the project, saying "there is interest in using Rust for kernel work that Red Hat is considering."
This is alongside earlier statements from Microsoft, Arm, and of course Google. Red Hat's statement is muted compared to, for example, Arm which said "Rustaceans at Arm are excited about the Rust for Linux initiative and look forward to assisting in this effort."
However it is still significant, bearing in mind the wide use of Red Hat Enterprise Linux and its derivatives.
- Keep calm and learn Rust: We'll be seeing a lot more of the language in Linux very soon
- Can Rust save the planet? Why, and why not
- Rust dust-up as entire moderation team resigns. Why? They won't really say
The GCC (GNU Compiler Collection) backend for the Rust compiler rustc_codegen_gcc has been merged into Rust, a step towards being able to compile Rust with GCC.
The stated benefit is "to be able to compile Rust code on platforms unsupported by LLVM. A secondary goal is to check if using the gcc backend will provide any run-time speed improvement for the programs compiled using rustc."
Ojeda said that experimental compilation of "the Rust side of the kernel" with GCC should follow soon. However the primary compiler for Rust for the kernel is LLVM via rustc_codegen_llvm.
Ojeda said that "the Rust support is still to be considered experimental. However, support is good enough that kernel developers can start working on the Rust abstractions for subsystems and write drivers and other modules."
Documentation is here. Ojeda also promised to start submitting kernel patches "every two weeks or so," accelerating progress. ®