Skip to content

Commit 30d2018

Browse files
ehsanmokmark-i-m
authored andcommitted
expand compilation stages
1 parent eb396e7 commit 30d2018

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The compiler is built using a tool called `x.py`. You will need to
44
have Python installed to run it. But before we get to that, if you're going to
5-
be hacking on rustc, you'll want to tweak the configuration of the compiler.
5+
be hacking on `rustc`, you'll want to tweak the configuration of the compiler.
66
The default configuration is oriented towards running the compiler as a user,
77
not a developer.
88

@@ -55,13 +55,20 @@ compiler to compile the newer version. In particular, the newer version of the
5555
compiler, `libstd`, and other tooling may use some unstable features
5656
internally. The result is the compiling `rustc` is done in stages.
5757

58-
- **Stage 0:** the stage0 compiler is the current _beta_ compiler; we
59-
download this binary from the internet.
60-
- **Stage 1:** the code in your clone is then compiled with the stage
61-
0 compiler to produce the stage 1 compiler.
62-
- **Stage 2:** the code in your clone is then compiled with the stage
63-
1 compiler *again* to produce the stage 2 compiler (i.e. it builds
64-
itself).
58+
- **Stage 0:** the stage0 compiler can be your existing (perhaps older version of)
59+
Rust compiler, the current _beta_ compiler or you may download the binary
60+
from the internet
61+
- **Stage 1:** the code in your clone (for new version)
62+
is then compiled with the stage0
63+
compiler to produce the stage1 compiler.
64+
However, it was built with an older compiler (stage0),
65+
so to optimize the stage1 compiler we go to next stage
66+
- **Stage 2:** we rebuild our stage1 compiler with itself
67+
to produce the stage2 compiler (i.e. it builds
68+
itself) to have all the _latest optimizations_
69+
- _(Optional)_ **Stage 3**: to sanity check of our new compiler, we can build it again
70+
with stage2 compiler which must be identical to itself,
71+
unless something has broken
6572

6673
For hacking, often building the stage 1 compiler is enough, but for
6774
final testing and release, the stage 2 compiler is used.

0 commit comments

Comments
 (0)