@@ -8,17 +8,19 @@ undergraduate research course at the [University of Saskatchewan][usask].
88## Building Miri
99
1010I recommend that you install [ rustup] [ rustup ] to obtain Rust. Miri comes with a
11- ` rust-toolchain ` file so rustup will automatically pick a suitable nightly
12- version. Then all you have to do is:
11+ ` rust-version ` file describing the latest supported nightly version of the Rust
12+ compiler toolchain. Then all you have to do is:
1313
1414``` sh
15- cargo build
15+ cargo +nightly build
1616```
1717
18+ with ` +nightly ` replaced with the appropriate nightly version of Rust.
19+
1820## Running Miri
1921
2022``` sh
21- cargo run tests/run-pass/vecs.rs # Or whatever test you like.
23+ cargo +nightly run tests/run-pass/vecs.rs # Or whatever test you like.
2224```
2325
2426## Running Miri with full libstd
@@ -28,15 +30,15 @@ Miri hits a call to such a function, execution terminates. To fix this, it is
2830possible to compile libstd with full MIR:
2931
3032``` sh
31- rustup component add rust-src
32- cargo install xargo
33- xargo/build.sh
33+ rustup component add --toolchain nightly rust-src
34+ cargo +nightly install xargo
35+ rustup run nightly xargo/build.sh
3436```
3537
3638Now you can run Miri against the libstd compiled by xargo:
3739
3840``` sh
39- MIRI_SYSROOT=~ /.xargo/HOST cargo run tests/run-pass-fullmir/hashmap.rs
41+ MIRI_SYSROOT=~ /.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs
4042```
4143
4244Notice that you will have to re-run the last step of the preparations above when
@@ -47,13 +49,39 @@ You can also set `-Zmiri-start-fn` to make Miri start evaluation with the
4749
4850## Running Miri on your own project('s test suite)
4951
50- Install Miri as a cargo subcommand with ` cargo install --all-features ` , and install
51- a full libstd as described above.
52+ Install Miri as a cargo subcommand with ` cargo install +nightly --all-features --path . ` .
53+
54+ Compile your project and its dependencies against a MIR-enabled libstd as described
55+ above:
56+
57+ 1 . Run ` cargo clean ` to eliminate any cached dependencies that were built against
58+ the non-MIR ` libstd ` .
59+ 2 . To run all tests in your project through, Miri, use
60+ ` MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test ` .
61+ 3 . If you have a binary project, you can run it through Miri using
62+ ` MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri ` .
63+
64+ ### Common Problems
65+
66+ When using the above instructions, you may encounter a number of confusing compiler
67+ errors.
68+
69+ #### "constant evaluation error: no mir for ` <function> ` "
70+
71+ You may have forgotten to set ` MIRI_SYSROOT ` when calling ` cargo miri ` , and
72+ your program called into ` std ` or ` core ` . Be sure to set ` MIRI_SYSROOT=~/.xargo/HOST ` .
73+
74+ #### "found possibly newer version of crate ` std ` which ` <dependency> ` depends on"
75+
76+ Your build directory may contain artifacts from an earlier build that did/did not
77+ have ` MIRI_SYSROOT ` set. Run ` cargo clean ` before switching from non-Miri to Miri
78+ builds and vice-versa.
79+
80+ #### "found crate ` std ` compiled by an incompatible version of rustc"
5281
53- Then, inside your own project, use `MIRI_SYSROOT=~ /.xargo/HOST cargo +nightly
54- miri` to run your project, if it is a bin project, or run
55- ` MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test ` to run all tests in your
56- project through Miri.
82+ You may be running ` cargo miri ` with a different compiler version than the one
83+ used to build the MIR-enabled ` std ` . Be sure to consistently use the same toolchain,
84+ which should be the toolchain specified in the ` rust-version ` file.
5785
5886## Miri ` -Z ` flags
5987
0 commit comments