Skip to content

Commit c02988b

Browse files
authored
Merge pull request #494 from RalfJung/readme
update README
2 parents 1cbed5c + 8f9ca24 commit c02988b

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

README.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ undergraduate research course at the [University of Saskatchewan][usask].
77

88
## Building Miri
99

10-
I recommend that you install [rustup][rustup] to obtain Rust. Miri comes with a
11-
`rust-version` file describing the latest supported nightly version of the Rust
12-
compiler toolchain. Then all you have to do is:
10+
I recommend that you install [rustup][rustup] to obtain Rust. Then all you have
11+
to do is:
1312

1413
```sh
1514
cargo +nightly build
1615
```
1716

18-
with `+nightly` replaced with the appropriate nightly version of Rust.
17+
This uses the very latest Rust version. If you experience any problem, refer to
18+
the `rust-version` file which contains a particular Rust nightly version that
19+
has been tested against the version of miri you are using. Make sure to use
20+
that particular `nightly-YYYY-MM-DD` whenever the instructions just say
21+
`nightly`.
22+
23+
To avoid repeating the nightly version all the time, you can use
24+
`rustup override set nightly` (or `rustup override set nightly-YYYY-MM-DD`),
25+
which means `nightly` Rust will automatically be used whenever you are working
26+
in this directory.
1927

2028
## Running Miri
2129

@@ -41,18 +49,23 @@ Now you can run Miri against the libstd compiled by xargo:
4149
MIRI_SYSROOT=~/.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs
4250
```
4351

44-
Notice that you will have to re-run the last step of the preparations above when
45-
your toolchain changes (e.g., when you update the nightly).
46-
47-
You can also set `-Zmiri-start-fn` to make Miri start evaluation with the
48-
`start_fn` lang item, instead of starting at the `main` function.
52+
Notice that you will have to re-run the last step of the preparations above
53+
(`xargo/build.sh`) when your toolchain changes (e.g., when you update the
54+
nightly).
4955

5056
## Running Miri on your own project('s test suite)
5157

52-
Install Miri as a cargo subcommand with `cargo install +nightly --all-features --path .`.
58+
Install Miri as a cargo subcommand with `cargo install +nightly --all-features
59+
--path .`. Be aware that if you used `rustup override set` to fix a particular
60+
Rust version for the miri directory, that will *not* apply to your own project
61+
directory! You have to use a consistent Rust version for building miri and your
62+
project for this to work, so remember to either always specify the nightly
63+
version manually, overriding it in your project directory as well, or use
64+
`rustup default nightly` (or `rustup default nightly-YYYY-MM-DD`) to globally
65+
make `nightly` the default toolchain.
5366

54-
Compile your project and its dependencies against a MIR-enabled libstd as described
55-
above:
67+
We assume that you have prepared a MIR-enabled libstd as described above. Now
68+
compile your project and its dependencies against that libstd:
5669

5770
1. Run `cargo clean` to eliminate any cached dependencies that were built against
5871
the non-MIR `libstd`.
@@ -85,11 +98,17 @@ which should be the toolchain specified in the `rust-version` file.
8598

8699
## Miri `-Z` flags
87100

88-
Miri adds some extra `-Z` flags to control its behavior:
89-
90-
* `-Zmiri-start-fn`: This makes interpretation start with `lang_start` (defined
91-
in libstd) instead of starting with `main`. Requires full MIR!
92-
* `-Zmiri-disable-validation` disables enforcing the validity invariant.
101+
Several `-Z` flags are relevant for miri:
102+
103+
* `-Zmir-opt-level` controls how many MIR optimizations are performed. miri
104+
overrides the default to be `0`; be advised that using any higher level can
105+
make miri miss bugs in your program because they got optimized away.
106+
* `-Zalways-encode-mir` makes rustc dump MIR even for completely monomorphic
107+
functions. This is needed so that miri can execute such functions, so miri
108+
sets this flag per default.
109+
* `-Zmiri-disable-validation` is a custom `-Z` flag added by miri. It disables
110+
enforcing the validity invariant, which is enforced by default. This is
111+
mostly useful for debugging; it means miri will miss bugs in your program.
93112

94113
## Development and Debugging
95114

0 commit comments

Comments
 (0)