3 # Manages a rustup toolchain called "miri".
5 # All commands set "miri" as the override toolchain for the current directory,
6 # and make the `rust-version` file match that toolchain.
10 # ./rustup-toolchain: Update "miri" toolchain to match `rust-version` (the known-good version for this commit).
12 # ./rustup-toolchain HEAD: Update "miri" toolchain and `rust-version` file to latest rustc HEAD.
14 # ./rustup-toolchain $COMMIT: Update "miri" toolchain and `rust-version` file to match that commit.
16 # Make sure rustup-toolchain-install-master is installed.
17 if ! which rustup-toolchain-install-master >/dev/null; then
18 echo "Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'"
22 # Determine new commit.
23 if [[ "$1" == "" ]]; then
24 NEW_COMMIT=$(cat rust-version)
25 elif [[ "$1" == "HEAD" ]]; then
26 NEW_COMMIT=$(git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1)
30 echo "$NEW_COMMIT" > rust-version
32 # Check if we already are at that commit.
33 CUR_COMMIT=$(rustc +miri --version -v 2>/dev/null | egrep "^commit-hash: " | cut -d " " -f 2)
34 if [[ "$CUR_COMMIT" == "$NEW_COMMIT" ]]; then
35 echo "miri toolchain is already at commit $CUR_COMMIT."
36 rustup override set miri
40 # Install and setup new toolchain.
41 rustup toolchain uninstall miri
42 rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -- "$NEW_COMMIT"
43 rustup override set miri