The effort to bring Rust to the Linux kernel marches on this week, with an update from Rust for Linux project maintainer Miguel Ojeda put out this week serving as cause for renewed excitement. While the update cautions that Rust support is “still to be considered experimental,” it notes that the project has moved on from using the beta Rust compiler to use stable releases, starting with Rust 1.57.0, which was just released last Thursday.
In addition, the project has migrated to the 2021 edition of Rust, and plans to migrate to new stable compilers each time one is released.
Rust is now an official language for Linux development.🎉
C and C++ have lead to lots of memory safety issues over the years. Rust can prevent these. A lot of new Linux code will be in Rust.
You can learn Rust for free, interactively in your browser: https://t.co/qGofxZNvK4
— Quincy Larson (@ossia) December 8, 2021
“By upgrading the compiler, we have been able to take off the list a few unstable features we were using,” Ojeda wrote, further noting that “we will keep upgrading until we do not rely on any unstable features; at which point we may want to start declaring a minimum Rust version is supported like it is done, e.g. GCC and Clang.”
With this update, Ojeda also said that, while still experimental, “support is good enough that kernel developers can start working on the Rust abstractions for subsystems and write drivers and other modules,” which has generally been the plan all along.
When we first looked at the idea of Rust in the Linux kernel, it was noted that the objective was not to rewrite the kernel’s 25 million lines of code in Rust, but rather to augment new developments with the more memory-safe language than the standard C normally used in Linux development.
Part of the issue with using Rust is that Rust is compiled based on LLVM, as opposed to GCC, and subsequently supports fewer architectures. This is a problem we saw play out when the Python cryptography library replaced some old C code with Rust, leading to a situation where certain architectures would not be supported. Hence, using Rust for drivers would limit the impact of this particular limitation.
I love that the Linux kernel is getting Rust support
A bitter-sweet moment for me – today I can read the Linux C code and understand it, and I can barely grasp Rust code. It feels even harder than reading modern C++
But writing new code in C or C++ is a crime, this must be done
— Miguel “mask and vax” de Icaza (@migueldeicaza) December 8, 2021
Ojeda further noted that the Rust for Linux project has been invited to a number of conferences and events this past year, and even garnered some support from Red Hat, which joins Arm, Google, and Microsoft in supporting the effort. According to Ojeda, Red Hat says that “there is interest in using Rust for kernel work that Red Hat is considering.”
On that note of Rust being compiled with LLVM instead of GCC, Ojeda also says that the GCC backend for the Rust compiler was merged into upstream Rust, and that “If the backend keeps progressing, we hope to soon be able to start experimenting with compiling the Rust side of the kernel with GCC!”
This Week in Programming
- GitHub Updates Its Code Search: GitHub has introduced a preview of its improved code search that it says will offer “substantial improvements to searching code on GitHub.” At launch, the new feature will cover more than 5 million of the most popular public repositories, alongside the code in your own private repositories, and supports a number of ways to search code — exact strings, regular expressions, Boolean operators, and scoping according to project, repository, organization and more. The feature isn’t fully available yet, but you can sign up for the waitlist now to be included in the preview. While you can read all about how the search works, this is one of those things that just works better when you see it, so give the intro video a quick viewing and check out what’s coming to a GitHub near you.
- …And Python Code Navigation: Alongside the news of GitHub’s improved code search, the company also released precise code navigation for Python, and code navigation in pull requests, both of which are generally available. The code navigation in pull requests change brings code navigation directly into the “files changed” tab of pull requests, rather than just in GitHub’s code browser, while precise code navigation for Python offers a precise definition rather than the “fuzzy” one previously offered. The Python feature is powered using the stack graphs framework also introduced this week and, while only supporting Python currently, will add other supported languages in the coming months.
- GitHub Actions Gets Container Signing: One last update this week from GitHub — the company has introduced the ability to safeguard your containers with a new container signing capability in GitHub Actions, which comes to it partly by way of the Open Software Security Foundation (OpenSSF), of which it is a founding member. Specifically, the OpenSSF hosts the Sigstore project, which allows developers to securely build, distribute and verify signed software artifacts, and GitHub has announced that it has “integrated Sigstore support for container image signing into the GitHub Actions starter workflow, so that developers can sign their container images by default.” The new feature will help to ensure that the code you pull from a container registry is actually what you think it is, and not something that could introduce a vulnerability. To get started, check out the starter workflow template that lets you take advantage of keyless signing when run from a public repository.
I got an email from my washing machine letting me know aws-1-east was out. so that’s…a thing.
— Rin Oliver, festive edition (they/he) (@kiran_oliver) December 8, 2021
- What Do You Want From Rust? The time has come for all you Rustaceans to let your voices be heard, as the 2021 State of Rust Survey has launched. The report examines who makes up the Rust community, how the project itself is doing, and what can be improved — and all of that is gathered by you filling out the survey. The anonymous questionnaire takes anywhere from 10 to 30 minutes and runs until December 22, so get on it. The findings from this year’s survey will be posted to the Rust Blog and you can also check out last year’s results.
- Kotlin Features Survey Results Arrive: While we’re talking about surveys, the results are in from the 2021 Kotlin Features Survey. The survey asked Kotlin developers what were the most awaited features in Kotlin and, while they note that the survey was “not exhaustive” and that it would not guarantee that “any of these features will make it into the language any time soon, even if they have received a lot of votes” they do say that “your votes help us to prioritize our work over the long term.” Well, despite that rather unencouraging aside, the researchers said that they received 1,540 complete responses and that the top three most desired features include multicatch and union types (45%), collection literals (32%), and multiple receivers on extension functions and properties (30%). For more on the results, where they are in the process of implementing these features, and other highly sought features, head on over to the blog post.
My younger son said “coding is basically just ifs and for loops.”
— John Carmack (@ID_AA_Carmack) December 4, 2021
Red Hat OpenShift is a sponsor of The New Stack.