Skip to content

Commit 60b17f3

Browse files
authored
Merge pull request rust-lang#4919 from RalfJung/locally-built
CONTRIBUTING: explain how to build miri against a locally built rustc
2 parents 4ed1320 + b32f9cb commit 60b17f3

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

src/tools/miri/CONTRIBUTING.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/pass/v
171171
```
172172

173173
Note that you will only get `info`, `warn` or `error` messages if you use a prebuilt compiler.
174-
In order to get `debug` and `trace` level messages, you need to build miri with a locally built
175-
compiler that has `debug=true` set in `bootstrap.toml`.
174+
In order to get `debug` and `trace` level messages, you need to build miri with a [locally built
175+
compiler](#advanced-topic-building-miri-against-a-locally-compiled-rustc) that has `debug=true` set in `bootstrap.toml`.
176176

177177
#### Debugging error messages
178178

@@ -320,6 +320,33 @@ You can also directly run Miri on a Rust source file:
320320
./x.py run miri --stage 1 --args src/tools/miri/tests/pass/hello.rs
321321
```
322322

323+
## Advanced topic: Building Miri against a locally compiled rustc
324+
325+
Very rarely, it can be necessary to work with an out-of-tree Miri but build it against a rustc that
326+
was locally compiled. (Usually, you should instead work on the Miri that's in the Rust tree, as
327+
described in the previous subsection.)
328+
329+
This requires a fully bootstrapped build:
330+
331+
```sh
332+
# Build rustc, then build rustc with that rustc. This can take a while.
333+
./x build library --stage 3
334+
```
335+
336+
You also need to set up a linked toolchain with rustup:
337+
338+
```sh
339+
rustup toolchain link stage2 build/host/stage2
340+
```
341+
342+
Then in the Miri folder, you can set this as the current toolchain and build against it:
343+
344+
```sh
345+
rustup override set stage2
346+
# Prevent `./miri` from reseting the toolchain.
347+
export MIRI_AUTO_OPS=no
348+
```
349+
323350
## Advanced topic: Syncing with the rustc repo
324351

325352
We use the [`josh-sync`](https://github.com/rust-lang/josh-sync) tool to transmit changes between the

0 commit comments

Comments
 (0)