Skip to content

Commit 00c0d7e

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

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

src/building/bootstrapping.md

+43
Original file line numberDiff line numberDiff line change
@@ -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 (aarch64-unknown-linux-gnu -> aarch64-unknown-linux-gnu)
461+
Copying stage0 library from stage0 (aarch64-unknown-linux-gnu -> aarch64-unknown-linux-gnu / aarch64-unknown-linux-gnu)
462+
Building stage0 compiler artifacts (aarch64-unknown-linux-gnu -> aarch64-unknown-linux-gnu)
463+
Copying stage0 rustc from stage0 (aarch64-unknown-linux-gnu -> aarch64-unknown-linux-gnu / aarch64-unknown-linux-gnu)
464+
Assembling stage1 compiler (aarch64-unknown-linux-gnu)
465+
Building stage1 library artifacts (aarch64-unknown-linux-gnu -> aarch64-unknown-linux-gnu)
466+
Copying stage1 library from stage1 (aarch64-unknown-linux-gnu -> aarch64-unknown-linux-gnu / aarch64-unknown-linux-gnu)
467+
Building stage1 tool rust-analyzer-proc-macro-srv (aarch64-unknown-linux-gnu)
468+
Building rustdoc for stage1 (aarch64-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

+18
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,24 @@ 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+
You can configure rustbuild to use incremental compilation with the
181+
`--incremental` flag:
182+
183+
```sh
184+
$ ./x.py build --incremental
185+
```
186+
187+
The `--incremental` flag will store incremental compilation artifacts
188+
in `build/<host>/stage0-incremental`. Note that we only use incremental
189+
compilation for the stage0 -> stage1 compilation -- this is because
190+
the stage1 compiler is changing, and we don't try to cache and reuse
191+
incremental artifacts across different versions of the compiler.
192+
193+
You can always drop the `--incremental` to build as normal (note that
194+
you will still be using the downloaded beta as your bootstrap).
195+
178196
## Fine-tuning optimizations
179197

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