Open Source Summit Both Linus Torvalds’ Open Source Summit keynote and Jonathan Corbet’s “Kernel Report” discussed efforts to allow Rust modules in Linux.
The next version of the kernel will be 6.0, but as ever, the change of major version number doesn’t denote any major technical changes. Torvalds acknowledged that it might have been desirable to have a headline feature such as “now you can develop drivers in Rust,” but this probably won’t happen until kernel 6.1.
So far, there is a working group, and a preliminary patch has been submitted. There are also two preliminary drivers implemented in the new language, which are discussed in depth over on LWN: a driver for NVMe drives, and an in-kernel server for the 9P network protocol from the Plan 9 operating system.
Some significant issues remain, however. Compilers are a big hurdle: currently, the kernel is usually compiled with GCC, the GNU Compiler Collection, but Rust is usually compiled with the rival LLVM compiler.
This isn’t a complete deal-breaker. The kernel can be built with the LLVM C compiler,
Clang, and the process is documented. It’s the way that Android, ChromeOS, and OpenMandriva compile their kernels. One significant snag with building the kernel with Clang, though, is CPU architecture support. Only x86 and Arm are well supported this way, and other architectures are not as solid yet.
The flip side of compiling the kernel with Clang is compiling Rust with GCC. There is an experimental Rust-on-GCC compiler front end, although the project page notes:
However, as our sister site DevClass reports, this may land in GCC 13. To track the development of Rust in GCC, follow the blog of lead developer Phil Herron.
Developer Miguel Ojeda has written about the reasoning behind the effort, and delivered a status update talk at the Linux Plumbers Conference that overlapped the Open Source Summit. His slides [PDF] have some in-depth info, talking about the potential stability improvements from Rust’s much improved memory safety compared to C.
There’s already a working NVMe driver in the kernel, so the new driver is for research, as developer Andreas Hindborg described in his talk, which followed Ojeda’s presentation – the YouTube video is of the whole Rust micro-conference. Be prepared for it to get technical, as Hindborg’s slides [PDF] demonstrate.
The Reg FOSS desk asked our tame compiler boffin Mark Morgan Lloyd for his assessment of the significance of Rust. As he put it:
Rust obviously uses braces which lulls the incautious into a sense of security. However, its underlying assignment model is sufficiently novel that I’m inclined to call it a sibling of ALGOL rather than a derivative… and just about every general-purpose language (except Smalltalk, LISP, Forth and APL) is a derivative of ALGOL, so you see how big it is.
One risk of its adoption, though, was summarized in LWN executive editor Jonathan Corbet’s Kernel Report. To quote “a longtime kernel develper” from his slides [PDF], the problem is not just conservatism among developers, but the implication that Rust is desirable simply because of its memory safety: