Skip to content

Commit bf7b361

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

File tree

5 files changed

+99
-11
lines changed

5 files changed

+99
-11
lines changed

src/building/bootstrapping.md

+54-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,46 @@ 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,test,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,test,rustc}
477+
478+
This copies the build output from Cargo into
479+
`build/$HOST/stage0-sysroot/lib/rustlib/$ARCH/lib`.
480+
[comment]: FIXME: this step's documentation should be expanded -- the information already here may be incorrect.
481+
482+
#### Assembling stage1 compiler
483+
484+
This copies the libraries we built in "building stage0 ... artifacts" into
485+
the stage1 compiler's lib directory. These are the host libraries that the
486+
compiler itself uses to run. These aren't actually used by artifacts the new
487+
compiler generates. This step also copies the rustc and rustdoc binaries we
488+
generated into `build/$HOST/stage/bin`.
489+
490+
The stage1/bin/rustc is a fully functional compiler, but it doesn't yet have
491+
any libraries to link built binaries or libraries to. The next 3 steps will
492+
provide those libraries for it; they are mostly equivalent to constructing
493+
the stage1/bin compiler so we don't go through them individually.

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

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ clean` will not cause a rebuild of LLVM.
5454

5555
## Building the Compiler
5656

57+
Building compiler is unfortunately not quite as simple as building other
58+
rust projects using `cargo build`. Instead, we use `x.py` script for building
59+
the compiler. The main reason behind it is the bootstrap stages where you use
60+
the output of one cargo invocation as the input compiler for another. Which
61+
is not possible with `cargo` itself.
62+
5763
Note that building will require a relatively large amount of storage space.
5864
You may want to have upwards of 10 or 15 gigabytes available to build the compiler.
5965

src/building/suggested.md

+29
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,35 @@ 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+
## Incremental builds
179+
180+
Incremental compilation is enabled by default in almost all of the config profiles
181+
under the `src/bootstrap/defaults`.
182+
183+
In case if it's not enabled, you can configure rustbuild to use incremental
184+
compilation with the `--incremental` flag:
185+
186+
```sh
187+
$ ./x.py build --incremental
188+
```
189+
190+
If you want to enable it once for all, you can apply the following configuration
191+
in your `config.toml`:
192+
193+
```toml
194+
[rust]
195+
incremental=true
196+
```
197+
198+
Incremental compilation will store compilation artifacts
199+
in `build/<host>/stage0-incremental`. Note that we only use incremental
200+
compilation for the stage0 -> stage1 compilation -- this is because
201+
the stage1 compiler is changing, and we don't try to cache and reuse
202+
incremental artifacts across different versions of the compiler.
203+
204+
Note that if incremental compilation is not enabled, you will
205+
still be using the downloaded beta as your bootstrap.
206+
178207
## Fine-tuning optimizations
179208

180209
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

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
## Introduction
66

7+
Most of the "meaty" steps that matter are backed by Cargo, which does indeed
8+
have its own parallelism and incremental management. Later steps, like
9+
tests, aren't incremental and simply run the entire suite currently.
10+
However, compiletest itself tries to avoid running tests when the artifacts
11+
that are involved (mainly the compiler) haven't changed.
12+
713
`compiletest` is the main test harness of the Rust test suite.
814
It allows test authors to organize large numbers of tests
915
(the Rust compiler has many thousands),

0 commit comments

Comments
 (0)