From ca9d50982d4b2fd5abe09066afdadd57c674ff57 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Mon, 6 Mar 2023 21:30:16 -0500 Subject: [PATCH 1/4] Install binaries to the miri toolchain's sysroot --- src/tools/miri/ci.sh | 4 ++-- src/tools/miri/miri | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh index 60450d098154..ef52a37fe319 100755 --- a/src/tools/miri/ci.sh +++ b/src/tools/miri/ci.sh @@ -62,8 +62,8 @@ function run_tests { if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then # These act up on Windows (`which miri` produces a filename that does not exist?!?), # so let's do this only on Linux. Also makes sure things work without these set. - export RUSTC=$(which rustc) - export MIRI=$(which miri) + export RUSTC=$(which rustc) # Produces a warning unless we also set MIRI + export MIRI=$(rustc +miri --print sysroot)/bin/miri fi mkdir -p .cargo echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml diff --git a/src/tools/miri/miri b/src/tools/miri/miri index 0c0bbbc70208..998e0d295243 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -281,8 +281,9 @@ find_sysroot() { case "$COMMAND" in install) # "--locked" to respect the Cargo.lock file if it exists. - $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked "$@" - $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked "$@" + # Install binaries to the miri toolchain's sysroot so they do not interact with other toolchains + $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked --root "$SYSROOT" "$@" + $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --root "$SYSROOT" "$@" ;; check) # Check, and let caller control flags. From 3ff7d3da54a45e8709fa056d07cb538e1297731a Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Mon, 13 Mar 2023 17:49:20 -0400 Subject: [PATCH 2/4] Update docs to match Co-authored-by: Ralf Jung --- src/tools/miri/CONTRIBUTING.md | 11 ++++------- src/tools/miri/miri | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/tools/miri/CONTRIBUTING.md b/src/tools/miri/CONTRIBUTING.md index 476075e9c914..bcdb623b090e 100644 --- a/src/tools/miri/CONTRIBUTING.md +++ b/src/tools/miri/CONTRIBUTING.md @@ -129,18 +129,15 @@ development version of Miri using ./miri install ``` -and then you can use it as if it was installed by `rustup`. Make sure you use -the same toolchain when calling `cargo miri` that you used when installing Miri! -Usually this means you have to write `cargo +miri miri ...` to select the `miri` -toolchain that was installed by `./miri toolchain`. +and then you can use it as if it was installed by `rustup` as a component of the +`miri` toolchain. Note that the `miri` and `cargo-miri` executables are placed +in the `miri` toolchain's sysroot to prevent conflicts with other toolchains. +The Miri binaries in the `cargo` bin directory (usually `~/.cargo/bin`) are managed by rustup. There's a test for the cargo wrapper in the `test-cargo-miri` directory; run `./run-test.py` in there to execute it. Like `./miri test`, this respects the `MIRI_TEST_TARGET` environment variable to execute the test for another target. -Note that installing Miri like this will "take away" Miri management from `rustup`. -If you want to later go back to a rustup-installed Miri, run `rustup update`. - ### Using a modified standard library Miri re-builds the standard library into a custom sysroot, so it is fairly easy diff --git a/src/tools/miri/miri b/src/tools/miri/miri index 998e0d295243..1073ff499ba0 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -6,8 +6,8 @@ USAGE=$(cat <<"EOF" ./miri install : Installs the miri driver and cargo-miri. are passed to `cargo install`. Sets up the rpath such that the installed binary should work in any -working directory. However, the rustup toolchain when invoking `cargo miri` -needs to be the same one used for `./miri install`. +working directory. Note that the binaries are placed in the `miri` toolchain +sysroot, to prevent conflicts with other toolchains. ./miri build : Just build miri. are passed to `cargo build`. @@ -281,7 +281,7 @@ find_sysroot() { case "$COMMAND" in install) # "--locked" to respect the Cargo.lock file if it exists. - # Install binaries to the miri toolchain's sysroot so they do not interact with other toolchains + # Install binaries to the miri toolchain's sysroot so they do not interact with other toolchains. $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked --root "$SYSROOT" "$@" $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --root "$SYSROOT" "$@" ;; From 43dff4f78fa835938c7abbf30f528f4220971184 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Mon, 13 Mar 2023 21:21:11 -0400 Subject: [PATCH 3/4] Don't use CI caches from before this branch --- src/tools/miri/.github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/miri/.github/workflows/ci.yml b/src/tools/miri/.github/workflows/ci.yml index 138a69974e14..4ae081e2c45d 100644 --- a/src/tools/miri/.github/workflows/ci.yml +++ b/src/tools/miri/.github/workflows/ci.yml @@ -54,8 +54,8 @@ jobs: # contains package information of crates installed via `cargo install`. ~/.cargo/.crates.toml ~/.cargo/.crates2.json - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo + key: ${{ runner.os }}-cargo-installfix-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-installfix - name: Install rustup-toolchain-install-master if: ${{ steps.cache.outputs.cache-hit != 'true' }} @@ -106,8 +106,8 @@ jobs: # contains package information of crates installed via `cargo install`. ~/.cargo/.crates.toml ~/.cargo/.crates2.json - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo + key: ${{ runner.os }}-cargo-installfix-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-installfix - name: Install rustup-toolchain-install-master if: ${{ steps.cache.outputs.cache-hit != 'true' }} From 3aa4de3fa83083fd39469e07432a92759c89d1f0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 15 Mar 2023 13:44:36 +0100 Subject: [PATCH 4/4] use date-based cache key --- src/tools/miri/.github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/miri/.github/workflows/ci.yml b/src/tools/miri/.github/workflows/ci.yml index 4ae081e2c45d..b71f48e4644b 100644 --- a/src/tools/miri/.github/workflows/ci.yml +++ b/src/tools/miri/.github/workflows/ci.yml @@ -54,8 +54,8 @@ jobs: # contains package information of crates installed via `cargo install`. ~/.cargo/.crates.toml ~/.cargo/.crates2.json - key: ${{ runner.os }}-cargo-installfix-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo-installfix + key: ${{ runner.os }}-cargo-reset20230315-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-reset20230315 - name: Install rustup-toolchain-install-master if: ${{ steps.cache.outputs.cache-hit != 'true' }} @@ -106,8 +106,8 @@ jobs: # contains package information of crates installed via `cargo install`. ~/.cargo/.crates.toml ~/.cargo/.crates2.json - key: ${{ runner.os }}-cargo-installfix-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo-installfix + key: ${{ runner.os }}-cargo-reset20230315-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-reset20230315 - name: Install rustup-toolchain-install-master if: ${{ steps.cache.outputs.cache-hit != 'true' }}