@@ -51,6 +51,13 @@ in the Rust fork of the given user to upstream. It will also pull a copy of the
51
51
rustc history into the Miri repo, unless you set the RUSTC_GIT env var to an
52
52
existing clone of the rustc repo.
53
53
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
+
54
61
ENVIRONMENT VARIABLES
55
62
56
63
MIRI_SYSROOT:
@@ -75,6 +82,42 @@ JOSH_FILTER=":at_commit=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/too
75
82
76
83
# # Early commands, that don't do auto-things and don't want the environment-altering things happening below.
77
84
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
+ ;;
78
121
rustc-pull)
79
122
cd " $MIRIDIR "
80
123
git fetch http://localhost:8000/rust-lang/rust.git$JOSH_FILTER .git master
@@ -145,7 +188,7 @@ if [ -z "$MIRI_AUTO_OPS" ]; then
145
188
# Run this first, so that the toolchain doesn't change after
146
189
# other code has run.
147
190
if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-toolchain" ] ; then
148
- (cd " $MIRIDIR " && ./rustup- toolchain)
191
+ $0 toolchain
149
192
fi
150
193
151
194
if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-fmt" ] ; then
0 commit comments