@@ -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,42 @@ 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- ```
67-
68- Now you can run Miri against the libstd compiled by xargo:
69-
70- ``` sh
71- MIRI_SYSROOT=~ /.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs
72- ```
73-
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-
7854## Running Miri on your own project('s test suite)
7955
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 ` .
56+ Install Miri as a cargo subcommand with ` cargo +nightly install --path . ` . Be
57+ aware that if you used ` rustup override set ` to fix a particular Rust version
58+ for the miri directory, that will * not* apply to your own project directory!
59+ You have to use a consistent Rust version for building miri and your project for
60+ this to work, so remember to either always specify the nightly version manually,
61+ overriding it in your project directory as well, or use ` rustup default nightly `
62+ (or ` rustup default nightly-YYYY-MM-DD ` ) to globally make ` nightly ` the default
63+ toolchain.
64+
65+ 1 . Run ` cargo clean ` to eliminate any cached dependencies. Miri needs your
66+ dependencies to be compiled the right way, that would not happen if they have
67+ previously already been compiled.
68+ 2 . To run all tests in your project through Miri, use ` cargo +nightly miri test ` .
69+ ** NOTE** : This is currently broken, see the discussion in
70+ [ #479 ] ( https://github.com/solson/miri/issues/479 ) .
71+ 3 . If you have a binary project, you can run it through Miri using `cargo
72+ +nightly miri run`.
10073
10174### Common Problems
10275
10376When using the above instructions, you may encounter a number of confusing compiler
10477errors.
10578
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-
11179#### "found possibly newer version of crate ` std ` which ` <dependency> ` depends on"
11280
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.
81+ Your build directory may contain artifacts from an earlier build that have/have
82+ not been built for Miri . Run ` cargo clean ` before switching from non-Miri to
83+ Miri builds and vice-versa.
11684
11785#### "found crate ` std ` compiled by an incompatible version of rustc"
11886
11987You 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 .
88+ used to build the custom libstd that Miri uses, and Miri failed to detect that.
89+ Try deleting ` ~/.miri ` .
12290
12391## Miri ` -Z ` flags
12492
0 commit comments