Skip to content

Commit d7ddad6

Browse files
authored
Merge pull request #407 from RalfJung/readme
update rustc build instructions to mention keep-stage
2 parents 40ac150 + 8264732 commit d7ddad6

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,6 @@ how to fix it, you could send a PR. :smile:
4040
cargo run --bin miri tests/run-pass-fullmir/vecs.rs # Or whatever test you like.
4141
```
4242

43-
## Debugging
44-
45-
Since the heart of miri (the main interpreter engine) lives in rustc, tracing
46-
the interpreter requires a version of rustc compiled with tracing. To this
47-
end, you will have to compile your own rustc:
48-
```
49-
git clone https://github.com/rust-lang/rust/ rustc
50-
cd rustc
51-
cp config.toml.example config.toml
52-
# Now edit `config.toml` and set `debug-assertions = true`
53-
./x.py build src/rustc
54-
rustup toolchain link custom build/x86_64-unknown-linux-gnu/stage2
55-
```
56-
The `build` step can take 30 to 60 minutes.
57-
58-
Now, in the miri directory, you can `rustup override set custom` and re-build
59-
everything. Finally, if you now set `RUST_LOG=rustc_mir::interpret=trace` as
60-
environment variable, you will get detailed step-by-step tracing information.
61-
6243
## Running miri on your own project('s test suite)
6344

6445
Install miri as a cargo subcommand with `cargo install --debug`.
@@ -68,8 +49,8 @@ through miri.
6849

6950
## Running miri with full libstd
7051

71-
Per default libstd does not contain the MIR of non-polymorphic functions. When
72-
miri hits a call to such a function, execution terminates. To fix this, it is
52+
Per default libstd does not contain the MIR of non-polymorphic functions. When
53+
miri hits a call to such a function, execution terminates. To fix this, it is
7354
possible to compile libstd with full MIR:
7455

7556
```sh
@@ -91,6 +72,37 @@ your toolchain changes (e.g., when you update the nightly).
9172
You can also set `-Zmiri-start-fn` to make miri start evaluation with the
9273
`start_fn` lang item, instead of starting at the `main` function.
9374

75+
## Development and Debugging
76+
77+
Since the heart of miri (the main interpreter engine) lives in rustc, working on
78+
miri will often require using a locally built rustc. This includes getting a
79+
trace of the execution, as distributed rustc has `trace!` disabled.
80+
81+
The first-time setup for a local rustc looks as follows:
82+
```
83+
git clone https://github.com/rust-lang/rust/ rustc
84+
cd rustc
85+
cp config.toml.example config.toml
86+
# Now edit `config.toml` and set `debug-assertions = true`
87+
./x.py build src/rustc
88+
# You may have to change the architecture in the next command
89+
rustup toolchain link custom build/x86_64-unknown-linux-gnu/stage2
90+
# Now cd to your miri directory
91+
rustup override set custom
92+
```
93+
The `build` step can take 30 minutes and more.
94+
95+
Now you can `cargo build` miri, and you can `cargo test --tests`. (`--tests`
96+
is needed to skip doctests because we have not built rustdoc for your custom
97+
toolchain.) You can also set `RUST_LOG=rustc_mir::interpret=trace` as
98+
environment variable to get a step-by-step trace.
99+
100+
If you changed something in rustc and want to re-build, run
101+
```
102+
./x.py build src/rustc --keep-stage 0
103+
```
104+
This avoids rebuilding the entire stage 0, which can save a lot of time.
105+
94106
## Contributing and getting help
95107

96108
Check out the issues on this GitHub repository for some ideas. There's lots that

0 commit comments

Comments
 (0)