The open source GCC (GNU Compiler Collection) has “voted” to approve the contribution of the Rust Frontend (aka GCC Rust) to GCC.
David Edelsohn, a founding member of the GCC Steering Committee, said in a statement: “we look forward to including a preliminary, beta version of GCC Rust in GCC 13.”
GCC typically has an annual release schedule. Version 12.1 was released in May 2022 so we might expect GCC 13, currently in Stage 1 of its development according to the GCC development plan, around May next year.
The importance of this project is its significance for Linux, generally built with GCC, where plans to allow Rust to be used alongside C for kernel code, for memory safety reasons, are steadily advancing – though while supportive, Linux inventor Linus Torvalds also said last month that “We tried C++ 25-plus years ago and we tried it for two weeks and then we stopped trying it. So to me, Rust is a way to try something new,” implying that the initiative remains experimental.
The open source GCC (GNU Compiler Collection) already has a backend for Rust, a project called rustc_codegen_gcc founded by Antoni Boucher. It is still described as work in progress, but was merged into the main Rust repository in September 2021.
This means that the Rust compiler, rustc, can be used with the GCC backend, the backend being the code generator which supports more CPU architectures than LLVM, the usual Rust backend compiler, though there are limitations such as requiring a patched version of GCC.
The alternative is to have a complete GCC toolchain. In January 2021 Open Source Security, Inc, creators of a hardened version of the Linux kernel called Grsecurity, said that it would fund a “public development effort” of a GCC frontend for Rust, the rationale being improved security from no longer having to mix different compilers. The company cited a paper which shows “how the overall security of an execution environment can be reduced by the introduction of code written in Rust or that of another language where the same binary-level security is not provided by the compiler.”
The outcome was that Belfast-based Philip Herron was funded to work on gccrs, “a full alternative implementation of the Rust language ontop of GCC with the goal to become fully upstream with the GNU toolchain.” The work is described as “in a very early stage and not usable yet for compiling real Rust programs.” One of the issues addressed in the FAQ is that “Rust currently lacks a full language specification,” though it is hoped that the project will help to address this. Benefits include full link time optimization (LTO) as well as the security issue mentioned above, and the ability to target more CPU architectures.