X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fmiri%2Fmiri;h=b09897c294cd17f3bf539b6a74420510f44e3d18;hb=43fa2918d1e4dfd90f83ce46aac8373ae8120068;hp=f0986bfb1cdbe847216bff42cd684ee19924c745;hpb=dedfb9c2140dcc770054b1515d6099e42d35004d;p=rust.git diff --git a/src/tools/miri/miri b/src/tools/miri/miri index f0986bfb1cd..b09897c294c 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -42,21 +42,21 @@ many different seeds. Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed. can explicitly list the benchmarks to run; by default, all of them are run. +./miri toolchain : +Update and activate the rustup toolchain 'miri' to the commit given in the +`rust-version` file. +`rustup-toolchain-install-master` must be installed for this to work. Any extra +flags are passed to `rustup-toolchain-install-master`. + ./miri rustc-pull: -Pull and merge Miri changes from the rustc repo. +Pull and merge Miri changes from the rustc repo. The fetched commit is stored in +the `rust-version` file, so the next `./miri toolchain` will install the rustc +we just pulled. ./miri rustc-push : -Push Miri changes back to the rustc repo. This will update the 'master' branch -in the Rust fork of the given user to upstream. It will also pull a copy of the -rustc history into the Miri repo, unless you set the RUSTC_GIT env var to an -existing clone of the rustc repo. - -./miri toolchain : -Update and activate the rustup toolchain 'miri'. If no commit is given, updates -to the commit given in the `rust-version` file. If the commit is `HEAD`, updates -to the latest upstream rustc commit. -`rustup-toolchain-install-master` must be installed for this to work. Any extra -flags are passed to `rustup-toolchain-install-master`. +Push Miri changes back to the rustc repo. This will pull a copy of the rustc +history into the Miri repo, unless you set the RUSTC_GIT env var to an existing +clone of the rustc repo. ENVIRONMENT VARIABLES @@ -78,7 +78,7 @@ shift # macOS does not have a useful readlink/realpath so we have to use Python instead... MIRIDIR=$(python3 -c 'import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' "$0") # Used for rustc syncs. -JOSH_FILTER=":at_commit=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri" +JOSH_FILTER=":rev(75dd959a3a40eb5b4574f8d2e23aa6efbeb33573:prefix=src/tools/miri):/src/tools/miri" # Needed for `./miri bench`. TOOLCHAIN=$(cd "$MIRIDIR"; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1) @@ -86,21 +86,12 @@ TOOLCHAIN=$(cd "$MIRIDIR"; rustup show active-toolchain | head -n 1 | cut -d ' ' case "$COMMAND" in toolchain) cd "$MIRIDIR" + NEW_COMMIT=$(cat rust-version) # Make sure rustup-toolchain-install-master is installed. if ! which rustup-toolchain-install-master >/dev/null; then echo "Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'" exit 1 fi - # Determine new commit. - if [[ "$1" == "" ]]; then - NEW_COMMIT=$(cat rust-version) - elif [[ "$1" == "HEAD" ]]; then - NEW_COMMIT=$(git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1) - else - NEW_COMMIT="$1" - fi - echo "$NEW_COMMIT" > rust-version - shift || true # don't fail if shifting fails because no commit was given # Check if we already are at that commit. CUR_COMMIT=$(rustc +miri --version -v 2>/dev/null | grep "^commit-hash: " | cut -d " " -f 2) if [[ "$CUR_COMMIT" == "$NEW_COMMIT" ]]; then @@ -122,8 +113,18 @@ toolchain) ;; rustc-pull) cd "$MIRIDIR" + FETCH_COMMIT=$(git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1) + # We can't pull from a commit with josh + # (https://github.com/josh-project/josh/issues/1034), so we just hope that + # nothing gets merged into rustc *during* this pull. git fetch http://localhost:8000/rust-lang/rust.git$JOSH_FILTER.git master + # Just verify that `master` didn't move. + if [[ $FETCH_COMMIT != $(git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1) ]]; then + echo "Looks like something got merged into Rust *while we were pulling*. Aborting. Please try again." + fi + echo "$FETCH_COMMIT" > rust-version # do this *before* merging as merging will fail in case of conflicts git merge FETCH_HEAD --no-ff -m "Merge from rustc" + git commit rust-version --amend -m "Merge from rustc" exit 0 ;; rustc-push) @@ -145,19 +146,21 @@ rustc-push) fi cd "$MIRIDIR" fi - # Prepare the branches. For reliable pushing we need to push to a non-existent branch - # and set `-o base` to a branch that holds current rustc master. - echo "Preparing $USER/rust..." - if git fetch https://github.com/$USER/rust $BRANCH &>/dev/null; then - echo "The '$BRANCH' seems to already exist in $USER/rust. Please delete it and try again." + # Prepare the branch. Pushing works much better if we use as base exactly + # the commit that we pulled from last time, so we use the `rust-version` + # file as a good approximation of that. + BASE=$(cat "$MIRIDIR/rust-version") + echo "Preparing $USER/rust (base: $BASE)..." + if git fetch "https://github.com/$USER/rust" "$BRANCH" &>/dev/null; then + echo "The branch '$BRANCH' seems to already exist in 'https://github.com/$USER/rust'. Please delete it and try again." exit 1 fi - git fetch https://github.com/rust-lang/rust master - git push https://github.com/$USER/rust FETCH_HEAD:master + git fetch https://github.com/rust-lang/rust $BASE + git push https://github.com/$USER/rust $BASE:refs/heads/$BRANCH -f # Do the actual push. cd "$MIRIDIR" echo "Pushing Miri changes..." - git push http://localhost:8000/$USER/rust.git$JOSH_FILTER.git HEAD:$BRANCH -o base=master + git push http://localhost:8000/$USER/rust.git$JOSH_FILTER.git HEAD:$BRANCH exit 0 ;; many-seeds)