Skip to content

Add a paragraph about bootstrapping #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/how-to-build-and-run.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# How to build the compiler and run what you built

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

Expand Down Expand Up @@ -48,6 +48,19 @@ use-jemalloc = false

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

One thing to keep in mind is that `rustc` is a _bootstrapping_ compiler. That
is, since `rustc` is written in Rust, we need to use an older version of the
compiler to compile the newer version. In particular, the newer version of the
compiler, `libstd`, and other tooling may use some unstable features
internally. The result is the compiling `rustc` is done in stages.

- Stage 0: the current _beta_ compiler is compiled using the current _stable_ compiler.
- Stage 1: the code in your clone is then compiled with the stage 0 compiler.
- Stage 2: the code in your clone is then compiled with the stage 1 compiler (i.e. it builds itself).

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

Once you've created a config.toml, you are now ready to run
`x.py`. There are a lot of options here, but let's start with what is
probably the best "go to" command for building a local rust:
Expand Down Expand Up @@ -117,4 +130,4 @@ Here are a few other useful x.py commands. We'll cover some of them in detail in
- `./x.py build` -- builds the stage2 compiler
- Running tests (see the section [running tests](./running-tests.html) for more details):
- `./x.py test --stage 1 src/libstd` -- runs the `#[test]` tests from libstd
- `./x.py test --stage 1 src/test/run-pass` -- runs the `run-pass` test suite
- `./x.py test --stage 1 src/test/run-pass` -- runs the `run-pass` test suite