@@ -42,6 +42,15 @@ 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 rustc-pull:
46+ Pull and merge Miri changes from the rustc repo.
47+
48+ ./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+
4554 ENVIRONMENT VARIABLES
4655
4756MIRI_SYSROOT:
@@ -52,37 +61,60 @@ Pass extra flags to all cargo invocations. (Ignored by `./miri cargo`.)
5261EOF
5362)
5463
55- # # We need to know where we are.
64+ # # We need to know which command to run and some global constants.
65+ COMMAND=" $1 "
66+ if [ -z " $COMMAND " ]; then
67+ echo " $USAGE "
68+ exit 1
69+ fi
70+ shift
5671# macOS does not have a useful readlink/realpath so we have to use Python instead...
5772MIRIDIR=$( python3 -c ' import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' " $0 " )
73+ # Used for rustc syncs.
74+ JOSH_FILTER=" :at_commit=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri"
5875
59- # # Run the auto-things.
60- if [ -z " $MIRI_AUTO_OPS " ]; then
61- export MIRI_AUTO_OPS=42
62-
63- # Run this first, so that the toolchain doesn't change after
64- # other code has run.
65- if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-toolchain" ] ; then
66- (cd " $MIRIDIR " && ./rustup-toolchain)
76+ # # Early commands, that don't do auto-things and don't want the environment-altering things happening below.
77+ case " $COMMAND " in
78+ rustc-pull)
79+ cd " $MIRIDIR "
80+ git fetch http://localhost:8000/rust-lang/rust.git$JOSH_FILTER .git master
81+ git merge FETCH_HEAD
82+ exit 0
83+ ;;
84+ rustc-push)
85+ USER=" $1 "
86+ BRANCH=" $2 "
87+ if [ -z " $USER " ] || [ -z " $BRANCH " ]; then
88+ echo " Usage: $0 rustc-push <github user> <branch>"
89+ exit 1
6790 fi
68-
69- if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-fmt" ] ; then
70- $0 fmt
91+ if [ -n " $RUSTC_GIT " ]; then
92+ # Use an existing fork for the branch updates.
93+ cd " $RUSTC_GIT "
94+ else
95+ # Do this in the local Miri repo.
96+ echo " This will pull a copy of the rust-lang/rust history into this Miri checkout, growing it by about 1GB."
97+ read -r -p " To avoid that, abort now and set the RUSTC_GIT environment variable to an existing rustc checkout. Proceed? [y/N] "
98+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
99+ exit 1
100+ fi
101+ cd " $MIRIDIR "
71102 fi
72-
73- if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-clippy" ] ; then
74- $0 clippy -- -D warnings
103+ # Prepare the branches. For reliable pushing we need to push to a non-existent branch
104+ # and set `-o base` to a branch that holds current rustc master.
105+ echo " Preparing $USER /rust..."
106+ if git fetch https://github.com/$USER /rust $BRANCH & > /dev/null; then
107+ echo " The '$BRANCH ' seems to already exist in $USER /rust. Please delete it and try again."
108+ exit 1
75109 fi
76- fi
77-
78- # # Determine command and toolchain.
79- COMMAND=" $1 "
80- [ $# -gt 0 ] && shift
81- # Doing this *after* auto-toolchain logic above, since that might change the toolchain.
82- TOOLCHAIN=$( cd " $MIRIDIR " ; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
83-
84- # # Handle some commands early, since they should *not* alter the environment.
85- case " $COMMAND " in
110+ git fetch https://github.com/rust-lang/rust master
111+ git push https://github.com/$USER /rust FETCH_HEAD:master
112+ # Do the actual push.
113+ cd " $MIRIDIR "
114+ echo " Pushing Miri changes..."
115+ git push http://localhost:8000/$USER /rust.git$JOSH_FILTER .git HEAD:$BRANCH -o base=master
116+ exit 0
117+ ;;
86118many-seeds)
87119 for SEED in $( { echo obase=16; seq 0 255; } | bc) ; do
88120 echo " Trying seed: $SEED "
@@ -106,9 +138,28 @@ bench)
106138 ;;
107139esac
108140
141+ # # Run the auto-things.
142+ if [ -z " $MIRI_AUTO_OPS " ]; then
143+ export MIRI_AUTO_OPS=42
144+
145+ # Run this first, so that the toolchain doesn't change after
146+ # other code has run.
147+ if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-toolchain" ] ; then
148+ (cd " $MIRIDIR " && ./rustup-toolchain)
149+ fi
150+
151+ if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-fmt" ] ; then
152+ $0 fmt
153+ fi
154+
155+ if [ -f " $MIRIDIR /.auto-everything" ] || [ -f " $MIRIDIR /.auto-clippy" ] ; then
156+ $0 clippy -- -D warnings
157+ fi
158+ fi
159+
109160# # Prepare the environment
110161# Determine some toolchain properties
111- # export the target so its available in miri
162+ TOOLCHAIN= $( cd " $MIRIDIR " ; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1 )
112163TARGET=$( rustc +$TOOLCHAIN --version --verbose | grep " ^host:" | cut -d ' ' -f 2)
113164SYSROOT=$( rustc +$TOOLCHAIN --print sysroot)
114165LIBDIR=$SYSROOT /lib/rustlib/$TARGET /lib
@@ -227,10 +278,7 @@ cargo)
227278 $CARGO " $@ "
228279 ;;
229280* )
230- if [ -n " $COMMAND " ]; then
231- echo " Unknown command: $COMMAND "
232- echo
233- fi
234- echo " $USAGE "
281+ echo " Unknown command: $COMMAND "
235282 exit 1
283+ ;;
236284esac
0 commit comments