|
1 | 1 | # How to build the compiler and run what you built
|
2 | 2 |
|
3 | 3 | 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 |
5 | 5 | be hacking on rustc, you'll want to tweak the configuration of the compiler. The default
|
6 | 6 | configuration is oriented towards running the compiler as a user, not a developer.
|
7 | 7 |
|
@@ -48,6 +48,19 @@ use-jemalloc = false
|
48 | 48 |
|
49 | 49 | ### Running x.py and building a stage1 compiler
|
50 | 50 |
|
| 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 | + |
51 | 64 | Once you've created a config.toml, you are now ready to run
|
52 | 65 | `x.py`. There are a lot of options here, but let's start with what is
|
53 | 66 | 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
|
117 | 130 | - `./x.py build` -- builds the stage2 compiler
|
118 | 131 | - Running tests (see the section [running tests](./running-tests.html) for more details):
|
119 | 132 | - `./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