@@ -42,7 +42,7 @@ in this directory.
42
42
43
43
[ rustup ] : https://www.rustup.rs
44
44
45
- ## Running Miri
45
+ ## Running Miri on tiny examples
46
46
47
47
``` sh
48
48
cargo +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
51
51
We have to disable validation because that can lead to errors when libstd is not
52
52
compiled the right way.
53
53
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
-
78
54
## Running Miri on your own project('s test suite)
79
55
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`.
100
73
101
74
### Common Problems
102
75
103
76
When using the above instructions, you may encounter a number of confusing compiler
104
77
errors.
105
78
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
-
111
79
#### "found possibly newer version of crate ` std ` which ` <dependency> ` depends on"
112
80
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.
116
84
117
85
#### "found crate ` std ` compiled by an incompatible version of rustc"
118
86
119
87
You 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 ` .
122
90
123
91
## Miri ` -Z ` flags
124
92
0 commit comments