Skip to content

Commit ed72e77

Browse files
committed
Auto merge of rust-lang#2667 - RalfJung:josh, r=RalfJung
adjust josh pushing, remove './miri toolchain HEAD/commit' Looks like pushing works much better if we use as base commit the last commit we pulled from rustc and merged into Miri. Which I guess is fair. Conveniently, the `rust-version` file should usually be pretty much exactly that commit. Also adjust `rustc-pull` to update that file. Pulling is now the way to update to a newer rustc, so I also removed `./miri toolchain HEAD`.
2 parents f3e6dd7 + 439cd77 commit ed72e77

File tree

3 files changed

+39
-52
lines changed

3 files changed

+39
-52
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ jobs:
6767
shell: bash
6868
run: |
6969
if [[ ${{ github.event_name }} == 'schedule' ]]; then
70-
./miri toolchain HEAD --host ${{ matrix.host_target }}
71-
else
72-
./miri toolchain "" --host ${{ matrix.host_target }}
70+
echo "Building against latest rustc git version"
71+
git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1 > rust-version
7372
fi
73+
./miri toolchain --host ${{ matrix.host_target }}
7474
7575
- name: Show Rust version
7676
run: |

CONTRIBUTING.md

+3-19
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,6 @@ We described above the simplest way to get a working build environment for Miri,
209209
which is to use the version of rustc indicated by `rustc-version`. But
210210
sometimes, that is not enough.
211211

212-
### Updating `rustc-version`
213-
214-
The `rustc-version` file is regularly updated to keep Miri close to the latest
215-
version of rustc. Usually, new contributors do not have to worry about this. But
216-
sometimes a newer rustc is needed for a patch, and sometimes Miri needs fixing
217-
for changes in rustc. In both cases, `rustc-version` needs updating.
218-
219-
To update the `rustc-version` file and install the latest rustc, you can run:
220-
```
221-
./miri toolchain HEAD
222-
```
223-
224-
Now edit Miri until `./miri test` passes, and submit a PR. Generally, it is
225-
preferred to separate updating `rustc-version` and doing what it takes to get
226-
Miri working again, from implementing new features that rely on the updated
227-
rustc. This avoids blocking all Miri development on landing a big PR.
228-
229212
### Building Miri with a locally built rustc
230213

231214
[building Miri with a locally built rustc]: #building-miri-with-a-locally-built-rustc
@@ -299,9 +282,10 @@ We assume we start on an up-to-date master branch in the Miri repo.
299282

300283
```sh
301284
# Fetch and merge rustc side of the history. Takes ca 5 min the first time.
285+
# This will also update the 'rustc-version' file.
302286
./miri rustc-pull
303-
# Update toolchain reference and apply formatting.
304-
./miri toolchain HEAD && ./miri fmt
287+
# Update local toolchain and apply formatting.
288+
./miri toolchain && ./miri fmt
305289
git commit -am "rustup"
306290
```
307291

miri

+33-30
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ many different seeds.
4242
Runs 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 ' '
8686
case "$COMMAND" in
8787
toolchain)
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
;;
123114
rustc-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
;;
129130
rustc-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
;;
163166
many-seeds)

0 commit comments

Comments
 (0)