@@ -90,15 +90,15 @@ things (like adding support for a new intrinsic) can be done by working just on
90
90
the miri side.
91
91
92
92
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 :
94
94
95
95
``` sh
96
96
rustup override set nightly # or the nightly in `rust-version`
97
97
cargo run --bin cargo-miri -- miri setup
98
98
```
99
99
100
100
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:
102
102
103
103
``` sh
104
104
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
109
109
Now you can run Miri directly, without going through ` cargo miri ` :
110
110
111
111
``` 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
113
113
```
114
114
115
115
You can also run the test suite with ` cargo test --release ` . `cargo test
@@ -120,14 +120,33 @@ less time.
120
120
121
121
Now you are set up! You can write a failing test case, and tweak miri until it
122
122
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
+
123
141
124
142
### Using a locally built rustc
125
143
126
144
Since the heart of Miri (the main interpreter engine) lives in rustc, working on
127
145
Miri will often require using a locally built rustc. The bug you want to fix
128
146
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.
131
150
132
151
The setup for a local rustc works as follows:
133
152
``` sh
@@ -149,22 +168,6 @@ rustup override set custom
149
168
With this, you should now have a working development setup! See
150
169
[ "Testing Miri"] ( #testing-miri ) above for how to proceed.
151
170
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
-
168
171
### Miri ` -Z ` flags and environment variables
169
172
170
173
Several ` -Z ` flags are relevant for Miri:
0 commit comments