Skip to content

Commit 5189a68

Browse files
committed
Overhaul GCC codegen backend section
1 parent 16061dc commit 5189a68

File tree

2 files changed

+30
-41
lines changed

2 files changed

+30
-41
lines changed

src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# GCC codegen backend
22

3-
If you ran into an error related to tests executed with the GCC codegen backend on CI,
4-
you can use the following command to run UI tests locally using the GCC backend:
3+
We run a subset of the compiler test suite with the GCC codegen backend on our CI, to help find changes that could break the integration of this backend with the compiler.
4+
5+
If you encounter any bugs or problems with the GCC codegen backend in general, don't hesitate to open issues on the
6+
[`rustc_codegen_gcc` repository](https://github.com/rust-lang/rustc_codegen_gcc).
7+
8+
Note that the backend currently only supports the `x86_64-unknown-linux-gnu` target.
9+
10+
## Running into GCC backend CI errors
11+
12+
If you ran into an error related to tests executed with the GCC codegen backend on CI in the `x86_64-gnu-gcc` job,
13+
you can use the following command to run UI tests locally using the GCC backend, which reproduces what happens on CI:
514

615
```bash
716
./x test tests/ui \
@@ -12,7 +21,13 @@ you can use the following command to run UI tests locally using the GCC backend:
1221

1322
If a different test suite has failed on CI, you will have to modify the `tests/ui` part.
1423

15-
Below, you can find more information about how to configure the GCC backend in bootstrap.
24+
To reproduce the whole CI job locally, you can run `cargo run --manifest-path src/ci/citool/Cargo.toml run-local x86_64-gnu-gcc`. See [Testing with Docker](../docker.md) for more information.
25+
26+
### What to do in case of a GCC job failure?
27+
28+
If the GCC job test fails and it seems like the failure could be caused by the GCC backend, you can ping the [cg-gcc working group](https://github.com/orgs/rust-lang/teams/wg-gcc-backend) using `@rust-lang/wg-gcc-backend`
29+
30+
If fixing a compiler test that fails with the GCC backend is non-trivial, you can ignore that test when executed with `cg_gcc` using the `//@ ignore-backends: gcc` [compiletest directive](../directives.md).
1631

1732
## Choosing which codegen backends are built
1833

@@ -49,13 +64,22 @@ To run compiler tests with the GCC codegen backend being used to build the test
4964
./x test tests/ui --test-codegen-backend gcc
5065
```
5166

52-
Note that in order for this to work, the tested compiler must have the GCC codegen backend available in its sysroot
53-
directory. You can achieve that using the [instructions above](#choosing-which-codegen-backends-are-built).
67+
Note that in order for this to work, the tested compiler must have the GCC codegen backend [available](#choosing-which-codegen-backends-are-built) in its sysroot directory.
5468

5569
## Downloading GCC from CI
5670

5771
The `gcc.download-ci-gcc` bootstrap option controls if GCC (which is a dependency of the GCC codegen backend)
5872
will be downloaded from CI or built locally. The default value is `true`, which will download GCC from CI
5973
if there are no local changes to the GCC sources and the given host target is available on CI.
6074

61-
Note that GCC can currently only be downloaded from CI for the `x86_64-unknown-linux-gnu` target.
75+
## Running tests of the backend itself
76+
77+
In addition to running the compiler's test suites using the GCC codegen backend, you can also run the test suite of the backend itself.
78+
79+
Now you do that using the following command:
80+
81+
```text
82+
./x test rustc_codegen_gcc
83+
```
84+
85+
The backend needs to be [enabled](#choosing-which-codegen-backends-are-built) for this to work.

src/doc/rustc-dev-guide/src/tests/running.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -396,39 +396,4 @@ Now, tests should just run, you don't have to set up anything else.
396396
[wasm32-wasip1 target support page]: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasip1.md#building-the-target.
397397

398398

399-
## Running rustc_codegen_gcc tests
400-
401-
First thing to know is that it only supports linux x86_64 at the moment. We will
402-
extend its support later on.
403-
404-
You need to update `codegen-backends` value in your `bootstrap.toml` file in the
405-
`[rust]` section and add "gcc" in the array:
406-
407-
```toml
408-
codegen-backends = ["llvm", "gcc"]
409-
```
410-
411-
Then you need to install libgccjit 12. For example with `apt`:
412-
413-
```text
414-
apt install libgccjit-12-dev
415-
```
416-
417-
Now you can run the following command:
418-
419-
```text
420-
./x test compiler/rustc_codegen_gcc/
421-
```
422-
423-
If it cannot find the `.so` library (if you installed it with `apt` for example), you
424-
need to pass the library file path with `LIBRARY_PATH`:
425-
426-
```text
427-
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12/ ./x test compiler/rustc_codegen_gcc/
428-
```
429-
430-
If you encounter bugs or problems, don't hesitate to open issues on the
431-
[`rustc_codegen_gcc`
432-
repository](https://github.com/rust-lang/rustc_codegen_gcc/).
433-
434399
[`tests/ui`]: https://github.com/rust-lang/rust/tree/master/tests/ui

0 commit comments

Comments
 (0)