Skip to content

Commit 3ad2fec

Browse files
committed
Auto merge of #2806 - saethlin:better-install, r=RalfJung
Install binaries to the miri toolchain's sysroot The default install produces this behavior: ``` $ cargo +miri miri --version miri 0.1.0 (0ba1f4a0 2023-03-05) $ cargo +nightly miri --version miri 0.1.0 (0ba1f4a0 2023-03-05) ``` Which is not good. We've effectively erased the toolchain selection, and users may reasonably conclude that their rustup install is broken. After this change, we now get this: ``` $ cargo +miri miri --version miri 0.1.0 (0ba1f4a0 2023-03-05) $ cargo +nightly miri --version miri 0.1.0 (f63ccaf 2023-03-06) ``` Thanks `@jyn514` who all but wrote this for me.
2 parents 5fde770 + 3aa4de3 commit 3ad2fec

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/tools/miri/.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
# contains package information of crates installed via `cargo install`.
5555
~/.cargo/.crates.toml
5656
~/.cargo/.crates2.json
57-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
58-
restore-keys: ${{ runner.os }}-cargo
57+
key: ${{ runner.os }}-cargo-reset20230315-${{ hashFiles('**/Cargo.lock') }}
58+
restore-keys: ${{ runner.os }}-cargo-reset20230315
5959

6060
- name: Install rustup-toolchain-install-master
6161
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
@@ -106,8 +106,8 @@ jobs:
106106
# contains package information of crates installed via `cargo install`.
107107
~/.cargo/.crates.toml
108108
~/.cargo/.crates2.json
109-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
110-
restore-keys: ${{ runner.os }}-cargo
109+
key: ${{ runner.os }}-cargo-reset20230315-${{ hashFiles('**/Cargo.lock') }}
110+
restore-keys: ${{ runner.os }}-cargo-reset20230315
111111

112112
- name: Install rustup-toolchain-install-master
113113
if: ${{ steps.cache.outputs.cache-hit != 'true' }}

src/tools/miri/CONTRIBUTING.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,15 @@ development version of Miri using
129129
./miri install
130130
```
131131

132-
and then you can use it as if it was installed by `rustup`. Make sure you use
133-
the same toolchain when calling `cargo miri` that you used when installing Miri!
134-
Usually this means you have to write `cargo +miri miri ...` to select the `miri`
135-
toolchain that was installed by `./miri toolchain`.
132+
and then you can use it as if it was installed by `rustup` as a component of the
133+
`miri` toolchain. Note that the `miri` and `cargo-miri` executables are placed
134+
in the `miri` toolchain's sysroot to prevent conflicts with other toolchains.
135+
The Miri binaries in the `cargo` bin directory (usually `~/.cargo/bin`) are managed by rustup.
136136

137137
There's a test for the cargo wrapper in the `test-cargo-miri` directory; run
138138
`./run-test.py` in there to execute it. Like `./miri test`, this respects the
139139
`MIRI_TEST_TARGET` environment variable to execute the test for another target.
140140

141-
Note that installing Miri like this will "take away" Miri management from `rustup`.
142-
If you want to later go back to a rustup-installed Miri, run `rustup update`.
143-
144141
### Using a modified standard library
145142

146143
Miri re-builds the standard library into a custom sysroot, so it is fairly easy

src/tools/miri/ci.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function run_tests {
6262
if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then
6363
# These act up on Windows (`which miri` produces a filename that does not exist?!?),
6464
# so let's do this only on Linux. Also makes sure things work without these set.
65-
export RUSTC=$(which rustc)
66-
export MIRI=$(which miri)
65+
export RUSTC=$(which rustc) # Produces a warning unless we also set MIRI
66+
export MIRI=$(rustc +miri --print sysroot)/bin/miri
6767
fi
6868
mkdir -p .cargo
6969
echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml

src/tools/miri/miri

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ USAGE=$(cat <<"EOF"
66
./miri install <flags>:
77
Installs the miri driver and cargo-miri. <flags> are passed to `cargo
88
install`. Sets up the rpath such that the installed binary should work in any
9-
working directory. However, the rustup toolchain when invoking `cargo miri`
10-
needs to be the same one used for `./miri install`.
9+
working directory. Note that the binaries are placed in the `miri` toolchain
10+
sysroot, to prevent conflicts with other toolchains.
1111
1212
./miri build <flags>:
1313
Just build miri. <flags> are passed to `cargo build`.
@@ -281,8 +281,9 @@ find_sysroot() {
281281
case "$COMMAND" in
282282
install)
283283
# "--locked" to respect the Cargo.lock file if it exists.
284-
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked "$@"
285-
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked "$@"
284+
# Install binaries to the miri toolchain's sysroot so they do not interact with other toolchains.
285+
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked --root "$SYSROOT" "$@"
286+
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --root "$SYSROOT" "$@"
286287
;;
287288
check)
288289
# Check, and let caller control flags.

0 commit comments

Comments
 (0)