Rust Support Is Being Built into the GNU GCC Compiler
thenewstack.io
thenewstack.io
I can definitely see many advantages in Rust that would add value to the Linux kernel. However, I feel like there are two definite things currently missing in the language that need to be implemented ASAP for the rust + linux kernel story to truly work.
Panics (Rust's term for exiting a program when encountering an unhandled error) are a good idea in most environments - instead of reading or writing past a vector's last element, the program immediately exits. This approach falls through when you're in an incredibly high stakes environment that must absolutely avoid crashes. Sure, you can catch some panics [0], but you can not easily avoid them entirely. There is no surefire way to know if subroutines any level deep may panic. Linus himself mentioned this problem, so I think handling it should be a top priority.
What's also definitely missing is an allocator strategy. Zig is a good example for this, you can choose the exact allocation method that fits your model.
[0]: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html#not...
Catching these bugs before they cause damage is an improvement to stability. In Rust you can compartmentalize panics. Instead of messing up the whole kernel or causing a machine-halting kernel panic, you can gracefully unwind one call and execute a fallback or return an error code from the one syscall that hit the bug. That is how you can continue running the kernel reliably instead of hoping to get lucky.
Then, there was a miscommunication between the Linux Rust project and Linus, about an issue that does not exist any more. An early draft had a handler that translated OOM to kernel panics as a kludge from use of Rust's standard library containers as a placeholder for proper containers being developed. Linus rightly criticized that this was a bad idea, but it was never meant to be the final setup. That code has been replaced now, and Rust in the kernel uses fallible allocation that does not abort nor panic. The issue does not exist in the no-alloc Rust dialect used in the kernel going forward.
Rust by way of GCC is great news and will do wonders for helping Rust expand further into the C/C++ dominated world of embedded programming where a lot of hardware lacks the support of LLVM and thus Rust proper.
https://github.com/rust-GCC/cargo-gccrs/
it's still in a relatively early stage as we are focusing on the compiler. But the idea is for it to be a drop-in replacement for compilation and execution operations, so you'd have `cargo gccrs build`, `cargo gccrs run`, `cargo gccrs test`, etc