Future Tech

If GNU please: Rust support merged for the forthcoming GCC 13

Tan KW
Publish date: Thu, 15 Dec 2022, 09:11 PM
Tan KW
0 462,818
Future Tech

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.

So far, there have been three "editions" of the language, which the Rust book defines as follows:

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 own release history lists 21 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

When considering Rust in different places, its version numbers become highly significant. As LWN reported, the Linux kernel 6.1 preliminary support for Rust stipulates version 1.62, released in June.

As we write, the current version of Rust is version 1.65.0. Rust 1.4, which is what the Rust-on-GCC support is currently aiming at, is quite a lot older: it was announced on October 29, 2015.

That looks like quite a significant gap to us. The version of the patch-set that was accepted is the fourth, and contributor Arthur Cohen also 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.

 

https://www.theregister.com//2022/12/15/gcc_13_rust_support_merged/

Discussions
Be the first to like this. Showing 0 of 0 comments

Post a Comment