Skip to content

Commit f04f6ca

Browse files
committed
Auto merge of rust-lang#129230 - RalfJung:miri-sync, r=RalfJung
Miri subtree update r? `@ghost`
2 parents 334e509 + 0708b28 commit f04f6ca

File tree

91 files changed

+2536
-1045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2536
-1045
lines changed

src/tools/miri/.cargo/config.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[unstable]
2+
profile-rustflags = true
3+
4+
# Add back the containing directory of the packages we have to refer to using --manifest-path.
5+
# Per-package profiles avoid adding this to build dependencies.
6+
[profile.dev.package."cargo-miri"]
7+
rustflags = ["--remap-path-prefix", "=cargo-miri"]
8+
[profile.dev.package."miri-script"]
9+
rustflags = ["--remap-path-prefix", "=miri-script"]

src/tools/miri/.github/workflows/ci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: clippy (all features)
6161
run: ./miri clippy --all-features -- -D warnings
6262
- name: rustdoc
63-
run: RUSTDOCFLAGS="-Dwarnings" ./miri cargo doc --document-private-items
63+
run: RUSTDOCFLAGS="-Dwarnings" ./miri doc --document-private-items
6464

6565
# These jobs doesn't actually test anything, but they're only used to tell
6666
# bors the build completed, as there is no practical way to detect when a
@@ -123,6 +123,8 @@ jobs:
123123
run: |
124124
git config --global user.name 'The Miri Cronjob Bot'
125125
git config --global user.email 'miri@cron.bot'
126+
- name: Install nightly toolchain
127+
run: rustup toolchain install nightly --profile minimal
126128
- name: get changes from rustc
127129
run: ./miri rustc-pull
128130
- name: Install rustup-toolchain-install-master

src/tools/miri/.github/workflows/setup/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ runs:
3535
run: cargo install -f rustup-toolchain-install-master hyperfine
3636
shell: bash
3737

38+
- name: Install nightly toolchain
39+
run: rustup toolchain install nightly --profile minimal
40+
shell: bash
41+
3842
- name: Install "master" toolchain
3943
run: |
4044
if [[ ${{ github.event_name }} == 'schedule' ]]; then

src/tools/miri/CONTRIBUTING.md

+39-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,43 @@ find useful.
88
Check out the issues on this GitHub repository for some ideas. In particular,
99
look for the green `E-*` labels which mark issues that should be rather
1010
well-suited for onboarding. For more ideas or help with hacking on Miri, you can
11-
contact us (`oli-obk` and `RalfJ`) on the [Rust Zulip].
11+
contact us on the [Rust Zulip]. See the [Rust website](https://www.rust-lang.org/governance/teams/compiler#team-miri)
12+
for a list of Miri maintainers.
1213

1314
[Rust Zulip]: https://rust-lang.zulipchat.com
1415

16+
### Larger-scale contributions
17+
18+
If you are thinking about making a larger-scale contribution -- in particular anything that needs
19+
more than can reasonably fit in a single PR to be feature-complete -- then please talk to us before
20+
writing significant amounts of code. Generally, we will ask that you follow a three-step "project"
21+
process for such contributions:
22+
23+
1. Clearly define the **goal** of the project. This defines the scope of the project, i.e. which
24+
part of which APIs should be supported. If this involves functions that expose a big API surface
25+
with lots of flags, the project may want to support only a tiny subset of flags; that should be
26+
documented. A good way to express the goal is with one or more test cases that Miri should be
27+
able to successfully execute when the project is completed. It is a good idea to get feedback
28+
from team members already at this stage to ensure that the project is reasonably scoped and
29+
aligns with our interests.
30+
2. Make a **design** for how to realize the goal. A larger project will likely have to do global
31+
changes to Miri, like adding new global state to the `Machine` type or new methods to the
32+
`FileDescription` trait. Often we have to iterate on those changes, which can quite substantially
33+
change how the final implementation looks like.
34+
35+
The design should be reasonably concrete, i.e. for new global state or methods the corresponding
36+
Rust types and method signatures should be spelled out. We realize that it can be hard to make a
37+
design without doing implementation work, in particular if you are not yet familiar with the
38+
codebase. Doing draft implementations in phase 2 of this process is perfectly fine, just please
39+
be aware that we might request fundamental changes that can require significantly reworking what
40+
you already did. If you open a PR in this stage, please clearly indicate that this project is
41+
still in the design stage.
42+
43+
3. Finish the **implementation** and have it reviewed.
44+
45+
This process is largely informal, and its primary goal is to more clearly communicate expectations.
46+
Please get in touch with us if you have any questions!
47+
1548
## Preparing the build environment
1649

1750
Miri heavily relies on internal and unstable rustc interfaces to execute MIR,
@@ -173,24 +206,24 @@ to `.vscode/settings.json` in your local Miri clone:
173206
"cargo-miri/Cargo.toml",
174207
"miri-script/Cargo.toml",
175208
],
209+
"rust-analyzer.check.invocationLocation": "root",
210+
"rust-analyzer.check.invocationStrategy": "once",
176211
"rust-analyzer.check.overrideCommand": [
177212
"env",
178213
"MIRI_AUTO_OPS=no",
179214
"./miri",
180-
"cargo",
181215
"clippy", // make this `check` when working with a locally built rustc
182216
"--message-format=json",
183-
"--all-targets",
184217
],
185218
// Contrary to what the name suggests, this also affects proc macros.
219+
"rust-analyzer.cargo.buildScripts.invocationLocation": "root",
220+
"rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
186221
"rust-analyzer.cargo.buildScripts.overrideCommand": [
187222
"env",
188223
"MIRI_AUTO_OPS=no",
189224
"./miri",
190-
"cargo",
191225
"check",
192226
"--message-format=json",
193-
"--all-targets",
194227
],
195228
}
196229
```
@@ -309,6 +342,7 @@ anyone but Miri itself. They are used to communicate between different Miri
309342
binaries, and as such worth documenting:
310343

311344
* `CARGO_EXTRA_FLAGS` is understood by `./miri` and passed to all host cargo invocations.
345+
It is reserved for CI usage; setting the wrong flags this way can easily confuse the script.
312346
* `MIRI_BE_RUSTC` can be set to `host` or `target`. It tells the Miri driver to
313347
actually not interpret the code but compile it like rustc would. With `target`, Miri sets
314348
some compiler flags to prepare the code for interpretation; with `host`, this is not done.

src/tools/miri/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,6 @@ to Miri failing to detect cases of undefined behavior in a program.
414414
being allocated or freed. This helps in debugging memory leaks and
415415
use after free bugs. Specifying this argument multiple times does not overwrite the previous
416416
values, instead it appends its values to the list. Listing an id multiple times has no effect.
417-
* `-Zmiri-track-call-id=<id1>,<id2>,...` shows a backtrace when the given call ids are
418-
assigned to a stack frame. This helps in debugging UB related to Stacked
419-
Borrows "protectors". Specifying this argument multiple times does not overwrite the previous
420-
values, instead it appends its values to the list. Listing an id multiple times has no effect.
421417
* `-Zmiri-track-pointer-tag=<tag1>,<tag2>,...` shows a backtrace when a given pointer tag
422418
is created and when (if ever) it is popped from a borrow stack (which is where the tag becomes invalid
423419
and any future use of it will error). This helps you in finding out why UB is

src/tools/miri/cargo-miri/miri

-4
This file was deleted.

src/tools/miri/cargo-miri/src/util.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,9 @@ pub fn find_miri() -> PathBuf {
9393
if let Some(path) = env::var_os("MIRI") {
9494
return path.into();
9595
}
96+
// Assume it is in the same directory as ourselves.
9697
let mut path = std::env::current_exe().expect("current executable path invalid");
97-
if cfg!(windows) {
98-
path.set_file_name("miri.exe");
99-
} else {
100-
path.set_file_name("miri");
101-
}
98+
path.set_file_name(format!("miri{}", env::consts::EXE_SUFFIX));
10299
path
103100
}
104101

src/tools/miri/ci/ci.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ case $HOST_TARGET in
150150
UNIX="panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
151151
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
152152
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
153-
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX threadname pthread-sync available-parallelism libc-time
154-
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX threadname pthread-sync available-parallelism libc-time
153+
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX threadname pthread-sync available-parallelism libc-time tls
154+
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX threadname pthread-sync available-parallelism libc-time tls
155155
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX
156156
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem
157157
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm

src/tools/miri/miri

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/usr/bin/env bash
22
set -e
3+
# We want to call the binary directly, so we need to know where it ends up.
4+
MIRI_SCRIPT_TARGET_DIR="$(dirname "$0")"/miri-script/target
5+
# If stdout is not a terminal and we are not on CI, assume that we are being invoked by RA, and use JSON output.
6+
if ! [ -t 1 ] && [ -z "$CI" ]; then
7+
MESSAGE_FORMAT="--message-format=json"
8+
fi
9+
# We need a nightly toolchain, for the `profile-rustflags` cargo feature.
10+
cargo +nightly build $CARGO_EXTRA_FLAGS --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml \
11+
-q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \
12+
( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 )
313
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
414
# rustup (that sets it's own environmental variables), which is undesirable.
5-
MIRI_SCRIPT_TARGET_DIR="$(dirname "$0")"/miri-script/target
6-
cargo +stable build $CARGO_EXTRA_FLAGS -q --target-dir "$MIRI_SCRIPT_TARGET_DIR" --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml || \
7-
( echo "Failed to build miri-script. Is the 'stable' toolchain installed?"; exit 1 )
815
"$MIRI_SCRIPT_TARGET_DIR"/debug/miri-script "$@"

src/tools/miri/miri-script/miri

-4
This file was deleted.

0 commit comments

Comments
 (0)