Skip to content

Commit d8c9c9d

Browse files
committed
update README for some tracing being available on nightlies
1 parent 4f659ed commit d8c9c9d

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

README.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ things (like adding support for a new intrinsic) can be done by working just on
9090
the miri side.
9191

9292
To prepare, make sure you are using a nightly Rust compiler. You also need to
93-
set up a libstd that enables execution with miri:
93+
set up a libstd that enables execution with Miri:
9494

9595
```sh
9696
rustup override set nightly # or the nightly in `rust-version`
9797
cargo run --bin cargo-miri -- miri setup
9898
```
9999

100100
The last command should end in printing the directory where the libstd was
101-
built. Set that as your MIRI_SYSROOT environment variable:
101+
built. Set that as your `MIRI_SYSROOT` environment variable:
102102

103103
```sh
104104
export MIRI_SYSROOT=~/.cache/miri/HOST # or whatever the previous command said
@@ -109,7 +109,7 @@ export MIRI_SYSROOT=~/.cache/miri/HOST # or whatever the previous command said
109109
Now you can run Miri directly, without going through `cargo miri`:
110110

111111
```sh
112-
cargo run tests/run-pass-fullmir/format.rs # or whatever test you like
112+
cargo run tests/run-pass/format.rs # or whatever test you like
113113
```
114114

115115
You can also run the test suite with `cargo test --release`. `cargo test
@@ -120,14 +120,33 @@ less time.
120120

121121
Now you are set up! You can write a failing test case, and tweak miri until it
122122
fails no more.
123+
You can get a trace of which MIR statements are being executed by setting the
124+
`MIRI_LOG` environment variable. For example:
125+
126+
```sh
127+
MIRI_LOG=info cargo run tests/run-pass/vecs.rs
128+
```
129+
130+
Setting `MIRI_LOG` like this will configure logging for miri itself as well as
131+
the `rustc::mir::interpret` and `rustc_mir::interpret` modules in rustc. You
132+
can also do more targeted configuration, e.g. to debug the stacked borrows
133+
implementation:
134+
```sh
135+
MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows cargo run tests/run-pass/vecs.rs
136+
```
137+
138+
In addition, you can set `MIRI_BACKTRACE=1` to get a backtrace of where an
139+
evaluation error was originally created.
140+
123141

124142
### Using a locally built rustc
125143

126144
Since the heart of Miri (the main interpreter engine) lives in rustc, working on
127145
Miri will often require using a locally built rustc. The bug you want to fix
128146
may actually be on the rustc side, or you just need to get more detailed trace
129-
of the execution -- in both cases, you should develop miri against a rustc you
130-
compiled yourself, with debug assertions (and hence tracing) enabled.
147+
of the execution than what is possible with release builds -- in both cases, you
148+
should develop miri against a rustc you compiled yourself, with debug assertions
149+
(and hence tracing) enabled.
131150

132151
The setup for a local rustc works as follows:
133152
```sh
@@ -149,22 +168,6 @@ rustup override set custom
149168
With this, you should now have a working development setup! See
150169
["Testing Miri"](#testing-miri) above for how to proceed.
151170

152-
Moreover, you can now run Miri with a trace of all execution steps:
153-
```sh
154-
MIRI_LOG=debug cargo run tests/run-pass/vecs.rs
155-
```
156-
157-
Setting `MIRI_LOG` like this will configure logging for miri itself as well as
158-
the `rustc::mir::interpret` and `rustc_mir::interpret` modules in rustc. You
159-
can also do more targeted configuration, e.g. to debug the stacked borrows
160-
implementation:
161-
```sh
162-
MIRI_LOG=rustc_mir::interpret=debug,miri::stacked_borrows cargo run tests/run-pass/vecs.rs
163-
```
164-
165-
In addition, you can set `MIRI_BACKTRACE=1` to get a backtrace of where an
166-
evaluation error was originally created.
167-
168171
### Miri `-Z` flags and environment variables
169172

170173
Several `-Z` flags are relevant for Miri:

0 commit comments

Comments
 (0)