Skip to content

Miri subtree update #143478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 59 commits into from
Jul 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
6e05d61
Synced rust-analyzer configs
YohDeadfall Jun 27, 2025
40ec147
Merge pull request #4415 from YohDeadfall/sync-ra-configs
RalfJung Jun 28, 2025
75e22d5
Preparing for merge from rustc
Jun 29, 2025
7b985d5
Merge from rustc
Jun 29, 2025
03a7b9f
Merge pull request #4420 from rust-lang/rustup-2025-06-29
RalfJung Jun 29, 2025
7be1bf7
make ./miri work on stable again
RalfJung Jun 29, 2025
d01e001
Merge pull request #4423 from RalfJung/miri-script-stable
RalfJung Jun 29, 2025
ea69081
also test on arm-64 linux hosts
RalfJung Jun 29, 2025
651d2f8
Merge pull request #4424 from RalfJung/aarch64-linux-ci
RalfJung Jun 29, 2025
d539e66
Preparing for merge from rustc
RalfJung Jun 29, 2025
9c22372
Merge from rustc
RalfJung Jun 29, 2025
33f1700
Merge pull request #4425 from RalfJung/rustup
RalfJung Jun 29, 2025
ab2443c
fix type mismatches in native-lib/scalar_arguments test
RalfJung Jun 29, 2025
6aaaff8
test on x86-32 and arm-32
RalfJung Jun 29, 2025
e788b3c
also test on s390x via qemu
RalfJung Jun 29, 2025
d559073
remove duplicate clippy check
RalfJung Jun 29, 2025
ec85b70
add a riscv64 test job
RalfJung Jun 29, 2025
d69b8e2
Add shims for `gettid`-esque functions
tgross35 Jun 13, 2025
d1ee0eb
Merge pull request #4422 from RalfJung/more-ci
RalfJung Jun 29, 2025
555553f
Merge pull request #4397 from tgross35/gettid-shims
RalfJung Jun 29, 2025
cd971c6
linux futex: fix for val > i32::MAX
RalfJung Jun 30, 2025
8bb5f8c
Merge pull request #4429 from RalfJung/futex-val-too-big
RalfJung Jun 30, 2025
0c3c9e4
Preparing for merge from rustc
Jul 1, 2025
e6371c9
Merge from rustc
Jul 1, 2025
8958967
fmt
Jul 1, 2025
c52d522
./miri toolchain: no need to run 'cargo metadata'
RalfJung Jul 1, 2025
83d519c
Merge pull request #4431 from rust-lang/rustup-2025-07-01
RalfJung Jul 1, 2025
828f594
re-balance CI jobs
RalfJung Jul 1, 2025
d72b15b
Merge pull request #4432 from RalfJung/no-metadata
RalfJung Jul 1, 2025
b9b8fd2
Merge pull request #4433 from RalfJung/ci-balance
RalfJung Jul 1, 2025
4606afb
Remove leaky synchronisation objects.
LorrensP-2158466 Jun 12, 2025
0ca0671
Merge pull request #4411 from LorrensP-2158466/remove-leaky-syncobj
RalfJung Jul 1, 2025
9d9f0e0
Preparing for merge from rustc
Jul 2, 2025
af5f4be
Merge from rustc
Jul 2, 2025
28900b0
Add tracing feature to enable tracing_chrome support
Stypox Jun 18, 2025
d2f2271
rename show_error -> fatal_error
RalfJung Jul 2, 2025
0234984
Merge pull request #4436 from rust-lang/rustup-2025-07-02
RalfJung Jul 2, 2025
0d43e2f
Merge pull request #4406 from Stypox/tracing
RalfJung Jul 2, 2025
510040f
skip env var memory for leak check
RalfJung Jul 2, 2025
5ce7a04
Merge pull request #4437 from RalfJung/env-cleanup
RalfJung Jul 2, 2025
8fc0fd5
use more clever approach for genmc conditional import
RalfJung Jul 2, 2025
143c05a
Merge pull request #4438 from RalfJung/genmc-conditional-import
RalfJung Jul 2, 2025
db617af
only set host-specific CC; improve and de-duplicate native libs testi…
RalfJung Jul 3, 2025
4be7583
Merge pull request #4439 from RalfJung/ci
RalfJung Jul 3, 2025
2cbbd6c
Preparing for merge from rustc
RalfJung Jul 3, 2025
484c64b
Merge from rustc
RalfJung Jul 3, 2025
3c3f1e4
Merge pull request #4440 from RalfJung/rustup
RalfJung Jul 3, 2025
7ea812f
nanosleep: fix argument name and add a missing argument read
RalfJung Jul 3, 2025
2119b7e
Merge pull request #4441 from RalfJung/nanosleep
RalfJung Jul 3, 2025
04522bb
Preparing for merge from rustc
Jul 4, 2025
f655289
Merge from rustc
Jul 4, 2025
0018401
Merge pull request #4442 from rust-lang/rustup-2025-07-04
oli-obk Jul 4, 2025
0d656e0
declare data race and weak memory support as non-experimental
RalfJung Jul 4, 2025
23b3be5
Merge pull request #4443 from RalfJung/concurrency-ub-detection
RalfJung Jul 4, 2025
1620117
Preparing for merge from rustc
RalfJung Jul 5, 2025
61f3705
Merge from rustc
RalfJung Jul 5, 2025
72043e3
fmt
RalfJung Jul 5, 2025
6e3e05b
Merge pull request #4445 from RalfJung/rustup
RalfJung Jul 5, 2025
a1f4172
update lockfile
RalfJung Jul 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,7 @@ dependencies = [
"regex",
"rustc_version",
"serde",
"serde_json",
"smallvec",
"tempfile",
"tikv-jemalloc-sys",
Expand Down
79 changes: 62 additions & 17 deletions src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,82 @@ defaults:
shell: bash

jobs:
build:
test:
name: test (${{ matrix.host_target }})
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
host_target: x86_64-unknown-linux-gnu
- os: macos-14
host_target: aarch64-apple-darwin
- os: windows-latest
host_target: i686-pc-windows-msvc
- host_target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- host_target: i686-unknown-linux-gnu
os: ubuntu-latest
multiarch: i386
gcc_cross: i686-linux-gnu
- host_target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
- host_target: armv7-unknown-linux-gnueabihf
os: ubuntu-24.04-arm
multiarch: armhf
gcc_cross: arm-linux-gnueabihf
- host_target: riscv64gc-unknown-linux-gnu
os: ubuntu-latest
multiarch: riscv64
gcc_cross: riscv64-linux-gnu
qemu: true
- host_target: s390x-unknown-linux-gnu
os: ubuntu-latest
multiarch: s390x
gcc_cross: s390x-linux-gnu
qemu: true
- host_target: aarch64-apple-darwin
os: macos-latest
- host_target: i686-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
env:
HOST_TARGET: ${{ matrix.host_target }}
steps:
- uses: actions/checkout@v4
- name: install qemu
if: ${{ matrix.qemu }}
run: sudo apt install qemu-user qemu-user-binfmt
- name: install multiarch
if: ${{ matrix.multiarch != '' }}
run: |
# s390x, ppc64el need Ubuntu Ports to be in the mirror list
sudo bash -c "echo 'https://ports.ubuntu.com/ priority:4' >> /etc/apt/apt-mirrors.txt"
# Add architecture
sudo dpkg --add-architecture ${{ matrix.multiarch }}
sudo apt update
# Install needed packages
sudo apt install $(echo "libatomic1: zlib1g-dev:" | sed 's/:/:${{ matrix.multiarch }}/g')
- uses: ./.github/workflows/setup
with:
toolchain_flags: "--host ${{ matrix.host_target }}"

# The `style` job only runs on Linux; this makes sure the Windows-host-specific
# code is also covered by clippy.
- name: Check clippy
if: ${{ matrix.os == 'windows-latest' }}
run: ./miri clippy -- -D warnings
# We set up the cross-compiler *after* the basic setup as setting CC would otherwise
# cause confusion.
- name: install gcc-cross
if: ${{ matrix.gcc_cross != '' }}
run: |
sudo apt install gcc-${{ matrix.gcc_cross }}
echo "Setting environment variables:"
echo "CC_${{ matrix.host_target }}=${{ matrix.gcc_cross }}-gcc" | tee -a $GITHUB_ENV
TARGET_UPPERCASE=$(echo ${{ matrix.host_target }} | tr '[:lower:]-' '[:upper:]_')
echo "CARGO_TARGET_${TARGET_UPPERCASE}_LINKER=${{ matrix.gcc_cross }}-gcc" | tee -a $GITHUB_ENV

- name: Test Miri
# The main test job! We don't run this in qemu as that is quite slow,
# so those targets only get the clippy check below.
- name: test Miri
if: ${{ !matrix.qemu }}
run: ./ci/ci.sh

# The `style` job only runs on Linux; this makes sure the host-specific
# code is also covered by clippy.
- name: clippy
run: ./miri clippy -- -D warnings

style:
name: style checks
runs-on: ubuntu-latest
Expand All @@ -51,8 +98,6 @@ jobs:

- name: rustfmt
run: ./miri fmt --check
- name: clippy
run: ./miri clippy -- -D warnings
- name: clippy (no features)
run: ./miri clippy --no-default-features -- -D warnings
- name: clippy (all features)
Expand All @@ -73,7 +118,7 @@ jobs:
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
# And they should be added below in `cron-fail-notify` as well.
conclusion:
needs: [build, style, coverage]
needs: [test, style, coverage]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
Expand Down Expand Up @@ -135,7 +180,7 @@ jobs:
cron-fail-notify:
name: cronjob failure notification
runs-on: ubuntu-latest
needs: [build, style, coverage]
needs: [test, style, coverage]
if: ${{ github.event_name == 'schedule' && failure() }}
steps:
# Send a Zulip notification
Expand Down
12 changes: 5 additions & 7 deletions src/tools/miri/.github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: "Miri CI setup"
description: "Sets up Miri CI"
inputs:
toolchain_flags:
description: extra flags to pass to rustup-toolchain-install-master
required: false
default: ''
runs:
Expand Down Expand Up @@ -31,18 +32,15 @@ runs:
~/.cargo/bin
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/**/*.yml') }}
restore-keys: cargo-${{ runner.os }}
# Bump the version when something here changes that needs a cache reset.
key: cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock') }}-v1
restore-keys: cargo-${{ runner.os }}-${{ runner.arch }}

- name: Install rustup-toolchain-install-master
- name: Install the tools we need
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install -f rustup-toolchain-install-master hyperfine
shell: bash

- name: Install nightly toolchain
run: rustup toolchain install nightly --profile minimal
shell: bash

- name: Install "master" toolchain
run: |
if [[ ${{ github.event_name }} == 'schedule' ]]; then
Expand Down
9 changes: 9 additions & 0 deletions src/tools/miri/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ compiler that has `debug=true` set in `bootstrap.toml`.
You can set `MIRI_BACKTRACE=1` to get a backtrace of where an
evaluation error was originally raised.

#### Tracing

You can generate a Chrome trace file from a Miri execution by passing `--features=tracing` during the
build and then setting `MIRI_TRACING=1` when running Miri. This will generate a `.json` file that
you can visualize in [Perfetto](https://ui.perfetto.dev/). For example:

```sh
MIRI_TRACING=1 ./miri run --features=tracing tests/pass/hello.rs
```

### UI testing

Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ dependencies = [
"regex",
"rustc_version",
"serde",
"serde_json",
"smallvec",
"tempfile",
"tikv-jemalloc-sys",
Expand Down
2 changes: 2 additions & 0 deletions src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ chrono = { version = "0.4.38", default-features = false }
chrono-tz = "0.10"
directories = "6"
bitflags = "2.6"
serde_json = { version = "1.0", optional = true }

# Copied from `compiler/rustc/Cargo.toml`.
# But only for some targets, it fails for others. Rustc configures this in its CI, but we can't
Expand Down Expand Up @@ -67,6 +68,7 @@ default = ["stack-cache"]
genmc = []
stack-cache = []
stack-cache-consistency-check = ["stack-cache"]
tracing = ["serde_json"]

[lints.rust.unexpected_cfgs]
level = "warn"
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ instance:
* Not sufficiently aligned memory accesses and references
* Violation of basic type invariants (a `bool` that is not 0 or 1, for example,
or an invalid enum discriminant)
* Data races and emulation of *some* weak memory effects, i.e.,
atomic reads can return outdated values
* **Experimental**: Violations of the [Stacked Borrows] rules governing aliasing
for reference types
* **Experimental**: Violations of the [Tree Borrows] aliasing rules, as an optional
alternative to [Stacked Borrows]
* **Experimental**: Data races and emulation of weak memory effects, i.e.,
atomic reads can return outdated values.

On top of that, Miri will also tell you about memory leaks: when there is memory
still allocated at the end of the execution, and that memory is not reachable
Expand Down
43 changes: 27 additions & 16 deletions src/tools/miri/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,42 +143,53 @@ case $HOST_TARGET in
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
# Extra tier 1
MANY_SEEDS=64 TEST_TARGET=i686-unknown-linux-gnu run_tests
MANY_SEEDS=64 TEST_TARGET=aarch64-unknown-linux-gnu run_tests
MANY_SEEDS=64 TEST_TARGET=x86_64-apple-darwin run_tests
MANY_SEEDS=64 TEST_TARGET=x86_64-pc-windows-gnu run_tests
;;
i686-unknown-linux-gnu)
# Host
# Without GC_STRESS as this is a slow runner.
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
# Partially supported targets (tier 2)
BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
UNIX="hello 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
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random thread sync concurrency epoll eventfd
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
;;
aarch64-unknown-linux-gnu)
# Host
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
# Extra tier 1 candidate
MANY_SEEDS=64 TEST_TARGET=aarch64-pc-windows-msvc run_tests
# Extra tier 2
MANY_SEEDS=16 TEST_TARGET=arm-unknown-linux-gnueabi run_tests # 32bit ARM
MANY_SEEDS=16 TEST_TARGET=aarch64-pc-windows-gnullvm run_tests # gnullvm ABI
MANY_SEEDS=16 TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
# Custom target JSON file
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 run_tests_minimal no_std
;;
armv7-unknown-linux-gnueabihf)
# Host
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
;;
aarch64-apple-darwin)
# Host
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
# Extra tier 1
MANY_SEEDS=64 TEST_TARGET=i686-pc-windows-gnu run_tests
MANY_SEEDS=64 TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
# Extra tier 2
MANY_SEEDS=16 TEST_TARGET=arm-unknown-linux-gnueabi run_tests # 32bit ARM
MANY_SEEDS=16 TEST_TARGET=aarch64-pc-windows-gnullvm run_tests # gnullvm ABI
MANY_SEEDS=16 TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
# Not officially supported tier 2
MANY_SEEDS=16 TEST_TARGET=mips-unknown-linux-gnu run_tests # a 32bit big-endian target, and also a target without 64bit atomics
MANY_SEEDS=16 TEST_TARGET=x86_64-unknown-illumos run_tests
MANY_SEEDS=16 TEST_TARGET=x86_64-pc-solaris run_tests
MANY_SEEDS=16 TEST_TARGET=x86_64-unknown-freebsd run_tests
MANY_SEEDS=16 TEST_TARGET=i686-unknown-freebsd run_tests
# Partially supported targets (tier 2)
BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
UNIX="hello 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
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random thread sync concurrency epoll eventfd
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
# Custom target JSON file
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 run_tests_minimal no_std
;;
i686-pc-windows-msvc)
# Host
# Without GC_STRESS and with reduced many-seeds count as this is the slowest runner.
# (The macOS runner checks windows-msvc with full many-seeds count.)
# Without GC_STRESS as this is the slowest runner.
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
# Extra tier 1
# We really want to ensure a Linux target works on a Windows host,
Expand Down
12 changes: 5 additions & 7 deletions src/tools/miri/etc/rust_analyzer_helix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ linkedProjects = [
]

[language-server.rust-analyzer.config.check]
invocationLocation = "root"
invocationStrategy = "once"
overrideCommand = [
"env",
"MIRI_AUTO_OPS=no",
"./miri",
"clippy", # make this `check` when working with a locally built rustc
"--message-format=json",
]

[language-server.rust-analyzer.config.cargo.extraEnv]
MIRI_AUTO_OPS = "no"
MIRI_IN_RA = "1"

# Contrary to what the name suggests, this also affects proc macros.
[language-server.rust-analyzer.config.buildScripts]
invocationLocation = "root"
[language-server.rust-analyzer.config.cargo.buildScripts]
invocationStrategy = "once"
overrideCommand = [
"env",
"MIRI_AUTO_OPS=no",
"./miri",
"check",
"--message-format=json",
Expand Down
28 changes: 16 additions & 12 deletions src/tools/miri/miri
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
set -e
# We want to call the binary directly, so we need to know where it ends up.
ROOT_DIR="$(dirname "$0")"
MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target
TOOLCHAIN="+nightly"
TARGET_DIR="$ROOT_DIR"/miri-script/target
# Prepare cargo invocation.
# We have to overwrite the toolchain since `+miri` might be activated and not installed.
TOOLCHAIN="+stable"
CARGO_FLAGS=("-q")
# If we are being invoked for RA, use JSON output and the default toolchain (to make proc-macros
# work in RA). This needs a different target dir to avoid mixing up the builds.
# Also set `-Zroot-dir` so that RA can identify where the error occurred.
if [ -n "$MIRI_IN_RA" ]; then
MESSAGE_FORMAT="--message-format=json"
TOOLCHAIN=""
MIRI_SCRIPT_TARGET_DIR="$MIRI_SCRIPT_TARGET_DIR"/ra
CARGO_FLAGS+=("--message-format=json" "-Zroot-dir=$ROOT_DIR")
TARGET_DIR="$ROOT_DIR"/target
fi
# We need a nightly toolchain, for `-Zroot-dir`.
cargo $TOOLCHAIN build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
-Zroot-dir="$ROOT_DIR" \
-q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \
( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 )
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
# rustup (that sets it's own environmental variables), which is undesirable.
"$MIRI_SCRIPT_TARGET_DIR"/debug/miri-script "$@"
# Run cargo.
cargo $TOOLCHAIN build --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
--target-dir "$TARGET_DIR" "${CARGO_FLAGS[@]}" || \
( echo "Failed to build miri-script. Is the 'stable' toolchain installed?"; exit 1 )
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly.
# Invoking `cargo run` goes through rustup (that sets it's own environmental variables), which is
# undesirable.
"$TARGET_DIR"/debug/miri-script "$@"
21 changes: 11 additions & 10 deletions src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ impl Command {
cmd!(sh, "rustup override set miri").run()?;
// Cleanup.
cmd!(sh, "cargo clean").run()?;
// Call `cargo metadata` on the sources in case that changes the lockfile
// (which fails under some setups when it is done from inside vscode).
let sysroot = cmd!(sh, "rustc --print sysroot").read()?;
let sysroot = sysroot.trim();
cmd!(sh, "cargo metadata --format-version 1 --manifest-path {sysroot}/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml").ignore_stdout().run()?;
Ok(())
}

Expand Down Expand Up @@ -707,9 +702,12 @@ impl Command {
let mut early_flags = Vec::<OsString>::new();

// In `dep` mode, the target is already passed via `MIRI_TEST_TARGET`
if !dep && let Some(target) = &target {
early_flags.push("--target".into());
early_flags.push(target.into());
#[expect(clippy::collapsible_if)] // we need to wait until this is stable
if !dep {
if let Some(target) = &target {
early_flags.push("--target".into());
early_flags.push(target.into());
}
}
early_flags.push("--edition".into());
early_flags.push(edition.as_deref().unwrap_or("2021").into());
Expand Down Expand Up @@ -737,8 +735,11 @@ impl Command {
// Add Miri flags
let mut cmd = cmd.args(&miri_flags).args(&early_flags).args(&flags);
// For `--dep` we also need to set the target in the env var.
if dep && let Some(target) = &target {
cmd = cmd.env("MIRI_TEST_TARGET", target);
#[expect(clippy::collapsible_if)] // we need to wait until this is stable
if dep {
if let Some(target) = &target {
cmd = cmd.env("MIRI_TEST_TARGET", target);
}
}
// Finally, run the thing.
Ok(cmd.run()?)
Expand Down
Loading
Loading