Skip to content

Commit ab5d6f2

Browse files
committed
extend bootstrap related documentations
Signed-off-by: ozkanonur <[email protected]>
1 parent 7352353 commit ab5d6f2

File tree

5 files changed

+83
-32
lines changed

5 files changed

+83
-32
lines changed

src/building/bootstrapping.md

+53-11
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,17 @@ you can tell the bootstrap shim to print all env variables by adding `-vvv` to y
411411

412412
This is an incomplete reference for the outputs generated by bootstrap:
413413

414-
| Stage 0 Action | Output |
415-
|-----------------------------------------------------------|----------------------------------------------|
416-
| `beta` extracted | `build/HOST/stage0` |
417-
| `stage0` builds `bootstrap` | `build/bootstrap` |
418-
| `stage0` builds `test`/`std` | `build/HOST/stage0-std/TARGET` |
419-
| copy `stage0-std` (HOST only) | `build/HOST/stage0-sysroot/lib/rustlib/HOST` |
420-
| `stage0` builds `rustc` with `stage0-sysroot` | `build/HOST/stage0-rustc/HOST` |
421-
| copy `stage0-rustc` (except executable) | `build/HOST/stage0-sysroot/lib/rustlib/HOST` |
422-
| build `llvm` | `build/HOST/llvm` |
423-
| `stage0` builds `codegen` with `stage0-sysroot` | `build/HOST/stage0-codegen/HOST` |
424-
| `stage0` builds `rustdoc`, `clippy`, `miri`, with `stage0-sysroot` | `build/HOST/stage0-tools/HOST` |
414+
| Stage 0 Action | Output |
415+
| ------------------------------------------------------------------ | -------------------------------------------- |
416+
| `beta` extracted | `build/HOST/stage0` |
417+
| `stage0` builds `bootstrap` | `build/bootstrap` |
418+
| `stage0` builds `test`/`std` | `build/HOST/stage0-std/TARGET` |
419+
| copy `stage0-std` (HOST only) | `build/HOST/stage0-sysroot/lib/rustlib/HOST` |
420+
| `stage0` builds `rustc` with `stage0-sysroot` | `build/HOST/stage0-rustc/HOST` |
421+
| copy `stage0-rustc` (except executable) | `build/HOST/stage0-sysroot/lib/rustlib/HOST` |
422+
| build `llvm` | `build/HOST/llvm` |
423+
| `stage0` builds `codegen` with `stage0-sysroot` | `build/HOST/stage0-codegen/HOST` |
424+
| `stage0` builds `rustdoc`, `clippy`, `miri`, with `stage0-sysroot` | `build/HOST/stage0-tools/HOST` |
425425

426426
`--stage=0` stops here.
427427

@@ -448,3 +448,45 @@ This is an incomplete reference for the outputs generated by bootstrap:
448448
| copy `rustdoc` | `build/HOST/stage2/bin` |
449449

450450
`--stage=2` stops here.
451+
452+
### Clarification of build command's stdout
453+
454+
In this part, we will investigate the build command's stdout in an action
455+
(similar, but more detailed and complete documentation compare to topic above).
456+
When you execute `x.py build --dry-run` command, the build output will be something
457+
like the following:
458+
459+
```text
460+
Building stage0 library artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
461+
Copying stage0 library from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
462+
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
463+
Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
464+
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
465+
Building stage1 library artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
466+
Copying stage1 library from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
467+
Building stage1 tool rust-analyzer-proc-macro-srv (x86_64-unknown-linux-gnu)
468+
Building rustdoc for stage1 (x86_64-unknown-linux-gnu)
469+
```
470+
471+
#### Building stage0 {std,compiler} artifacts
472+
473+
These steps use the provided (downloaded, usually) compiler to compile the
474+
local Rust source into libraries we can use.
475+
476+
#### Copying stage0 {std,rustc}
477+
478+
This copies the library and compiler artifacts from Cargo into
479+
`stage0-sysroot/lib/rustlib/{target-triple}/lib`
480+
481+
#### Assembling stage1 compiler
482+
483+
This copies the libraries we built in "building stage0 ... artifacts" into
484+
the stage1 compiler's lib directory. These are the host libraries that the
485+
compiler itself uses to run. These aren't actually used by artifacts the new
486+
compiler generates. This step also copies the rustc and rustdoc binaries we
487+
generated into `build/$HOST/stage/bin`.
488+
489+
The stage1/bin/rustc is a fully functional compiler, but it doesn't yet have
490+
any libraries to link built binaries or libraries to. The next 3 steps will
491+
provide those libraries for it; they are mostly equivalent to constructing
492+
the stage1/bin compiler so we don't go through them individually.

src/building/suggested.md

+21
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,27 @@ You can also use `--keep-stage 1` when running tests. Something like this:
175175
- Initial test run: `./x.py test tests/ui`
176176
- Subsequent test run: `./x.py test tests/ui --keep-stage 1`
177177

178+
## Using incremental compilation
179+
180+
You can further enable the `--incremental` flag to save additional
181+
time in subsequent rebuilds:
182+
183+
```bash
184+
./x.py test tests/ui --incremental --test-args issue-1234
185+
```
186+
187+
If you don't want to include the flag with every command, you can
188+
enable it in the `config.toml`:
189+
190+
```toml
191+
[rust]
192+
incremental = true
193+
```
194+
195+
Note that incremental compilation will use more disk space than usual.
196+
If disk space is a concern for you, you might want to check the size
197+
of the `build` directory from time to time.
198+
178199
## Fine-tuning optimizations
179200

180201
Setting `optimize = false` makes the compiler too slow for tests. However, to

src/getting-started.md

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ serious development work. In particular, `./x.py build` and `./x.py test`
114114
provide many ways to compile or test a subset of the code, which can save a lot
115115
of time.
116116

117+
Also, note that `x.py` supports all kinds of path suffixes for `compiler`, `library`,
118+
and `src/tools` directories. So, you can simply run `x.py test tidy` instead of
119+
`x.py test src/tools/tidy`. Or, `x.py build std` instead of `x.py build library/std`.
120+
117121
[rust-analyzer]: ./building/suggested.html#configuring-rust-analyzer-for-rustc
118122

119123
See the chapters on [building](./building/how-to-build-and-run.md),

src/tests/compiletest.md

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ See the [Adding new tests](adding.md) chapter for a tutorial on creating a new
2424
test, and the [Running tests](running.md) chapter on how to run the test
2525
suite.
2626

27+
Compiletest itself tries to avoid running tests when the artifacts
28+
that are involved (mainly the compiler) haven't changed. You can use
29+
`x test --test-args --force-rerun` to rerun a test even when none of the
30+
inputs have changed.
31+
2732
## Test suites
2833

2934
All of the tests are in the [`tests`] directory.

src/tests/running.md

-21
Original file line numberDiff line numberDiff line change
@@ -175,27 +175,6 @@ By passing `--pass $mode`, you can reduce the testing time. For each
175175
mode, please see [Controlling pass/fail
176176
expectations](ui.md#controlling-passfail-expectations).
177177

178-
## Using incremental compilation
179-
180-
You can further enable the `--incremental` flag to save additional
181-
time in subsequent rebuilds:
182-
183-
```bash
184-
./x.py test tests/ui --incremental --test-args issue-1234
185-
```
186-
187-
If you don't want to include the flag with every command, you can
188-
enable it in the `config.toml`:
189-
190-
```toml
191-
[rust]
192-
incremental = true
193-
```
194-
195-
Note that incremental compilation will use more disk space than usual.
196-
If disk space is a concern for you, you might want to check the size
197-
of the `build` directory from time to time.
198-
199178
## Running tests with different "compare modes"
200179

201180
UI tests may have different output depending on certain "modes" that

0 commit comments

Comments
 (0)