January 4, 2024 R Software Solution Rust in Linux: Where we are and where we’re going next Specifically, as Alex Gaynor and Geoffrey Thomas explained at the 2019 Linux Security Summit, almost two-thirds of Linux kernel security holes come from memory safety issues. And where do those errors come from? Inherent weaknesses in C and C++. Rust, on the other hand, avoids these problems by using far safer application programming interfaces (APIs). Also: 8 things you can do with Linux that you can’t do with MacOS or Windows That’s not to say that we’re ready to retire C for Rust just yet. In fact, that day is unlikely ever to come. But Rust is definitely on its way to becoming an important language for Linux development. Before we reach that destination, there are some challenges to overcome. As Ojeda said at the event, while the “core team has grown with new members”, there’s still a lot of work to be done. That effort starts with programming tools for Rust on Linux. Some distros are already embracing Rust with open arms. For example, Ubuntu now provides “all the necessary toolchain and kernel requirements to build and test out-of-tree kernel modules.” Today, there are three major Linux Rust toolchains coming together. The first of these is GCC codegen for rustc. This toolchain compiles and can boot mainline Rust and Linux without source code changes. Then, there’s GCC Front-End for Rust, which can be loaded by the existing rustc frontend, but benefits from GCC optimizations. Unfortunately, this project is still very much alpha code. Finally, there’s Coccinelle for Rust. Coccinelle is a tool for making large-scale Linux kernel C source code, and Coccinelle for Rust is seeking to bring this power to Rust codebases. Also: The best Linux distros for beginners As for the day-to-day work that’s required to make Rust fully integrated with Linux, the “official” website of the initiative is now the self-explanatory Rust for Linux. This site is your one-stop source for all things Rust on Linux. The original rust code branch, where development happened for two years, has been retired. The code is still there, but it’s been frozen and archived. Moving forward, rust-next will be the branch that contains new Rust features to be submitted during the next merge window of the Linux kernel. This branch, as the name suggests, is part of Linux Next. Rust-fixes, meanwhile, is the branch that contains Rust fixes for the current cycle of the Linux kernel. In addition, Rust-dev is an experimental branch for integration purposes. It’s a queue for patches that “look good enough” to share and tinker with. However, the move forward has not been straightforward. Rust on Linux developers have discovered some problems along the way. For example, while deadlocks, when two or more threads are waiting on the other to finish, are safe in Rust, because they don’t result in undefined behavior, they’re not safe in the Linux kernel. The programmers are working on fixing this issue. Also: How to create a bootable Linux USB drive The developers are also worrying about is how to deal with Rust versions. Today, developers can’t guarantee that newer Rust versions will work in Linux because the latest version of Rust Linux is compatible with some unstable features. Will these features be there in the next version of Rust? Will they be backward compatible? Stay tuned. For now, Linux Rust programmers are tracking the latest version of the Rust compiler. That’s quite an unusual approach for the kernel, where the name of the game is usually to use old, proven code. A related issue is that there’s growing interest in backporting Rust support into long-term support (LTS) versions of Linux, specifically 5.15 and 6.1. Some people are especially showing interest in the super LTS Linux 6.1 kernel. However, Linux doesn’t generally allow backports into LTS Linuxes. So, if you really, really want fully featured Rust support in an older LTS kernel, you’re going to need to pay for it in one way or the other. Another general rule that Rust developers have decided they’re going to try to “break” is the rule against duplicate drivers. Usually, no one wants anyone wasting time reinventing the wheel, but some maintainers are open to the idea of experimenting with Rust, by starting simple with a driver they’re already familiar with. Also: If you want to try BSD, GhostBSD might be your best bet Still, others have expressed an interest in writing Rust drivers, but the required abstractions are not there, and merging would break the “no code without an expected in-tree user” rule. So, Ojeda and his merry crew of Rust developers have requested an exception for Rust drivers. These movements are small steps forward, but they’re all critical for making Rust equal to C as a Linux programming language. Based on the high interest I saw at Plumbers, I fully expect that Rust will, eventually, get there. Linux The best Linux laptops for consumers and developers Want to save your aging computer? Try these 5 Linux distributions The best distros for beginners How to enable Linux on your Chromebook (and why you should) The best Linux laptops for consumers and developers Want to save your aging computer? Try these 5 Linux distributions The best distros for beginners How to enable Linux on your Chromebook (and why you should) Article source: https://www.zdnet.com/article/rust-in-linux-where-we-are-and-where-were-going-next/#ftag=RSSbaffb68