Skip to content

Commit ad9784e

Browse files
committed
make ./miri run a bit more silent; add option to control seeds tested by many-seeds
1 parent af92b04 commit ad9784e

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
9999
// `config.toml`.
100100
command.env("RUSTC_WRAPPER", "");
101101

102-
if only_setup {
103-
if print_sysroot {
104-
// Be extra sure there is no noise on stdout.
105-
command.stdout(process::Stdio::null());
106-
}
102+
if only_setup && !print_sysroot {
103+
// Forward output.
107104
} else {
105+
// Supress output.
108106
command.stdout(process::Stdio::null());
109107
command.stderr(process::Stdio::null());
110108
}
@@ -120,7 +118,9 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
120118
std::env::set_var("MIRI_SYSROOT", &sysroot_dir);
121119

122120
// Do the build.
123-
if only_setup {
121+
if print_sysroot {
122+
// Be silent.
123+
} else if only_setup {
124124
// We want to be explicit.
125125
eprintln!("Preparing a sysroot for Miri (target: {target})...");
126126
} else {
@@ -143,7 +143,9 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
143143
)
144144
}
145145
});
146-
if only_setup {
146+
if print_sysroot {
147+
// Be silent.
148+
} else if only_setup {
147149
eprintln!("A sysroot for Miri is now available in `{}`.", sysroot_dir.display());
148150
} else {
149151
eprintln!("done");

src/tools/miri/miri

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Mainly meant to be invoked by rust-analyzer.
3636
./miri many-seeds <command>:
3737
Runs <command> over and over again with different seeds for Miri. The MIRIFLAGS
3838
variable is set to its original value appended with ` -Zmiri-seed=$SEED` for
39-
many different seeds.
39+
many different seeds. The MIRI_SEEDS variable controls how many seeds are being
40+
tried; MIRI_SEED_START controls the first seed to try.
4041
4142
./miri bench <benches>:
4243
Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed.
@@ -174,7 +175,9 @@ rustc-push)
174175
fi
175176
;;
176177
many-seeds)
177-
for SEED in $(seq 0 255); do
178+
MIRI_SEED_START=${MIRI_SEED_START:-0} # default to 0
179+
MIRI_SEEDS=${MIRI_SEEDS:-256} # default to 256
180+
for SEED in $(seq $MIRI_SEED_START $(( $MIRI_SEED_START + $MIRI_SEEDS - 1 )) ); do
178181
echo "Trying seed: $SEED"
179182
MIRIFLAGS="$MIRIFLAGS -Zlayout-seed=$SEED -Zmiri-seed=$SEED" $@ || { echo "Failing seed: $SEED"; break; }
180183
done
@@ -249,6 +252,8 @@ export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR $RUSTFLAGS"
249252
# Build a sysroot and set MIRI_SYSROOT to use it. Arguments are passed to `cargo miri setup`.
250253
build_sysroot() {
251254
if ! MIRI_SYSROOT="$($CARGO run $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -- miri setup --print-sysroot "$@")"; then
255+
# Run it again so the user can see the error.
256+
$CARGO run $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -- miri setup "$@"
252257
echo "'cargo miri setup' failed"
253258
exit 1
254259
fi

0 commit comments

Comments
 (0)