Skip to content

Commit 866ed3a

Browse files
authored
Rollup merge of rust-lang#147924 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update Subtree update of `rustc-dev-guide` to rust-lang/rustc-dev-guide@7cb1f42. Created using https://github.com/rust-lang/josh-sync. r? `@ghost`
2 parents 7b0e3eb + 05d4da3 commit 866ed3a

File tree

8 files changed

+82
-51
lines changed

8 files changed

+82
-51
lines changed

src/doc/rustc-dev-guide/src/backend/debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ llvm-ir`). `--build-type=debug` emits code for debug builds. There are also
7777
other useful options. Also, debug info in LLVM IR can clutter the output a lot:
7878
`RUSTFLAGS="-C debuginfo=0"` is really useful.
7979

80-
`RUSTFLAGS="-C save-temps"` outputs LLVM bitcode (not the same as IR) at
80+
`RUSTFLAGS="-C save-temps"` outputs LLVM bitcode at
8181
different stages during compilation, which is sometimes useful. The output LLVM
8282
bitcode will be in `.bc` files in the compiler's output directory, set via the
8383
`--out-dir DIR` argument to `rustc`.

src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,18 @@ Once you've created a `bootstrap.toml`, you are now ready to run
227227
probably the best "go to" command for building a local compiler:
228228

229229
```console
230-
./x build rustc
230+
./x build library
231231
```
232232

233-
What this command does is build `rustc` using the stage0 compiler and stage0 `std`.
233+
What this command does is:
234+
- Build `rustc` using the stage0 compiler and stage0 `std`.
235+
- Build `library` (the standard libraries) with the stage1 compiler that was just built.
236+
- Assemble a working stage1 sysroot, containing the stage1 compiler and stage1 standard libraries.
234237

235238
To build `rustc` with the in-tree `std`, use this command instead:
236239

237240
```console
238-
./x build rustc --stage 2
241+
./x build library --stage 2
239242
```
240243

241244
This final product (stage1 compiler + libs built using that compiler)
@@ -246,7 +249,7 @@ You will probably find that building the stage1 `std` is a bottleneck for you,
246249
but fear not, there is a (hacky) workaround...
247250
see [the section on avoiding rebuilds for std][keep-stage].
248251

249-
[keep-stage]: ./suggested.md#faster-builds-with---keep-stage
252+
[keep-stage]: ./suggested.md#faster-rebuilds-with---keep-stage-std
250253

251254
Sometimes you don't need a full build. When doing some kind of
252255
"type-based refactoring", like renaming a method, or changing the

src/doc/rustc-dev-guide/src/building/suggested.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,40 @@ steps, meaning it will have two precompiled compilers: stage0 compiler and `down
306306
for `stage > 0` steps. This way, it will never need to build the in-tree compiler. As a result, your
307307
build time will be significantly reduced by not building the in-tree compiler.
308308

309+
## Faster rebuilds with `--keep-stage-std`
310+
311+
Sometimes just checking whether the compiler builds is not enough. A common
312+
example is that you need to add a `debug!` statement to inspect the value of
313+
some state or better understand the problem. In that case, you don't really need
314+
a full build. By bypassing bootstrap's cache invalidation, you can often get
315+
these builds to complete very fast (e.g., around 30 seconds). The only catch is
316+
this requires a bit of fudging and may produce compilers that don't work (but
317+
that is easily detected and fixed).
318+
319+
The sequence of commands you want is as follows:
320+
321+
- Initial build: `./x build library`
322+
- Subsequent builds: `./x build library --keep-stage-std=1`
323+
- Note that we added the `--keep-stage-std=1` flag here
324+
325+
As mentioned, the effect of `--keep-stage-std=1` is that we just _assume_ that the
326+
old standard library can be re-used. If you are editing the compiler, this is
327+
often true: you haven't changed the standard library, after all. But
328+
sometimes, it's not true: for example, if you are editing the "metadata" part of
329+
the compiler, which controls how the compiler encodes types and other states
330+
into the `rlib` files, or if you are editing things that wind up in the metadata
331+
(such as the definition of the MIR).
332+
333+
**The TL;DR is that you might get weird behavior from a compile when using
334+
`--keep-stage-std=1`** -- for example, strange [ICEs](../appendix/glossary.html#ice)
335+
or other panics. In that case, you should simply remove the `--keep-stage-std=1`
336+
from the command and rebuild. That ought to fix the problem.
337+
338+
You can also use `--keep-stage-std=1` when running tests. Something like this:
339+
340+
- Initial test run: `./x test tests/ui`
341+
- Subsequent test run: `./x test tests/ui --keep-stage-std=1`
342+
309343
## Using incremental compilation
310344

311345
You can further enable the `--incremental` flag to save additional time in

src/doc/rustc-dev-guide/src/compiler-team.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ They are held on [Zulip][zulip-meetings]. It works roughly as follows:
5454
those that are sufficiently important for us to actively track
5555
progress. P-critical and P-high bugs should ideally always have an
5656
assignee.
57-
- **Check S-waiting-on-team and I-nominated issues:** These are issues where feedback from
58-
the team is desired.
57+
- **Check `S-waiting-on-t-compiler` and `I-compiler-nominated` issues:** These are issues where
58+
feedback from the team is desired.
5959
- **Look over the performance triage report:** We check for PRs that made the
6060
performance worse and try to decide if it's worth reverting the performance regression or if
6161
the regression can be addressed in a future PR.

src/doc/rustc-dev-guide/src/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ Please see <https://forge.rust-lang.org/release/issue-triaging.html>.
461461
[S-tracking-]: https://github.com/rust-lang/rust/labels?q=s-tracking
462462
[the rustc-dev-guide working group documentation]: https://forge.rust-lang.org/wg-rustc-dev-guide/index.html#where-to-contribute-rustc-dev-guide-changes
463463

464-
### Rfcbot labels
464+
### rfcbot labels
465465

466466
[rfcbot] uses its own labels for tracking the process of coordinating
467467
asynchronous decisions, such as approving or rejecting a change.

src/doc/rustc-dev-guide/src/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Some work is too large to be done by a single person. In this case, it's common
9898
issues" to co-ordinate the work between contributors. Here are some example tracking issues where
9999
it's easy to pick up work without a large time commitment:
100100

101-
- [Move UI tests to subdirectories](https://github.com/rust-lang/rust/issues/73494)
101+
- *Add recurring work items here.*
102102

103103
If you find more recurring work, please feel free to add it here!
104104

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

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
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 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
7-
./x test tests/ui --set 'rust.codegen-backends = ["llvm", "gcc"]' --test-codegen-backend gcc
16+
./x test tests/ui \
17+
--set 'rust.codegen-backends = ["llvm", "gcc"]' \
18+
--set 'rust.debug-assertions = false' \
19+
--test-codegen-backend gcc
820
```
921

10-
Below, you can find more information about how to configure the GCC backend in bootstrap.
22+
If a different test suite has failed on CI, you will have to modify the `tests/ui` part.
23+
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).
1131

1232
## Choosing which codegen backends are built
1333

@@ -44,13 +64,22 @@ To run compiler tests with the GCC codegen backend being used to build the test
4464
./x test tests/ui --test-codegen-backend gcc
4565
```
4666

47-
Note that in order for this to work, the tested compiler must have the GCC codegen backend available in its sysroot
48-
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.
4968

5069
## Downloading GCC from CI
5170

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

56-
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)