-
Notifications
You must be signed in to change notification settings - Fork 410
improve README instructions for using rustup and for compiling separate crates
#483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
95f7406
f77b292
3dcf655
abda1a8
5347411
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,17 +8,19 @@ undergraduate research course at the [University of Saskatchewan][usask]. | |
| ## Building Miri | ||
|
|
||
| I recommend that you install [rustup][rustup] to obtain Rust. Miri comes with a | ||
| `rust-toolchain` file so rustup will automatically pick a suitable nightly | ||
| version. Then all you have to do is: | ||
| `rust-version` file describing the latest supported nightly version of the Rust | ||
| compiler toolchain. Then all you have to do is: | ||
|
|
||
| ```sh | ||
| cargo build | ||
| cargo +nightly build | ||
| ``` | ||
|
|
||
| with `+nightly` replaced with the appropriate nightly version of Rust. | ||
|
|
||
| ## Running Miri | ||
|
|
||
| ```sh | ||
| cargo run tests/run-pass/vecs.rs # Or whatever test you like. | ||
| cargo +nightly run tests/run-pass/vecs.rs # Or whatever test you like. | ||
| ``` | ||
|
|
||
| ## Running Miri with full libstd | ||
|
|
@@ -28,15 +30,15 @@ Miri hits a call to such a function, execution terminates. To fix this, it is | |
| possible to compile libstd with full MIR: | ||
|
|
||
| ```sh | ||
| rustup component add rust-src | ||
| cargo install xargo | ||
| xargo/build.sh | ||
| rustup component add --toolchain nightly rust-src | ||
| cargo +nightly install xargo | ||
| rustup run nightly xargo/build.sh | ||
| ``` | ||
|
|
||
| Now you can run Miri against the libstd compiled by xargo: | ||
|
|
||
| ```sh | ||
| MIRI_SYSROOT=~/.xargo/HOST cargo run tests/run-pass-fullmir/hashmap.rs | ||
| MIRI_SYSROOT=~/.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs | ||
| ``` | ||
|
|
||
| Notice that you will have to re-run the last step of the preparations above when | ||
|
|
@@ -47,13 +49,39 @@ You can also set `-Zmiri-start-fn` to make Miri start evaluation with the | |
|
|
||
| ## Running Miri on your own project('s test suite) | ||
|
|
||
| Install Miri as a cargo subcommand with `cargo install --all-features`, and install | ||
| a full libstd as described above. | ||
| Install Miri as a cargo subcommand with `cargo install +nightly --all-features --path .`. | ||
|
|
||
| Compile your project and its dependencies against a MIR-enabled libstd as described | ||
| above: | ||
|
|
||
| 1. Run `cargo clean` to eliminate any cached dependencies that were built against | ||
| the non-MIR `libstd`. | ||
| 2. To run all tests in your project through, Miri, use | ||
| `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test`. | ||
| 3. If you have a binary project, you can run it through Miri using | ||
| `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri`. | ||
|
|
||
| ### Common Problems | ||
|
|
||
| When using the above instructions, you may encounter a number of confusing compiler | ||
| errors. | ||
|
|
||
| #### "constant evaluation error: no mir for `<function>`" | ||
|
|
||
| You may have forgotten to set `MIRI_SYSROOT` when calling `cargo miri`, and | ||
| your program called into `std` or `core`. Be sure to set `MIRI_SYSROOT=~/.xargo/HOST`. | ||
|
|
||
| #### "found possibly newer version of crate `std` which `<dependency>` depends on" | ||
|
|
||
| Your build directory may contain artifacts from an earlier build that did/did not | ||
| have `MIRI_SYSROOT` set. Run `cargo clean` before switching from non-Miri to Miri | ||
| builds and vice-versa. | ||
|
|
||
| #### "found crate `std` compiled by an incompatible version of rustc" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand how/why this is different from the one right before. Seems to me both are caused by "sysroot confusion", and both are solved the same way. Why should we give different advise for these two?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand. They have different causes and different solutions.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, the difference is "deps were built without I think what threw me off was specifically mentioning |
||
|
|
||
| Then, inside your own project, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly | ||
| miri` to run your project, if it is a bin project, or run | ||
| `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test` to run all tests in your | ||
| project through Miri. | ||
| You may be running `cargo miri` with a different compiler version than the one | ||
| used to build the MIR-enabled `std`. Be sure to consistently use the same toolchain, | ||
RalfJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| which should be the toolchain specified in the `rust-version` file. | ||
|
|
||
| ## Miri `-Z` flags | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.