Skip to content

Commit 257e73f

Browse files
committed
improve comments and docs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent 09eb3b3 commit 257e73f

File tree

4 files changed

+21
-59
lines changed

4 files changed

+21
-59
lines changed

src/building/bootstrapping/what-bootstrapping-does.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ The stage0 compiler is by default the very recent _beta_ `rustc` compiler and it
6666
associated dynamic libraries, which `./x.py` will download for you. (You can
6767
also configure `./x.py` to change stage0 to something else.)
6868

69-
The stage0 compiler is then used only to compile [`src/bootstrap`] and [`compiler/rustc`].
70-
When assembling the libraries and binaries that will become the stage1 `rustc` compiler,
71-
the freshly compiled `rustc` and beta `std` are used.
69+
The precompiled stage0 compiler is then used only to compile [`src/bootstrap`] and [`compiler/rustc`]
70+
with precompiled stage0 std.
7271

73-
Note that to build the stage1 compiler we use the precompiled beta compiler and beta std from stage0.
74-
Therefore, to use a compiler with a std that is freshly built from the tree, you need to build the
75-
stage2 compiler.
72+
Note that to build the stage1 compiler we use the precompiled stage0 compiler and std.
73+
Therefore, to use a compiler with a std that is freshly built from the tree, you need to
74+
build the stage2 compiler.
7675

7776
There are two concepts at play here: a compiler (with its set of dependencies) and its
7877
'target' or 'object' libraries (`std` and `rustc`). Both are staged, but in a staggered manner.
@@ -87,7 +86,7 @@ The rustc source code is then compiled with the `stage0` compiler to produce the
8786

8887
### Stage 2: the truly current compiler
8988

90-
We then rebuild our `stage1` compiler with in-tree std to produce the `stage2`
89+
We then rebuild the compiler using `stage1` compiler with in-tree std to produce the `stage2`
9190
compiler.
9291

9392
The `stage1` compiler itself was built by precompiled `stage0` compiler and std
@@ -194,8 +193,8 @@ include, but are not limited to:
194193
without building `rustc` from source ('build with `stage0`, then test the
195194
artifacts'). If you're working on the standard library, this is normally the
196195
test command you want.
197-
- `./x build --stage 0` means to build with the beta `rustc`.
198-
- `./x doc --stage 0` means to document using the beta `rustdoc`.
196+
- `./x build --stage 0` means to build with the stage0 `rustc`.
197+
- `./x doc --stage 0` means to document using the stage0 `rustdoc`.
199198

200199
#### Examples of what *not* to do
201200

@@ -442,6 +441,6 @@ compiler itself uses to run. These aren't actually used by artifacts the new
442441
compiler generates. This step also copies the `rustc` and `rustdoc` binaries we
443442
generated into `build/$HOST/stage/bin`.
444443

445-
The `stage1/bin/rustc` is a fully functional compiler built with the beta compiler and std.
446-
To use a compiler built entirely from source with the in-tree compiler and std, you need to build
447-
the stage2 compiler, which is compiled using the stage1 compiler and std.
444+
The `stage1/bin/rustc` is a fully functional compiler built with stage0 (precompiled) compiler and std.
445+
To use a compiler built entirely from source with the in-tree compiler and std, you need to build the
446+
stage2 compiler, which is compiled using the stage1 (in-tree) compiler and std.

src/building/how-to-build-and-run.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ you will likely need to build at some point; for example, if you want
269269
to run the entire test suite).
270270

271271
```bash
272-
rustup toolchain link stage0 build/host/stage0-sysroot # beta compiler + beta std
273272
rustup toolchain link stage1 build/host/stage1
274273
rustup toolchain link stage2 build/host/stage2
275274
```

src/building/new-target.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Look for existing targets to use as examples.
8585
After adding your target to the `rustc_target` crate you may want to add
8686
`core`, `std`, ... with support for your new target. In that case you will
8787
probably need access to some `target_*` cfg. Unfortunately when building with
88-
stage0 (the beta compiler), you'll get an error that the target cfg is
88+
stage0 (a precompiled compiler), you'll get an error that the target cfg is
8989
unexpected because stage0 doesn't know about the new target specification and
9090
we pass `--check-cfg` in order to tell it to check.
9191

src/building/suggested.md

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -310,51 +310,15 @@ lets you use `cargo fmt`.
310310
[the section on vscode]: suggested.md#configuring-rust-analyzer-for-rustc
311311
[the section on rustup]: how-to-build-and-run.md?highlight=rustup#creating-a-rustup-toolchain
312312

313-
## Faster builds with `--keep-stage`.
314-
315-
Sometimes just checking whether the compiler builds is not enough. A common
316-
example is that you need to add a `debug!` statement to inspect the value of
317-
some state or better understand the problem. In that case, you don't really need
318-
a full build. By bypassing bootstrap's cache invalidation, you can often get
319-
these builds to complete very fast (e.g., around 30 seconds). The only catch is
320-
this requires a bit of fudging and may produce compilers that don't work (but
321-
that is easily detected and fixed).
322-
323-
The sequence of commands you want is as follows:
324-
325-
- Initial build: `./x build library`
326-
- As [documented previously], this will build a functional stage1 compiler as
327-
part of running all stage0 commands (which include building a `std`
328-
compatible with the stage1 compiler) as well as the first few steps of the
329-
"stage 1 actions" up to "stage1 (sysroot stage1) builds std".
330-
- Subsequent builds: `./x build library --keep-stage 1`
331-
- Note that we added the `--keep-stage 1` flag here
332-
333-
[documented previously]: ./how-to-build-and-run.md#building-the-compiler
334-
335-
As mentioned, the effect of `--keep-stage 1` is that we just _assume_ that the
336-
old standard library can be re-used. If you are editing the compiler, this is
337-
almost always true: you haven't changed the standard library, after all. But
338-
sometimes, it's not true: for example, if you are editing the "metadata" part of
339-
the compiler, which controls how the compiler encodes types and other states
340-
into the `rlib` files, or if you are editing things that wind up in the metadata
341-
(such as the definition of the MIR).
342-
343-
**The TL;DR is that you might get weird behavior from a compile when using
344-
`--keep-stage 1`** -- for example, strange [ICEs](../appendix/glossary.html#ice)
345-
or other panics. In that case, you should simply remove the `--keep-stage 1`
346-
from the command and rebuild. That ought to fix the problem.
347-
348-
You can also use `--keep-stage 1` when running tests. Something like this:
349-
350-
- Initial test run: `./x test tests/ui`
351-
- Subsequent test run: `./x test tests/ui --keep-stage 1`
352-
353-
### Iterating the standard library with `--keep-stage`
354-
355-
If you are making changes to the standard library, you can use `./x build
356-
--keep-stage 0 library` to iteratively rebuild the standard library without
357-
rebuilding the compiler.
313+
## Faster Builds with CI-rustc
314+
315+
If you are not working on the compiler, you often don't need to build the compiler tree.
316+
For example, you can skip building the compiler and only build the `library` tree or the
317+
tools under `src/tools`. To achieve that, you have to enable this by setting the `download-rustc`
318+
option in your configuration. This tells bootstrap to use the latest nightly compiler for `stage > 0`
319+
steps, meaning it will have two precompiled compilers: stage0 compiler and `download-rustc` compiler
320+
for `stage > 0` steps. This way, it will never need to build the in-tree compiler. As a result, your
321+
build time will be significantly reduced by not building the in-tree compiler.
358322

359323
## Using incremental compilation
360324

0 commit comments

Comments
 (0)