@@ -141,42 +141,28 @@ version of `rustc` that, instead of compiling your code, runs it. It accepts
141
141
all the same flags as ` rustc ` (though the ones only affecting code generation
142
142
and linking obviously will have no effect) [ and more] [ miri-flags ] .
143
143
144
- To run the Miri driver, you need to have the ` MIRI_SYSROOT ` environment variable
145
- set to an appropriate sysroot. You can generate such a sysroot with the
146
- following incantation:
147
-
148
- ```
149
- cargo run --bin cargo-miri -- miri setup
150
- ```
151
-
152
- This basically runs the ` cargo-miri ` binary (which backs the ` cargo miri `
153
- subcommand) with ` cargo ` , and asks it to ` setup ` . It should in the end print
154
- the directory where the libstd was built. In the following, we will assume it
155
- is ` ~/.cache/miri/HOST ` ; you may have to adjust that if you are not using Linux.
156
-
157
- Now you can run the driver directly using
144
+ Running the Miri driver requires some fiddling with environment variables, so the ` miri ` script helps you do that.
145
+ For example, you can run the driver on a particular file by doing
158
146
159
147
``` sh
160
- MIRI_SYSROOT= ~ /.cache /miri/HOST cargo run tests/run-pass/format.rs # or whatever test you like
148
+ . /miri run tests/run-pass/format.rs # or whatever test you like
161
149
```
162
150
163
151
and you can run the test suite using
164
152
165
153
```
166
- cargo test
154
+ ./miri test
167
155
```
168
156
169
- We recommend adding the ` --release ` flag to make tests run faster.
170
-
171
- ` cargo test --release FILTER ` only runs those tests that contain ` FILTER ` in
172
- their filename (including the base directory, e.g. ` cargo test --release fail `
173
- will run all compile-fail tests).
157
+ ` ./miri test FILTER ` only runs those tests that contain ` FILTER ` in their
158
+ filename (including the base directory, e.g. ` ./miri test fail ` will run all
159
+ compile-fail tests).
174
160
175
161
You can get a trace of which MIR statements are being executed by setting the
176
162
` MIRI_LOG ` environment variable. For example:
177
163
178
164
``` sh
179
- MIRI_LOG=info cargo run tests/run-pass/vecs.rs
165
+ MIRI_LOG=info ./miri run tests/run-pass/vecs.rs
180
166
```
181
167
182
168
Setting ` MIRI_LOG ` like this will configure logging for Miri itself as well as
@@ -185,7 +171,7 @@ can also do more targeted configuration, e.g. the following helps debug the
185
171
stacked borrows implementation:
186
172
187
173
``` sh
188
- MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows cargo run tests/run-pass/vecs.rs
174
+ MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/run-pass/vecs.rs
189
175
```
190
176
191
177
In addition, you can set ` MIRI_BACKTRACE=1 ` to get a backtrace of where an
@@ -199,7 +185,7 @@ is probably easier to test it with the cargo wrapper. You can install your
199
185
development version of Miri using
200
186
201
187
```
202
- cargo install --path . --force
188
+ ./miri install
203
189
```
204
190
205
191
and then you can use it as if it was installed by ` rustup ` . Make sure you use
@@ -235,18 +221,7 @@ rustup override set custom
235
221
```
236
222
237
223
With this, you should now have a working development setup! See
238
- [ above] [ testing-miri ] for how to proceed working with the Miri driver. Notice
239
- that rustc's sysroot is already built for Miri in this case, so you can set
240
- ` MIRI_SYSROOT=$(rustc --print sysroot) ` .
241
-
242
- Running ` cargo miri ` in this setup is a bit more complicated, because the Miri
243
- binary you just created needs help to find the libraries it links against. On
244
- Linux, you can set the rpath to make this "just work":
245
-
246
- ``` sh
247
- export RUSTFLAGS=" -C link-args=-Wl,-rpath,$( rustc --print sysroot) /lib/rustlib/x86_64-unknown-linux-gnu/lib"
248
- cargo install --path . --force
249
- ```
224
+ [ above] [ testing-miri ] for how to proceed working with the Miri driver.
250
225
251
226
### Miri ` -Z ` flags and environment variables
252
227
[ miri-flags ] : #miri--z-flags-and-environment-variables
0 commit comments