Skip to content

Commit 174aef4

Browse files
committed
Auto merge of rust-lang#104293 - Manishearth:rollup-xj92d0k, r=Manishearth
Rollup of 8 pull requests Successful merges: - rust-lang#95292 (Allow specialized const trait impls.) - rust-lang#100386 (Make `Sized` coinductive, again) - rust-lang#102215 (Implement the `+whole-archive` modifier for `wasm-ld`) - rust-lang#103468 (Fix unused lint and parser caring about spaces to won't produce invalid code) - rust-lang#103531 (Suggest calling the instance method of the same name when method not found) - rust-lang#103960 (piece of diagnostic migrate) - rust-lang#104051 (update Miri) - rust-lang#104129 (rustdoc: use javascript to layout notable traits popups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e73e55b + 5227295 commit 174aef4

33 files changed

+831
-218
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ jobs:
6767
shell: bash
6868
run: |
6969
if [[ ${{ github.event_name }} == 'schedule' ]]; then
70-
./rustup-toolchain HEAD --host ${{ matrix.host_target }}
70+
./miri toolchain HEAD --host ${{ matrix.host_target }}
7171
else
72-
./rustup-toolchain "" --host ${{ matrix.host_target }}
72+
./miri toolchain "" --host ${{ matrix.host_target }}
7373
fi
7474
7575
- name: Show Rust version
@@ -118,7 +118,7 @@ jobs:
118118
- name: Install "master" toolchain
119119
shell: bash
120120
run: |
121-
./rustup-toolchain "" -c clippy
121+
./miri toolchain
122122
123123
- name: Show Rust version
124124
run: |

.gitpod.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ tasks:
44
- before: echo "..."
55
init: |
66
cargo install rustup-toolchain-install-master
7-
./rustup-toolchain
7+
./miri toolchain
88
./miri build
9-
command: echo "Run tests with ./miri test"
9+
command: echo "Run tests with ./miri test"

CONTRIBUTING.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ tested against. Other versions will likely not work. After installing
2323
[`rustup-toolchain-install-master`], you can run the following command to
2424
install that exact version of rustc as a toolchain:
2525
```
26-
./rustup-toolchain
26+
./miri toolchain
2727
```
2828
This will set up a rustup toolchain called `miri` and set it as an override for
2929
the current directory.
3030

3131
You can also create a `.auto-everything` file (contents don't matter, can be empty), which
32-
will cause any `./miri` command to automatically call `rustup-toolchain`, `clippy` and `rustfmt`
32+
will cause any `./miri` command to automatically call `./miri toolchain`, `clippy` and `rustfmt`
3333
for you. If you don't want all of these to happen, you can add individual `.auto-toolchain`,
3434
`.auto-clippy` and `.auto-fmt` files respectively.
3535

@@ -132,12 +132,15 @@ development version of Miri using
132132
and then you can use it as if it was installed by `rustup`. Make sure you use
133133
the same toolchain when calling `cargo miri` that you used when installing Miri!
134134
Usually this means you have to write `cargo +miri miri ...` to select the `miri`
135-
toolchain that was installed by `./rustup-toolchain`.
135+
toolchain that was installed by `./miri toolchain`.
136136

137137
There's a test for the cargo wrapper in the `test-cargo-miri` directory; run
138138
`./run-test.py` in there to execute it. Like `./miri test`, this respects the
139139
`MIRI_TEST_TARGET` environment variable to execute the test for another target.
140140

141+
Note that installing Miri like this will "take away" Miri management from `rustup`.
142+
If you want to later go back to a rustup-installed Miri, run `rustup update`.
143+
141144
### Using a modified standard library
142145

143146
Miri re-builds the standard library into a custom sysroot, so it is fairly easy
@@ -214,7 +217,7 @@ for changes in rustc. In both cases, `rustc-version` needs updating.
214217

215218
To update the `rustc-version` file and install the latest rustc, you can run:
216219
```
217-
./rustup-toolchain HEAD
220+
./miri toolchain HEAD
218221
```
219222

220223
Now edit Miri until `./miri test` passes, and submit a PR. Generally, it is
@@ -290,16 +293,14 @@ cargo run --release -p josh-proxy -- --local=$(pwd)/local --remote=https://githu
290293

291294
### Importing changes from the rustc repo
292295

296+
Josh needs to be running, as described above.
293297
We assume we start on an up-to-date master branch in the Miri repo.
294298

295299
```sh
296-
# Fetch rustc side of the history. Takes ca 5 min the first time.
297-
# Do NOT change that commit ID, it needs to be exactly this!
298-
git fetch http://localhost:8000/rust-lang/rust.git:at_commit=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri.git master
299-
# Include that history into ours.
300-
git merge FETCH_HEAD -m "merge rustc history"
300+
# Fetch and merge rustc side of the history. Takes ca 5 min the first time.
301+
./miri rustc-pull
301302
# Update toolchain reference and apply formatting.
302-
./rustup-toolchain HEAD && ./miri fmt
303+
./miri toolchain HEAD && ./miri fmt
303304
git commit -am "rustup"
304305
```
305306

@@ -310,16 +311,15 @@ needed.
310311

311312
### Exporting changes to the rustc repo
312313

313-
We will use the josh proxy to push to your fork of rustc. You need to make sure
314-
that the master branch of your fork is up-to-date. Also make sure that there
315-
exists no branch called `miri` in your fork. Then run the following in the Miri
316-
repo, assuming we are on an up-to-date master branch:
314+
Josh needs to be running, as described above. We will use the josh proxy to push
315+
to your fork of rustc. Run the following in the Miri repo, assuming we are on an
316+
up-to-date master branch:
317317

318318
```sh
319319
# Push the Miri changes to your rustc fork (substitute your github handle for YOUR_NAME).
320-
# Do NOT change that commit ID, it needs to be exactly this!
321-
git push http://localhost:8000/YOUR_NAME/rust.git:at_commit=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri.git -o base=master HEAD:miri
320+
./miri rustc-push YOUR_NAME miri
322321
```
323322

324-
This will create a new branch in your fork, and the output should include a link
325-
to create a rustc PR that will integrate those changes into the main repository.
323+
This will create a new branch called 'miri' in your fork, and the output should
324+
include a link to create a rustc PR that will integrate those changes into the
325+
main repository.

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,15 @@ to Miri failing to detect cases of undefined behavior in a program.
374374
application instead of raising an error within the context of Miri (and halting
375375
execution). Note that code might not expect these operations to ever panic, so
376376
this flag can lead to strange (mis)behavior.
377-
* `-Zmiri-retag-fields` changes Stacked Borrows retagging to recurse into fields.
377+
* `-Zmiri-retag-fields` changes Stacked Borrows retagging to recurse into *all* fields.
378378
This means that references in fields of structs/enums/tuples/arrays/... are retagged,
379379
and in particular, they are protected when passed as function arguments.
380+
(The default is to recurse only in cases where rustc would actually emit a `noalias` attribute.)
380381
* `-Zmiri-retag-fields=<all|none|scalar>` controls when Stacked Borrows retagging recurses into
381382
fields. `all` means it always recurses (like `-Zmiri-retag-fields`), `none` means it never
382-
recurses (the default), `scalar` means it only recurses for types where we would also emit
383+
recurses, `scalar` (the default) means it only recurses for types where we would also emit
383384
`noalias` annotations in the generated LLVM IR (types passed as indivudal scalars or pairs of
384-
scalars).
385+
scalars). Setting this to `none` is **unsound**.
385386
* `-Zmiri-tag-gc=<blocks>` configures how often the pointer tag garbage collector runs. The default
386387
is to search for and remove unreachable tags once every `10000` basic blocks. Setting this to
387388
`0` disables the garbage collector, which causes some programs to have explosive memory usage
@@ -419,9 +420,9 @@ Some native rustc `-Z` flags are also very relevant for Miri:
419420

420421
Moreover, Miri recognizes some environment variables:
421422

422-
* `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and rustup-toolchain
423-
should be skipped. If it is set to any value, they are skipped. This is used for avoiding
424-
infinite recursion in `./miri` and to allow automated IDE actions to avoid the auto ops.
423+
* `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and toolchain setup
424+
should be skipped. If it is set to any value, they are skipped. This is used for avoiding infinite
425+
recursion in `./miri` and to allow automated IDE actions to avoid the auto ops.
425426
* `MIRI_LOG`, `MIRI_BACKTRACE` control logging and backtrace printing during
426427
Miri executions, also [see "Testing the Miri driver" in `CONTRIBUTING.md`][testing-miri].
427428
* `MIRIFLAGS` (recognized by `cargo miri` and the test suite) defines extra

cargo-miri/src/phases.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
528528
cmd.args(binary_args);
529529

530530
// Make sure we use the build-time working directory for interpreting Miri/rustc arguments.
531-
// But then we need to switch to the run-time one, which we instruct Miri do do by setting `MIRI_CWD`.
531+
// But then we need to switch to the run-time one, which we instruct Miri to do by setting `MIRI_CWD`.
532532
cmd.current_dir(info.current_dir);
533533
cmd.env("MIRI_CWD", env::current_dir().unwrap());
534534

miri

+125-31
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ 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 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+
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`.
60+
4561
ENVIRONMENT VARIABLES
4662
4763
MIRI_SYSROOT:
@@ -52,37 +68,98 @@ Pass extra flags to all cargo invocations. (Ignored by `./miri cargo`.)
5268
EOF
5369
)
5470

55-
## We need to know where we are.
71+
## We need to know which command to run and some global constants.
72+
COMMAND="$1"
73+
if [ -z "$COMMAND" ]; then
74+
echo "$USAGE"
75+
exit 1
76+
fi
77+
shift
5678
# macOS does not have a useful readlink/realpath so we have to use Python instead...
5779
MIRIDIR=$(python3 -c 'import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' "$0")
80+
# Used for rustc syncs.
81+
JOSH_FILTER=":at_commit=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri"
82+
# Needed for `./miri bench`.
83+
TOOLCHAIN=$(cd "$MIRIDIR"; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
5884

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)
85+
## Early commands, that don't do auto-things and don't want the environment-altering things happening below.
86+
case "$COMMAND" in
87+
toolchain)
88+
cd "$MIRIDIR"
89+
# Make sure rustup-toolchain-install-master is installed.
90+
if ! which rustup-toolchain-install-master >/dev/null; then
91+
echo "Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'"
92+
exit 1
6793
fi
68-
69-
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-fmt" ] ; then
70-
$0 fmt
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"
71101
fi
72-
73-
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-clippy" ] ; then
74-
$0 clippy -- -D warnings
102+
echo "$NEW_COMMIT" > rust-version
103+
shift || true # don't fail if shifting fails because no commit was given
104+
# Check if we already are at that commit.
105+
CUR_COMMIT=$(rustc +miri --version -v 2>/dev/null | grep "^commit-hash: " | cut -d " " -f 2)
106+
if [[ "$CUR_COMMIT" == "$NEW_COMMIT" ]]; then
107+
echo "miri toolchain is already at commit $CUR_COMMIT."
108+
rustup override set miri
109+
exit 0
75110
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
111+
# Install and setup new toolchain.
112+
rustup toolchain uninstall miri
113+
rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt -c clippy "$@" -- "$NEW_COMMIT"
114+
rustup override set miri
115+
# Cleanup.
116+
cargo clean
117+
# Call 'cargo metadata' on the sources in case that changes the lockfile
118+
# (which fails under some setups when it is done from inside vscode).
119+
cargo metadata --format-version 1 --manifest-path "$(rustc --print sysroot)/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml" >/dev/null
120+
# Done!
121+
exit 0
122+
;;
123+
rustc-pull)
124+
cd "$MIRIDIR"
125+
git fetch http://localhost:8000/rust-lang/rust.git$JOSH_FILTER.git master
126+
git merge FETCH_HEAD --no-ff -m "Merge from rustc"
127+
exit 0
128+
;;
129+
rustc-push)
130+
USER="$1"
131+
BRANCH="$2"
132+
if [ -z "$USER" ] || [ -z "$BRANCH" ]; then
133+
echo "Usage: $0 rustc-push <github user> <branch>"
134+
exit 1
135+
fi
136+
if [ -n "$RUSTC_GIT" ]; then
137+
# Use an existing fork for the branch updates.
138+
cd "$RUSTC_GIT"
139+
else
140+
# Do this in the local Miri repo.
141+
echo "This will pull a copy of the rust-lang/rust history into this Miri checkout, growing it by about 1GB."
142+
read -r -p "To avoid that, abort now and set the RUSTC_GIT environment variable to an existing rustc checkout. Proceed? [y/N] "
143+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
144+
exit 1
145+
fi
146+
cd "$MIRIDIR"
147+
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' seems to already exist in $USER/rust. Please delete it and try again."
153+
exit 1
154+
fi
155+
git fetch https://github.com/rust-lang/rust master
156+
git push https://github.com/$USER/rust FETCH_HEAD:master
157+
# Do the actual push.
158+
cd "$MIRIDIR"
159+
echo "Pushing Miri changes..."
160+
git push http://localhost:8000/$USER/rust.git$JOSH_FILTER.git HEAD:$BRANCH -o base=master
161+
exit 0
162+
;;
86163
many-seeds)
87164
for SEED in $({ echo obase=16; seq 0 255; } | bc); do
88165
echo "Trying seed: $SEED"
@@ -106,9 +183,29 @@ bench)
106183
;;
107184
esac
108185

186+
## Run the auto-things.
187+
if [ -z "$MIRI_AUTO_OPS" ]; then
188+
export MIRI_AUTO_OPS=42
189+
190+
# Run this first, so that the toolchain doesn't change after
191+
# other code has run.
192+
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-toolchain" ] ; then
193+
$0 toolchain
194+
# Let's make sure to actually use that toolchain, too.
195+
TOOLCHAIN=miri
196+
fi
197+
198+
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-fmt" ] ; then
199+
$0 fmt
200+
fi
201+
202+
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-clippy" ] ; then
203+
$0 clippy -- -D warnings
204+
fi
205+
fi
206+
109207
## Prepare the environment
110208
# Determine some toolchain properties
111-
# export the target so its available in miri
112209
TARGET=$(rustc +$TOOLCHAIN --version --verbose | grep "^host:" | cut -d ' ' -f 2)
113210
SYSROOT=$(rustc +$TOOLCHAIN --print sysroot)
114211
LIBDIR=$SYSROOT/lib/rustlib/$TARGET/lib
@@ -227,10 +324,7 @@ cargo)
227324
$CARGO "$@"
228325
;;
229326
*)
230-
if [ -n "$COMMAND" ]; then
231-
echo "Unknown command: $COMMAND"
232-
echo
233-
fi
234-
echo "$USAGE"
327+
echo "Unknown command: $COMMAND"
235328
exit 1
329+
;;
236330
esac

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
85d089b41e2a0c0f07ab34f6c5a7c451389f25e6
1+
b03502b35d111bef0399a66ab3cc765f0802e8ba

0 commit comments

Comments
 (0)