@@ -42,21 +42,21 @@ many different seeds.
4242Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed.
4343<benches> can explicitly list the benchmarks to run; by default, all of them are run.
4444
45+ ./miri toolchain <flags>:
46+ Update and activate the rustup toolchain 'miri' to the commit given in the
47+ `rust-version` file.
48+ `rustup-toolchain-install-master` must be installed for this to work. Any extra
49+ flags are passed to `rustup-toolchain-install-master`.
50+
4551./miri rustc-pull:
46- Pull and merge Miri changes from the rustc repo.
52+ Pull and merge Miri changes from the rustc repo. The fetched commit is stored in
53+ the `rust-version` file, so the next `./miri toolchain` will install the rustc
54+ we just pulled.
4755
4856./miri rustc-push <github user> <branch>:
49- Push Miri changes back to the rustc repo. This will update the 'master' branch
50- in the Rust fork of the given user to upstream. It will also pull a copy of the
51- rustc history into the Miri repo, unless you set the RUSTC_GIT env var to an
52- existing clone of the rustc repo.
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`.
57+ Push Miri changes back to the rustc repo. This will pull a copy of the rustc
58+ history into the Miri repo, unless you set the RUSTC_GIT env var to an existing
59+ clone of the rustc repo.
6060
6161 ENVIRONMENT VARIABLES
6262
@@ -86,21 +86,12 @@ TOOLCHAIN=$(cd "$MIRIDIR"; rustup show active-toolchain | head -n 1 | cut -d ' '
8686case " $COMMAND " in
8787toolchain)
8888 cd " $MIRIDIR "
89+ NEW_COMMIT=$( cat rust-version)
8990 # Make sure rustup-toolchain-install-master is installed.
9091 if ! which rustup-toolchain-install-master > /dev/null; then
9192 echo " Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'"
9293 exit 1
9394 fi
94- # Determine new commit.
95- if [[ " $1 " == " " ]]; then
96- NEW_COMMIT=$( cat rust-version)
97- elif [[ " $1 " == " HEAD" ]]; then
98- NEW_COMMIT=$( git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1)
99- else
100- NEW_COMMIT=" $1 "
101- fi
102- echo " $NEW_COMMIT " > rust-version
103- shift || true # don't fail if shifting fails because no commit was given
10495 # Check if we already are at that commit.
10596 CUR_COMMIT=$( rustc +miri --version -v 2> /dev/null | grep " ^commit-hash: " | cut -d " " -f 2)
10697 if [[ " $CUR_COMMIT " == " $NEW_COMMIT " ]]; then
@@ -122,8 +113,18 @@ toolchain)
122113 ;;
123114rustc-pull)
124115 cd " $MIRIDIR "
116+ FETCH_COMMIT=$( git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1)
117+ # We can't pull from a commit with josh
118+ # (https://github.com/josh-project/josh/issues/1034), so we just hope that
119+ # nothing gets merged into rustc *during* this pull.
125120 git fetch http://localhost:8000/rust-lang/rust.git$JOSH_FILTER .git master
121+ # Just verify that `master` didn't move.
122+ if [[ $FETCH_COMMIT != $( git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1) ]]; then
123+ echo " Looks like something got merged into Rust *while we were pulling*. Aborting. Please try again."
124+ fi
125+ echo " $FETCH_COMMIT " > rust-version # do this *before* merging as merging will fail in case of conflicts
126126 git merge FETCH_HEAD --no-ff -m " Merge from rustc"
127+ git commit rust-version --amend -m " Merge from rustc"
127128 exit 0
128129 ;;
129130rustc-push)
@@ -145,19 +146,21 @@ rustc-push)
145146 fi
146147 cd " $MIRIDIR "
147148 fi
148- # Prepare the branches. For reliable pushing we need to push to a non-existent branch
149- # and set `-o base` to a branch that holds current rustc master.
150- echo " Preparing $USER /rust..."
151- if git fetch https://github.com/$USER /rust $BRANCH & > /dev/null; then
152- echo " The branch '$BRANCH ' seems to already exist in $USER /rust. Please delete it and try again."
149+ # Prepare the branch. Pushing works much better if we use as base exactly
150+ # the commit that we pulled from last time, so we use the `rust-version`
151+ # file as a good approximation of that.
152+ BASE=$( cat " $MIRIDIR /rust-version" )
153+ echo " Preparing $USER /rust (base: $BASE )..."
154+ if git fetch " https://github.com/$USER /rust" " $BRANCH " & > /dev/null; then
155+ echo " The branch '$BRANCH ' seems to already exist in 'https://github.com/$USER /rust'. Please delete it and try again."
153156 exit 1
154157 fi
155- git fetch https://github.com/rust-lang/rust master
156- git push https://github.com/$USER /rust FETCH_HEAD:master
158+ git fetch https://github.com/rust-lang/rust $BASE
159+ git push https://github.com/$USER /rust $BASE :refs/heads/ $BRANCH -f
157160 # Do the actual push.
158161 cd " $MIRIDIR "
159162 echo " Pushing Miri changes..."
160- git push http://localhost:8000/$USER /rust.git$JOSH_FILTER .git HEAD:$BRANCH -o base=master
163+ git push http://localhost:8000/$USER /rust.git$JOSH_FILTER .git HEAD:$BRANCH
161164 exit 0
162165 ;;
163166many-seeds)
0 commit comments