If GNU please: Rust support merged for the forthcoming GCC 13
But don't get too excited. It's as preliminary as the kernel support
Updated Preliminary support for compiling the Rust language has been merged into the codebase for GCC 13, which will be the next version of the GNU compiler collection.
The Reg's sister site DevClass reported on the approval back in July, along with a timeline of when to expect the next steps, and now the code merge has happened. This is a good thing, and it's significant step for the Rust language – but there is a whole list of "buts" attached to this news.
The Rust-GCC project has been underway for a couple of years, as can be seen from the earliest commits on its Github page. The last time we wrote about it, when covering Linus Torvalds' keynote at the Open Source Summit, we attracted criticism for, um, quoting the project's own description from that page, saying how preliminary it was. Some Rustaceans regarded this as unfair, which may possibly tell you more about the fervor of Rust fans than it tells you about the GCC compiler's state of completion.
Support in GCC will mean that there are two compilers able to build Rust code. The Rust Project itself is building the language using LLVM, a suite of tools for building compilers, such as the Clang C compiler that's been favored by Apple since XCode 3.2 for Mac OS X 10.6 "Snow Leopard", back in 2009.
(Incidentally, Apple built tooling to use LLVM as an optimizing back-end to GCC, and offered the code to the GNU Project, but it was rejected, in part because the code was in C++, the language LLVM is built in. GCC, like much of the GNU Project, is built in C. This highlights just one fundamental difference in the path of bringing Rust to GCC.)
For a compiled programming language, having more than a single compiler is an important sign of its maturity and stability. But Rust is relatively new, and only attained version 1.0 in 2015, as we noted when covering its fifth birthday a couple of years ago. That means it's a moving target for the team working on the GCC compiler to try to hit.
At the time of this writing, three Rust editions are available: Rust 2015, Rust 2018, and Rust 2021.
Another way to track its evolution is the version numbers. So far, the project's release history lists various versions (omitting alphas and betas). The email message from the GCC mailing list accepting the Rust patch set quotes from Rust-on-GCC project lead Philip Herron's submission email:
For some context, my current project plan brings us to November 2022 where we (unexpected events permitting) should be able to support valid Rust code targeting Rustc version ~1.40
As we write, the current version of Rust is version 1.65.0. Rust 1.40, which appears to be what the Rust-on-GCC support is currently aiming at, was released on December 19, 2019. Rust 1.49.0 came out on December 31, 2020.
- Open source community split over offer of 'corporate' welfare for critical dev tools
- The GNOME Project is closing all its mailing lists
- 'Merge window from Hell' opens as Linus Torvalds reveals Linux 6.1
- MacOS9.app: A tour de force of emulation and integration
- Big changes coming in Debian 12: Some parts won't be FOSS
- Open source databases: What are they and why do they matter?
The version of the patch-set that was accepted is the fourth, and contributor Arthur Cohen posted some words of caution:
Please note however that despite the language being in, the compiler is still at an extremely early stage. We are still not able to properly compile Rust code in the version that we target, 1.49.
To do anything meaningful with the language, you will also need the core library, which again, we cannot compile yet in its 1.49 version.
This is very much an extremely experimental compiler and will still get a lot of changes in the coming weeks and months up until the release.
The Rust-on-GCC project isn't the only alternative Rust toolchain being worked on. MrustC, or Mutabah's Rust Compiler, is another, being implemented in C++ and which emits, as the project page puts it, "currently very ugly C, but LLVM/cretone/GIMPLE/… could work". There's also rustc_codegen_gcc, a work-in-progress GCC code generator that uses libgccjit.
All this activity is very encouraging, though. In our recent story about Linux support for laptop and desktop Arm kit, we reported the very favorable comments about Rust from the developer working on the graphics drivers for the GPU in Apple's M1-powered Macs. With open source code, often a big hurdle is getting a first version out there; after that, people pile in with bug fixes and performance improvements, and things can then improve surprisingly rapidly. ®
On an earlier version of this piece, we mistakenly referred to Rust 1.4 rather than Rust 1.40, which as some of you noticed was released in late 2019, a smidge more recently than 1.4's October, 2015 release date. Our thanks to readers who wrote in to let us know.