@@ -42,7 +42,7 @@ in this directory.
4242
4343[ rustup ] : https://www.rustup.rs
4444
45- ## Running Miri
45+ ## Running Miri on tiny examples
4646
4747``` sh
4848cargo +nightly run -- -Zmiri-disable-validation tests/run-pass/vecs.rs # Or whatever test you like.
@@ -51,74 +51,47 @@ cargo +nightly run -- -Zmiri-disable-validation tests/run-pass/vecs.rs # Or what
5151We have to disable validation because that can lead to errors when libstd is not
5252compiled the right way.
5353
54- ## Running Miri with full libstd
55-
56- Per default libstd does not contain the MIR of non-polymorphic functions, and
57- also does not contain some extra MIR statements that miri needs for validation.
58- When Miri hits a call to such a function, execution terminates, and even when
59- the MIR is present, validation can fail. To fix this, it is possible to compile
60- libstd with full MIR:
61-
62- ``` sh
63- rustup component add --toolchain nightly rust-src
64- cargo +nightly install xargo
65- rustup run nightly xargo/build.sh
66- ```
54+ ## Running Miri on your own project('s test suite)
6755
68- Now you can run Miri against the libstd compiled by xargo :
56+ Install Miri as a cargo subcommand :
6957
7058``` sh
71- MIRI_SYSROOT= ~ /.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs
59+ cargo +nightly install --git https://github.com/solson/miri/ miri
7260```
7361
74- Notice that you will have to re-run the last step of the preparations above
75- (` xargo/build.sh ` ) when your toolchain changes (e.g., when you update the
76- nightly).
77-
78- ## Running Miri on your own project('s test suite)
79-
80- Install Miri as a cargo subcommand with `cargo +nightly install --all-features
81- --path .` . Be aware that if you used ` rustup override set` to fix a particular
82- Rust version for the miri directory, that will * not* apply to your own project
83- directory! You have to use a consistent Rust version for building miri and your
84- project for this to work, so remember to either always specify the nightly
85- version manually, overriding it in your project directory as well, or use
86- ` rustup default nightly ` (or ` rustup default nightly-YYYY-MM-DD ` ) to globally
87- make ` nightly ` the default toolchain.
88-
89- We assume that you have prepared a MIR-enabled libstd as described above. Now
90- compile your project and its dependencies against that libstd:
91-
92- 1 . Run ` cargo clean ` to eliminate any cached dependencies that were built against
93- the non-MIR ` libstd ` .
94- 2 . To run all tests in your project through, Miri, use
95- ` MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test ` . ** NOTE** : This is
96- currently broken, see the discussion in
97- [ #479 ] ( https://github.com/solson/miri/issues/479 ) .
98- 3 . If you have a binary project, you can run it through Miri using
99- ` MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri ` .
62+ Be aware that if you used ` rustup override set ` to fix a particular Rust version
63+ for the miri directory, that will * not* apply to your own project directory!
64+ You have to use a consistent Rust version for building miri and your project for
65+ this to work, so remember to either always specify the nightly version manually,
66+ overriding it in your project directory as well, or use ` rustup default nightly `
67+ (or ` rustup default nightly-YYYY-MM-DD ` ) to globally make ` nightly ` the default
68+ toolchain.
69+
70+ 1 . Run ` cargo clean ` to eliminate any cached dependencies. Miri needs your
71+ dependencies to be compiled the right way, that would not happen if they have
72+ previously already been compiled.
73+ 2 . To run all tests in your project through Miri, use ` cargo +nightly miri test ` .
74+ ** NOTE** : This is currently broken, see the discussion in
75+ [ #479 ] ( https://github.com/solson/miri/issues/479 ) .
76+ 3 . If you have a binary project, you can run it through Miri using `cargo
77+ +nightly miri run`.
10078
10179### Common Problems
10280
10381When using the above instructions, you may encounter a number of confusing compiler
10482errors.
10583
106- #### "constant evaluation error: no mir for ` <function> ` "
107-
108- You may have forgotten to set ` MIRI_SYSROOT ` when calling ` cargo miri ` , and
109- your program called into ` std ` or ` core ` . Be sure to set ` MIRI_SYSROOT=~/.xargo/HOST ` .
110-
11184#### "found possibly newer version of crate ` std ` which ` <dependency> ` depends on"
11285
113- Your build directory may contain artifacts from an earlier build that did/did not
114- have ` MIRI_SYSROOT ` set . Run ` cargo clean ` before switching from non-Miri to Miri
115- builds and vice-versa.
86+ Your build directory may contain artifacts from an earlier build that have/have
87+ not been built for Miri . Run ` cargo clean ` before switching from non-Miri to
88+ Miri builds and vice-versa.
11689
11790#### "found crate ` std ` compiled by an incompatible version of rustc"
11891
11992You may be running ` cargo miri ` with a different compiler version than the one
120- used to build the MIR-enabled ` std ` . Be sure to consistently use the same toolchain,
121- which should be the toolchain specified in the ` rust-version ` file .
93+ used to build the custom libstd that Miri uses, and Miri failed to detect that.
94+ Try deleting ` ~/.cache/miri ` .
12295
12396## Miri ` -Z ` flags
12497
0 commit comments