Linux Developers Continue Evaluating The Path To Adding Rust Code To The Kernel

Written by Michael Larabel in Linux Kernel on 27 August 2020 at 06:38 PM EDT. 59 Comments
LINUX KERNEL
As mentioned back in July, upstream Linux developers have been working to figure out a path for adding Rust code to the Linux kernel. That topic is now being further explored at this week's virtual Linux Plumbers Conference and it's still looking like it will happen, it's just a matter of when the initial infrastructure will be in place and how slowly the rollout will be.

Back in July, Linus Torvalds shared his thoughts on Rust within the Linux kernel tree and didn't shoot down the idea just his preference on how it be handled, basically having it be enabled if Rust is present on the system.

To be clear though, these Rust Linux kernel plans do not involve rewriting large parts of the kernel in Rust (at least for the foreseeable future...), there would be caveats on the extent to which Rust code could be used and what functionality, and the Rust support would be optional when building the Linux kernel. C would remain the dominant language of the kernel and then it's just a matter of what new functionality gets added around Rust if concerned by memory safety, concurrency, and other areas where Rust is popular with developers.

Various upstream developers have been interested in Rust for those language benefits around memory safety and security as well as its syntax being close to C. There would be a to-be-determined subset of Rust to be supported by the Linux kernel.

Besides figuring out the limits of the Rust support within the kernel, also being figured out is the Kbuild/Kconfig build integration, whether to make use of Rust's Cargo as a builder, and other guidelines such as ensuring all the Rust code remains in-tree (not using Cargo to fetch external code).

While the Rust code would be optional, the developers do acknowledge there are limitations on where Rust is supported due to the LLVM compiler back-ends. But at least for x86/x86_64, ARM/ARM64, POWER, and other prominent targets there is support along with the likes of RISC-V.

Nothing firm has been determined yet but it's a topic that is still being discussed at the virtual LPC this week and surely over the weeks/months ahead on the kernel mailing list. There is Rust-For-Linux on GitHub with a prototype kernel module implementation. There is also the PDF slides from today's talk on the matter.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week