@@ -141,42 +141,30 @@ version of `rustc` that, instead of compiling your code, runs it. It accepts
141141all the same flags as ` rustc ` (though the ones only affecting code generation
142142and linking obviously will have no effect) [ and more] [ miri-flags ] .
143143
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
145+ the ` miri ` script helps you do that. For example, you can run the driver on a
146+ particular file by doing
158147
159148``` sh
160- MIRI_SYSROOT=~ /.cache/miri/HOST cargo run tests/run-pass/format.rs # or whatever test you like
149+ ./miri run tests/run-pass/format.rs
150+ ./miri run tests/run-pass/hello.rs --target i686-unknown-linux-gnu
161151```
162152
163- and you can run the test suite using
153+ and you can run the test suite using:
164154
165155```
166- cargo test
156+ ./miri test
167157```
168158
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).
159+ ` ./miri test FILTER ` only runs those tests that contain ` FILTER ` in their
160+ filename (including the base directory, e.g. ` ./miri test fail ` will run all
161+ compile-fail tests).
174162
175163You can get a trace of which MIR statements are being executed by setting the
176164` MIRI_LOG ` environment variable. For example:
177165
178166``` sh
179- MIRI_LOG=info cargo run tests/run-pass/vecs.rs
167+ MIRI_LOG=info ./miri run tests/run-pass/vecs.rs
180168```
181169
182170Setting ` MIRI_LOG ` like this will configure logging for Miri itself as well as
@@ -185,7 +173,7 @@ can also do more targeted configuration, e.g. the following helps debug the
185173stacked borrows implementation:
186174
187175``` sh
188- MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows cargo run tests/run-pass/vecs.rs
176+ MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/run-pass/vecs.rs
189177```
190178
191179In addition, you can set ` MIRI_BACKTRACE=1 ` to get a backtrace of where an
@@ -199,7 +187,7 @@ is probably easier to test it with the cargo wrapper. You can install your
199187development version of Miri using
200188
201189```
202- cargo install --path . --force
190+ ./miri install
203191```
204192
205193and then you can use it as if it was installed by ` rustup ` . Make sure you use
@@ -235,18 +223,7 @@ rustup override set custom
235223```
236224
237225With 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- ```
226+ [ above] [ testing-miri ] for how to proceed working with the Miri driver.
250227
251228### Miri ` -Z ` flags and environment variables
252229[ miri-flags ] : #miri--z-flags-and-environment-variables
0 commit comments