@@ -27,42 +27,31 @@ list!
27
27
28
28
## Running Miri on your own project (and its test suite)
29
29
30
- Install Miri as a cargo subcommand :
30
+ Install Miri via ` rustup ` :
31
31
32
32
``` sh
33
- cargo +nightly install --force --git https://github.com/rust-lang/miri miri
33
+ rustup component add miri
34
34
```
35
35
36
- If this does not work, try using the nightly version given in
37
- [ this file] ( https://raw.githubusercontent.com/rust-lang/miri/master/rust-version ) . CI
38
- should ensure that this nightly always works.
39
-
40
- You have to use a consistent Rust version for building miri and your project, so
41
- remember to either always specify the nightly version manually (like in the
42
- example above), overriding it in your project directory as well, or use `rustup
43
- default nightly` (or ` rustup default nightly-YYYY-MM-DD`) to globally make
44
- ` nightly ` the default toolchain.
45
-
46
36
Now you can run your project in Miri:
47
37
48
38
1 . Run ` cargo clean ` to eliminate any cached dependencies. Miri needs your
49
39
dependencies to be compiled the right way, that would not happen if they have
50
40
previously already been compiled.
51
- 2 . To run all tests in your project through Miri, use ` cargo +nightly miri test ` .
52
- 3 . If you have a binary project, you can run it through Miri using `cargo
53
- +nightly miri run`.
41
+ 2 . To run all tests in your project through Miri, use ` cargo miri test ` .
42
+ 3 . If you have a binary project, you can run it through Miri using ` cargo miri run ` .
54
43
55
44
The first time you run Miri, it will perform some extra setup and install some
56
45
dependencies. It will ask you for confirmation before installing anything. If
57
- you run Miri on CI, run ` cargo +nightly miri setup ` to avoid getting interactive
46
+ you run Miri on CI, run ` cargo miri setup ` to avoid getting interactive
58
47
questions.
59
48
60
49
You can pass arguments to Miri after the first ` -- ` , and pass arguments to the
61
50
interpreted program or test suite after the second ` -- ` . For example, `cargo
62
- +nightly miri run -- -Zmiri-disable-validation` runs the program without
63
- validation of basic type invariants and references. `cargo +nightly miri test
64
- -- -- -Zunstable-options -- exclude-should-panic` skips ` #[ should_panic] ` tests,
65
- which is a good idea because Miri does not support unwinding or catching panics.
51
+ miri run -- -Zmiri-disable-validation` runs the program without validation of
52
+ basic type invariants and references. `cargo miri test -- -- -Zunstable-options
53
+ --exclude-should-panic` skips ` #[ should_panic] ` tests, which is a good idea
54
+ because Miri does not support unwinding or catching panics.
66
55
67
56
When running code via ` cargo miri ` , the ` miri ` config flag is set. You can
68
57
use this to exclude test cases that will fail under Miri because they do things
@@ -110,10 +99,14 @@ convenient way is to install Miri using cargo, then you can easily run it on
110
99
other projects:
111
100
112
101
``` sh
102
+ rustup component remove miri # avoid having Miri installed twice
113
103
cargo +nightly install --path " $DIR " --force # or the nightly in `rust-version`
114
104
cargo +nightly miri setup
115
105
```
116
106
107
+ (We are giving ` +nightly ` explicitly here all the time because it is important
108
+ that all of these commands get executed with the same toolchain.)
109
+
117
110
If you want to use a different libstd (not the one that comes with the
118
111
nightly), you can do that by running
119
112
@@ -124,9 +117,6 @@ XARGO_RUST_SRC=~/src/rust/rustc/src/ cargo +nightly miri setup
124
117
Either way, you can now do ` cargo +nightly miri run ` to run Miri with your
125
118
local changes on whatever project you are debugging.
126
119
127
- (We are giving ` +nightly ` explicitly here all the time because it is important
128
- that all of these commands get executed with the same toolchain.)
129
-
130
120
` cargo miri setup ` should end in printing the directory where the libstd was
131
121
built. For the next step to work, set that as your ` MIRI_SYSROOT ` environment
132
122
variable:
0 commit comments