From 95f740600c530658a40687f169e2337171cbe612 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Mon, 15 Oct 2018 18:45:55 +0000 Subject: [PATCH 1/5] improve README instructions for using `rustup` and for compiling separate Cargo projects --- README.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e59accaea1..9c6128643c 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,29 @@ 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 --all-features --path .`. -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. +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. For a binary project, run `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri` to +build and run your project; for a binary or library, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test` +to run all tests in your project through Miri. + +If you forget to set `MIRI_SYSROOT`, be sure to run `cargo clean` again before +correcting it. Otherwise you are likely to get "dependency was built against possibly +newer std" errors. + +## Using Rustup To Specify a Specific Nightly + +To target a specific nightly, modify the above instructions as follows. + +1. Install Miri using `cargo +nightly-2018-10-15 install --all-features --path .`, +with the date replaced as appropriate. +2. Run `xargo/build.sh` as `rustup run nightly-2018-10-15 build.sh`. +3. When running tests, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-15 miri test`. ## Miri `-Z` flags From f77b29294829564f6d95148ef1e3749587518dfa Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Fri, 19 Oct 2018 15:07:19 +0000 Subject: [PATCH 2/5] added line indicating that `build.sh` and `cargo miri` need the same toolchain --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9c6128643c..087a2a44cf 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,10 @@ with the date replaced as appropriate. 2. Run `xargo/build.sh` as `rustup run nightly-2018-10-15 build.sh`. 3. When running tests, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-15 miri test`. +You may prefer to do this rather than depending on the rustup default toolchain, +if you routinely update the default, since **it is essential that `xargo/build.sh` +is run with the same toolchain as `cargo miri`.** + ## Miri `-Z` flags Miri adds some extra `-Z` flags to control its behavior: From 3dcf655eead8aa4f041d881a91200fc9998d4405 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sat, 20 Oct 2018 16:31:15 +0000 Subject: [PATCH 3/5] readme: pull "common problems" into their own section --- README.md | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 087a2a44cf..e5c2850ef3 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,33 @@ above: 1. Run `cargo clean` to eliminate any cached dependencies that were built against the non-MIR `libstd`. -2. For a binary project, run `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri` to -build and run your project; for a binary or library, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test` -to run all tests in your project through Miri. +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`. -If you forget to set `MIRI_SYSROOT`, be sure to run `cargo clean` again before -correcting it. Otherwise you are likely to get "dependency was built against possibly -newer std" errors. +### Common Problems + +When modifying the above instructions, you may encounter a number of confusing compiler +errors. + +#### "constant evaluation error: no mir for ``" + +You may have forgotten to set `MIRI_SYSROOT` when calling `cargo miri test`, and +your program called into `std` or `core`. Be sure to set `MIRI_SYSROOT=~/.xargo/HOST`. + +#### "found possibly newer version of crate `std` which `` 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" + +You may be running `cargo miri test` with a different compiler version than the one +used to build the MIR-enabled `std`. Be sure to consistently use the same toolchain, +perhaps by following the below instructions to specify a specific nightly for use +with Miri. ## Using Rustup To Specify a Specific Nightly @@ -68,13 +88,9 @@ To target a specific nightly, modify the above instructions as follows. 1. Install Miri using `cargo +nightly-2018-10-15 install --all-features --path .`, with the date replaced as appropriate. -2. Run `xargo/build.sh` as `rustup run nightly-2018-10-15 build.sh`. +2. Run `xargo/build.sh` as `rustup run nightly-2018-10-15 xargo/build.sh`. 3. When running tests, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-15 miri test`. -You may prefer to do this rather than depending on the rustup default toolchain, -if you routinely update the default, since **it is essential that `xargo/build.sh` -is run with the same toolchain as `cargo miri`.** - ## Miri `-Z` flags Miri adds some extra `-Z` flags to control its behavior: From abda1a8ebb4f38929a6f62e73b81ce6deb95ef61 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sun, 21 Oct 2018 16:46:28 +0000 Subject: [PATCH 4/5] rename `rust-toolchain` to `rust-version`; add note to README about usage --- .travis.yml | 3 +-- README.md | 4 +++- appveyor.yml | 2 +- rust-toolchain => rust-version | 0 4 files changed, 5 insertions(+), 4 deletions(-) rename rust-toolchain => rust-version (100%) diff --git a/.travis.yml b/.travis.yml index d2315c7e95..095af11627 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,8 @@ before_script: if [ "$TRAVIS_EVENT_TYPE" = cron ]; then RUST_TOOLCHAIN=nightly else - RUST_TOOLCHAIN=$(cat rust-toolchain) + RUST_TOOLCHAIN=$(cat rust-version) fi -- rm rust-toolchain # install Rust - curl https://build.travis-ci.org/files/rustup-init.sh -sSf | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" - export PATH=$HOME/.cargo/bin:$PATH diff --git a/README.md b/README.md index e5c2850ef3..76127d8b62 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,9 @@ with Miri. ## Using Rustup To Specify a Specific Nightly -To target a specific nightly, modify the above instructions as follows. +To target a specific nightly, modify the above instructions as follows. It is recommended +to use the nightly specified in the `rust-version` file in this repo, since that is the +most recent nightly supported by Miri. 1. Install Miri using `cargo +nightly-2018-10-15 install --all-features --path .`, with the date replaced as appropriate. diff --git a/appveyor.yml b/appveyor.yml index 4614891a31..cf578120c9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ branches: install: # install Rust - set PATH=C:\Program Files\Git\mingw64\bin;C:\msys64\mingw%MSYS2_BITS%\bin;%PATH% - - set /p RUST_TOOLCHAIN= Date: Tue, 23 Oct 2018 15:21:19 +0000 Subject: [PATCH 5/5] README: remove "specific nightly" instructions and use +nightly throughout Also replace `cargo miri test` with `cargo miri` in general examples. --- README.md | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 76127d8b62..7597c9a0e1 100644 --- a/README.md +++ b/README.md @@ -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,7 +49,7 @@ 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 --path .`. +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: @@ -61,12 +63,12 @@ the non-MIR `libstd`. ### Common Problems -When modifying the above instructions, you may encounter a number of confusing compiler +When using the above instructions, you may encounter a number of confusing compiler errors. #### "constant evaluation error: no mir for ``" -You may have forgotten to set `MIRI_SYSROOT` when calling `cargo miri test`, and +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 `` depends on" @@ -77,21 +79,9 @@ builds and vice-versa. #### "found crate `std` compiled by an incompatible version of rustc" -You may be running `cargo miri test` with a different compiler version than the one +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, -perhaps by following the below instructions to specify a specific nightly for use -with Miri. - -## Using Rustup To Specify a Specific Nightly - -To target a specific nightly, modify the above instructions as follows. It is recommended -to use the nightly specified in the `rust-version` file in this repo, since that is the -most recent nightly supported by Miri. - -1. Install Miri using `cargo +nightly-2018-10-15 install --all-features --path .`, -with the date replaced as appropriate. -2. Run `xargo/build.sh` as `rustup run nightly-2018-10-15 xargo/build.sh`. -3. When running tests, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-15 miri test`. +which should be the toolchain specified in the `rust-version` file. ## Miri `-Z` flags