-
Notifications
You must be signed in to change notification settings - Fork 558
Add missing documentation for running tests with GCC backend #2587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GuillaumeGomez
merged 2 commits into
rust-lang:master
from
GuillaumeGomez:gcc-backend-missing-docs
Sep 18, 2025
+55
−2
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,56 @@ | ||
# GCC codegen backend tests | ||
# GCC codegen backend | ||
|
||
TODO: please add some more information to this page. | ||
If you ran into an error related to tests executed with the GCC codegen backend on CI, | ||
you can use the following command to run tests locally using the GCC backend: | ||
|
||
```bash | ||
./x test tests/ui --set 'rust.codegen-backends = ["llvm", "gcc"]' --test-codegen-backend gcc | ||
``` | ||
|
||
Below, you can find more information about how to configure the GCC backend in bootstrap. | ||
|
||
## Choosing which codegen backends are built | ||
|
||
The `rust.codegen-backends = [...]` bootstrap option affects which codegen backends will be built and | ||
included in the sysroot of the produced `rustc`. To use the GCC codegen backend, `"gcc"` has to | ||
be included in this array in `bootstrap.toml`: | ||
|
||
```toml | ||
rust.codegen-backends = ["llvm", "gcc"] | ||
``` | ||
|
||
If you don't want to change your `bootstrap.toml` file, you can alternatively run your `x` | ||
commands with `--set rust.codegen-backends=["llvm", "gcc"]'`. For example: | ||
|
||
```bash | ||
./x build --set 'rust.codegen-backends=["llvm", "gcc"]' | ||
``` | ||
|
||
The first backend in the `codegen-backends` array will determine which backend will be used as the | ||
*default backend* of the built `rustc`. This also determines which backend will be used to compile the | ||
stage 1 standard library (or anything built in stage 2+). To produce `rustc` that uses the GCC backend | ||
by default, you can thus put `"gcc"` as the first element of this array: | ||
|
||
```bash | ||
./x build --set 'rust.codegen-backends=["gcc"]' library | ||
``` | ||
|
||
## Choosing the codegen backend used in tests | ||
|
||
To run compiler tests with the GCC codegen backend being used to build the test Rust programs, you can use the | ||
`--test-codegen-backend` flag: | ||
|
||
```bash | ||
./x test tests/ui --test-codegen-backend gcc | ||
``` | ||
|
||
Note that in order for this to work, the tested compiler must have the GCC codegen backend available in its sysroot | ||
directory. You can achieve that using the [instructions above](#choosing-which-codegen-backends-are-built). | ||
|
||
## Downloading GCC from CI | ||
|
||
The `gcc.download-ci-gcc` bootstrap option controls if GCC (which is a dependency of the GCC codegen backend) | ||
will be downloaded from CI or built locally. The default value is `true`, which will download GCC from CI | ||
if there are no local changes to the GCC sources and the given host target is available on CI. | ||
|
||
Note that GCC can currently only be downloaded from CI for the `x86_64-unknown-linux-gnu` target. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this can hit any contributor in any PR, I think it should be possible to run these tests in a one-shot way without permanently altering one's configuration.
I don't know what exactly altering the config in this way does, but if it means during my next PR it will build this backend, then that's not great -- it's unlikely to be relevant again then.
Please put yourself into the shoes of a rustc contributor that has nothing to do with the GCC backend, and is unlikely to encounter it for most of their PRs -- and tell that contributor what they should do to fix the PR where this weird failure they didn't expect shows up. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done with
./x test ... --test-codegen-backend gcc --set 'rust.codegen-backends=["llvm", "gcc"]'
. A bit of a mouthful, but it will likely be copy-pasted from the docs anyway, or stored in some local helper file.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhere on this page, in a super obvious place that the reader will find immediately when going here the first time (i.e., probably at the top), should be a command to copy-paste to run the tests. That's still not the case, isn't it? I have to copy multiple things together to get the actual command I need to use.
I don't know how much more clear I can be about optimizing this for an inexperienced contributor who doesn't want to do much work on the GCC backend, they just want to fix their PR. Or even an experienced contributor who doesn't normally touch GCC but has their tests fail in GCC every 4 months (i.e., too rarely to remember the command). Please, when writing this, put yourself in the shoes of such a contributor, not in the shoes of someone who's been working on rustc and its GCC backend for years.
I think that command is
but I am not actually sure.