Skip to content

Commit 0f2b367

Browse files
committed
merge rustup-toolchain into ./miri
1 parent 7b239df commit 0f2b367

File tree

7 files changed

+58
-68
lines changed

7 files changed

+58
-68
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ jobs:
6767
shell: bash
6868
run: |
6969
if [[ ${{ github.event_name }} == 'schedule' ]]; then
70-
./rustup-toolchain HEAD --host ${{ matrix.host_target }}
70+
./miri toolchain HEAD --host ${{ matrix.host_target }}
7171
else
72-
./rustup-toolchain "" --host ${{ matrix.host_target }}
72+
./miri toolchain "" --host ${{ matrix.host_target }}
7373
fi
7474
7575
- name: Show Rust version
@@ -118,7 +118,7 @@ jobs:
118118
- name: Install "master" toolchain
119119
shell: bash
120120
run: |
121-
./rustup-toolchain "" -c clippy
121+
./miri toolchain
122122
123123
- name: Show Rust version
124124
run: |

.gitpod.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ tasks:
44
- before: echo "..."
55
init: |
66
cargo install rustup-toolchain-install-master
7-
./rustup-toolchain
7+
./miri toolchain
88
./miri build
9-
command: echo "Run tests with ./miri test"
9+
command: echo "Run tests with ./miri test"

CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ tested against. Other versions will likely not work. After installing
2323
[`rustup-toolchain-install-master`], you can run the following command to
2424
install that exact version of rustc as a toolchain:
2525
```
26-
./rustup-toolchain
26+
./miri toolchain
2727
```
2828
This will set up a rustup toolchain called `miri` and set it as an override for
2929
the current directory.
3030

3131
You can also create a `.auto-everything` file (contents don't matter, can be empty), which
32-
will cause any `./miri` command to automatically call `rustup-toolchain`, `clippy` and `rustfmt`
32+
will cause any `./miri` command to automatically call `./miri toolchain`, `clippy` and `rustfmt`
3333
for you. If you don't want all of these to happen, you can add individual `.auto-toolchain`,
3434
`.auto-clippy` and `.auto-fmt` files respectively.
3535

@@ -132,7 +132,7 @@ development version of Miri using
132132
and then you can use it as if it was installed by `rustup`. Make sure you use
133133
the same toolchain when calling `cargo miri` that you used when installing Miri!
134134
Usually this means you have to write `cargo +miri miri ...` to select the `miri`
135-
toolchain that was installed by `./rustup-toolchain`.
135+
toolchain that was installed by `./miri toolchain`.
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
@@ -214,7 +214,7 @@ for changes in rustc. In both cases, `rustc-version` needs updating.
214214

215215
To update the `rustc-version` file and install the latest rustc, you can run:
216216
```
217-
./rustup-toolchain HEAD
217+
./miri toolchain HEAD
218218
```
219219

220220
Now edit Miri until `./miri test` passes, and submit a PR. Generally, it is
@@ -297,7 +297,7 @@ We assume we start on an up-to-date master branch in the Miri repo.
297297
# Fetch and merge rustc side of the history. Takes ca 5 min the first time.
298298
./miri rustc-pull
299299
# Update toolchain reference and apply formatting.
300-
./rustup-toolchain HEAD && ./miri fmt
300+
./miri toolchain HEAD && ./miri fmt
301301
git commit -am "rustup"
302302
```
303303

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ Some native rustc `-Z` flags are also very relevant for Miri:
419419

420420
Moreover, Miri recognizes some environment variables:
421421

422-
* `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and rustup-toolchain
423-
should be skipped. If it is set to any value, they are skipped. This is used for avoiding
424-
infinite recursion in `./miri` and to allow automated IDE actions to avoid the auto ops.
422+
* `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and toolchain setup
423+
should be skipped. If it is set to any value, they are skipped. This is used for avoiding infinite
424+
recursion in `./miri` and to allow automated IDE actions to avoid the auto ops.
425425
* `MIRI_LOG`, `MIRI_BACKTRACE` control logging and backtrace printing during
426426
Miri executions, also [see "Testing the Miri driver" in `CONTRIBUTING.md`][testing-miri].
427427
* `MIRIFLAGS` (recognized by `cargo miri` and the test suite) defines extra

miri

+44-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ in the Rust fork of the given user to upstream. It will also pull a copy of the
5151
rustc history into the Miri repo, unless you set the RUSTC_GIT env var to an
5252
existing clone of the rustc repo.
5353
54+
./miri toolchain <commit> <flags>:
55+
Update and activate the rustup toolchain 'miri'. If no commit is given, updates
56+
to the commit given in the `rust-version` file. If the commit is `HEAD`, updates
57+
to the latest upstream rustc commit.
58+
`rustup-toolchain-install-master` must be installed for this to work. Any extra
59+
flags are passed to `rustup-toolchain-install-master`.
60+
5461
ENVIRONMENT VARIABLES
5562
5663
MIRI_SYSROOT:
@@ -75,6 +82,42 @@ JOSH_FILTER=":at_commit=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/too
7582

7683
## Early commands, that don't do auto-things and don't want the environment-altering things happening below.
7784
case "$COMMAND" in
85+
toolchain)
86+
cd "$MIRIDIR"
87+
# Make sure rustup-toolchain-install-master is installed.
88+
if ! which rustup-toolchain-install-master >/dev/null; then
89+
echo "Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'"
90+
exit 1
91+
fi
92+
# Determine new commit.
93+
if [[ "$1" == "" ]]; then
94+
NEW_COMMIT=$(cat rust-version)
95+
elif [[ "$1" == "HEAD" ]]; then
96+
NEW_COMMIT=$(git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1)
97+
else
98+
NEW_COMMIT="$1"
99+
fi
100+
echo "$NEW_COMMIT" > rust-version
101+
shift || true # don't fail if shifting fails because no commit was given
102+
# Check if we already are at that commit.
103+
CUR_COMMIT=$(rustc +miri --version -v 2>/dev/null | grep "^commit-hash: " | cut -d " " -f 2)
104+
if [[ "$CUR_COMMIT" == "$NEW_COMMIT" ]]; then
105+
echo "miri toolchain is already at commit $CUR_COMMIT."
106+
rustup override set miri
107+
exit 0
108+
fi
109+
# Install and setup new toolchain.
110+
rustup toolchain uninstall miri
111+
rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt -c clippy "$@" -- "$NEW_COMMIT"
112+
rustup override set miri
113+
# Cleanup.
114+
cargo clean
115+
# Call 'cargo metadata' on the sources in case that changes the lockfile
116+
# (which fails under some setups when it is done from inside vscode).
117+
cargo metadata --format-version 1 --manifest-path "$(rustc --print sysroot)/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml" >/dev/null
118+
# Done!
119+
exit 0
120+
;;
78121
rustc-pull)
79122
cd "$MIRIDIR"
80123
git fetch http://localhost:8000/rust-lang/rust.git$JOSH_FILTER.git master
@@ -145,7 +188,7 @@ if [ -z "$MIRI_AUTO_OPS" ]; then
145188
# Run this first, so that the toolchain doesn't change after
146189
# other code has run.
147190
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-toolchain" ] ; then
148-
(cd "$MIRIDIR" && ./rustup-toolchain)
191+
$0 toolchain
149192
fi
150193

151194
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-fmt" ] ; then

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
85d089b41e2a0c0f07ab34f6c5a7c451389f25e6
1+
607878d069267e1402ad792c9331b426e4c6d0f9

rustup-toolchain

-53
This file was deleted.

0 commit comments

Comments
 (0)