Skip to content

Commit 6ccb3b0

Browse files
authored
Merge pull request rust-lang#33 from mark-i-m/stages
Add a paragraph about bootstrapping
2 parents 0bda06e + 4f983eb commit 6ccb3b0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# How to build the compiler and run what you built
22

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

@@ -48,6 +48,19 @@ use-jemalloc = false
4848

4949
### Running x.py and building a stage1 compiler
5050

51+
One thing to keep in mind is that `rustc` is a _bootstrapping_ compiler. That
52+
is, since `rustc` is written in Rust, we need to use an older version of the
53+
compiler to compile the newer version. In particular, the newer version of the
54+
compiler, `libstd`, and other tooling may use some unstable features
55+
internally. The result is the compiling `rustc` is done in stages.
56+
57+
- Stage 0: the current _beta_ compiler is compiled using the current _stable_ compiler.
58+
- Stage 1: the code in your clone is then compiled with the stage 0 compiler.
59+
- Stage 2: the code in your clone is then compiled with the stage 1 compiler (i.e. it builds itself).
60+
61+
For hacking, often building the stage 1 compiler is enough, but for testing and
62+
release, the stage 2 compiler is used.
63+
5164
Once you've created a config.toml, you are now ready to run
5265
`x.py`. There are a lot of options here, but let's start with what is
5366
probably the best "go to" command for building a local rust:
@@ -117,4 +130,4 @@ Here are a few other useful x.py commands. We'll cover some of them in detail in
117130
- `./x.py build` -- builds the stage2 compiler
118131
- Running tests (see the section [running tests](./running-tests.html) for more details):
119132
- `./x.py test --stage 1 src/libstd` -- runs the `#[test]` tests from libstd
120-
- `./x.py test --stage 1 src/test/run-pass` -- runs the `run-pass` test suite
133+
- `./x.py test --stage 1 src/test/run-pass` -- runs the `run-pass` test suite

0 commit comments

Comments
 (0)