Proposal
rustc_codegen_gcc is a new code generation backend for rustc using the libgccjit library from GCC. (Despite its name, libgccjit works for ahead-of-time compilation as well.) rustc_codegen_gcc will allow Rust to target the wider set of architectures that GCC supports. It'll also allow us to generate code optimized via GCC, which in some cases can provide better code generation.
This MCP proposes incorporating rustc_codegen_gcc into rust-lang/rust as compiler/rustc_codegen_gcc (using git subtree), alongside the other code generation backends. This MCP also proposes gating CI on rustc_codegen_gcc building, but not on it passing any tests.
rustc_codegen_gcc currently passes the entire core testsuite; work on the remainder of the testsuite is in progress. rustc_codegen_gcc benefits from the existing infrastructure to annotate tests as requiring a specific backend, so that it doesn't attempt to pass LLVM-specific tests.
If this MCP is accepted, we'll subsequently submit PRs adding it to rust-lang/rust and adding it to the build process. We'll also make a PR to the highfive bot, to automatically CC @antoyo on changes to compiler/rustc_codegen_gcc. In the future, we'll make a separate proposal to distribute rustc_codegen_gcc via rustup.
Licensing
rustc_codegen_gcc uses the same license as rustc: dual MIT / Apache-2.0. The libgccjit library that rustc_codegen_gcc depends on uses the same license as GCC: GPLv3-or-later. This won't affect users of rustc at all, and it won't affect distributors of rustc who do not build or distribute the GCC backend.
Distributors of rustc (including the Rust project itself) who do choose to build or distribute the GCC backend will need to provide the full source for their distribution of rustc under a GPL-compatible Open Source license; rustc and all its dependencies are under GPL-compatible Open Source licenses, so in practice this just means that distributors of rustc who choose to build and distribute the GCC backend need to supply full source code. This does not seem like a practical issue, nor does it change rustc's normal permissive licensing policy, as anyone who wishes to use rustc under a permissive license may simply avoid building or distributing the GCC backend.
We hope that in practice, Linux distributions will build and distribute the GCC backend once it passes enough of the testsuite to be widely useful, and especially once we have targets that depend on it. Other distributors of rustc may choose whether to build and distribute the GCC backend based on their needs.
We will never make any portion of rustc other than rustc_codegen_gcc depend on libgccjit.
Given the value of a GCC backend in expanding Rust's reach to more targets, and thus enabling the use of Rust in projects that need to continue supporting such targets, we believe this represents a reasonable step that will not in practice affect anyone's use, development, or distribution of rustc.
Authors
@antoyo is the primary author of rustc_codegen_gcc, and will continue to maintain it once merged.
@joshtriplett helped with this MCP, and provided guidance and recommendations on licensing.
Mentors or Reviewers
Not sure who to put here.
Process
The main points of the Major Change Process are as follows:
You can read more about Major Change Proposals on forge.
Comments
Proposal
rustc_codegen_gccis a new code generation backend for rustc using thelibgccjitlibrary from GCC. (Despite its name,libgccjitworks for ahead-of-time compilation as well.)rustc_codegen_gccwill allow Rust to target the wider set of architectures that GCC supports. It'll also allow us to generate code optimized via GCC, which in some cases can provide better code generation.This MCP proposes incorporating
rustc_codegen_gccintorust-lang/rustascompiler/rustc_codegen_gcc(usinggit subtree), alongside the other code generation backends. This MCP also proposes gating CI onrustc_codegen_gccbuilding, but not on it passing any tests.rustc_codegen_gcccurrently passes the entirecoretestsuite; work on the remainder of the testsuite is in progress.rustc_codegen_gccbenefits from the existing infrastructure to annotate tests as requiring a specific backend, so that it doesn't attempt to pass LLVM-specific tests.If this MCP is accepted, we'll subsequently submit PRs adding it to
rust-lang/rustand adding it to the build process. We'll also make a PR to the highfive bot, to automatically CC @antoyo on changes tocompiler/rustc_codegen_gcc. In the future, we'll make a separate proposal to distributerustc_codegen_gccviarustup.Licensing
rustc_codegen_gccuses the same license as rustc: dual MIT / Apache-2.0. Thelibgccjitlibrary thatrustc_codegen_gccdepends on uses the same license as GCC: GPLv3-or-later. This won't affect users of rustc at all, and it won't affect distributors of rustc who do not build or distribute the GCC backend.Distributors of rustc (including the Rust project itself) who do choose to build or distribute the GCC backend will need to provide the full source for their distribution of rustc under a GPL-compatible Open Source license;
rustcand all its dependencies are under GPL-compatible Open Source licenses, so in practice this just means that distributors ofrustcwho choose to build and distribute the GCC backend need to supply full source code. This does not seem like a practical issue, nor does it change rustc's normal permissive licensing policy, as anyone who wishes to use rustc under a permissive license may simply avoid building or distributing the GCC backend.We hope that in practice, Linux distributions will build and distribute the GCC backend once it passes enough of the testsuite to be widely useful, and especially once we have targets that depend on it. Other distributors of
rustcmay choose whether to build and distribute the GCC backend based on their needs.We will never make any portion of rustc other than
rustc_codegen_gccdepend onlibgccjit.Given the value of a GCC backend in expanding Rust's reach to more targets, and thus enabling the use of Rust in projects that need to continue supporting such targets, we believe this represents a reasonable step that will not in practice affect anyone's use, development, or distribution of rustc.
Authors
@antoyo is the primary author of
rustc_codegen_gcc, and will continue to maintain it once merged.@joshtriplett helped with this MCP, and provided guidance and recommendations on licensing.
Mentors or Reviewers
Not sure who to put here.
Process
The main points of the Major Change Process are as follows:
@rustbot second.-C flag, then full team check-off is required.@rfcbot fcp mergeon either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments