Skip to content

Merge rustc_codegen_gcc backend as compiler/rustc_codegen_gcc #442

Closed
@antoyo

Description

@antoyo

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:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was accepted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions