@@ -7,41 +7,33 @@ undergraduate research course at the [University of Saskatchewan][usask].
7
7
8
8
## Building Miri
9
9
10
- I recommend that you install [ rustup] [ rustup ] to obtain Rust. miri comes with a
10
+ I recommend that you install [ rustup] [ rustup ] to obtain Rust. Miri comes with a
11
11
` rust-toolchain ` file so rustup will automatically pick a suitable nightly
12
12
version. Then all you have to do is:
13
13
14
14
``` sh
15
15
cargo build
16
16
```
17
17
18
- ## Running tests
18
+ ## Running Miri
19
19
20
20
``` sh
21
21
cargo run tests/run-pass/vecs.rs # Or whatever test you like.
22
22
```
23
23
24
- ## Running miri on your own project('s test suite)
25
-
26
- Install miri as a cargo subcommand with ` cargo install --debug ` .
27
- Then, inside your own project, use ` cargo +nightly miri ` to run your project, if it is
28
- a bin project, or run ` cargo +nightly miri test ` to run all tests in your project
29
- through miri.
30
-
31
- ## Running miri with full libstd
24
+ ## Running Miri with full libstd
32
25
33
26
Per default libstd does not contain the MIR of non-polymorphic functions. When
34
- miri hits a call to such a function, execution terminates. To fix this, it is
27
+ Miri hits a call to such a function, execution terminates. To fix this, it is
35
28
possible to compile libstd with full MIR:
36
29
37
30
``` sh
38
31
rustup component add rust-src
39
32
cargo install xargo
40
- cd xargo/
41
- RUSTFLAGS=' -Zalways-encode-mir' xargo build
33
+ xargo/build.sh
42
34
```
43
35
44
- Now you can run miri against the libstd compiled by xargo:
36
+ Now you can run Miri against the libstd compiled by xargo:
45
37
46
38
``` sh
47
39
MIRI_SYSROOT=~ /.xargo/HOST cargo run tests/run-pass-fullmir/hashmap.rs
@@ -50,13 +42,23 @@ MIRI_SYSROOT=~/.xargo/HOST cargo run tests/run-pass-fullmir/hashmap.rs
50
42
Notice that you will have to re-run the last step of the preparations above when
51
43
your toolchain changes (e.g., when you update the nightly).
52
44
53
- You can also set ` -Zmiri-start-fn ` to make miri start evaluation with the
45
+ You can also set ` -Zmiri-start-fn ` to make Miri start evaluation with the
54
46
` start_fn ` lang item, instead of starting at the ` main ` function.
55
47
48
+ ## Running Miri on your own project('s test suite)
49
+
50
+ Install Miri as a cargo subcommand with ` cargo install --all-features ` , and install
51
+ a full libstd as described above.
52
+
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.
57
+
56
58
## Development and Debugging
57
59
58
- Since the heart of miri (the main interpreter engine) lives in rustc, working on
59
- miri will often require using a locally built rustc. This includes getting a
60
+ Since the heart of Miri (the main interpreter engine) lives in rustc, working on
61
+ Miri will often require using a locally built rustc. This includes getting a
60
62
trace of the execution, as distributed rustc has ` trace! ` disabled.
61
63
62
64
The first-time setup for a local rustc looks as follows:
@@ -68,12 +70,12 @@ cp config.toml.example config.toml
68
70
./x.py build src/rustc
69
71
# You may have to change the architecture in the next command
70
72
rustup toolchain link custom build/x86_64-unknown-linux-gnu/stage2
71
- # Now cd to your miri directory
73
+ # Now cd to your Miri directory
72
74
rustup override set custom
73
75
```
74
76
The ` build ` step can take 30 minutes and more.
75
77
76
- Now you can ` cargo build ` miri , and you can ` cargo test --tests ` . (` --tests `
78
+ Now you can ` cargo build ` Miri , and you can ` cargo test --tests ` . (` --tests `
77
79
is needed to skip doctests because we have not built rustdoc for your custom
78
80
toolchain.) You can also set ` RUST_LOG=rustc_mir::interpret=trace ` as
79
81
environment variable to get a step-by-step trace.
0 commit comments