Skip to content

Commit b252b4c

Browse files
authored
Unrolled build for #153437
Rollup merge of #153437 - RalfJung:miri-libtest-unstable, r=cuviper coretest in miri: fix using unstable libtest features Alternative (IMO preferable) to #153369. Also reverts that PR.
2 parents 052b9c2 + 6b7dbff commit b252b4c

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

library/test/build.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ fn main() {
22
println!("cargo:rerun-if-changed=build.rs");
33
println!("cargo:rustc-check-cfg=cfg(enable_unstable_features)");
44

5-
// Miri testing uses unstable features, so always enable that for its sysroot.
6-
// Otherwise, only enable unstable if rustc looks like a nightly or dev build.
7-
let enable_unstable_features = std::env::var("MIRI_CALLED_FROM_SETUP").is_ok() || {
8-
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
9-
let version = std::process::Command::new(rustc).arg("-vV").output().unwrap();
10-
let stdout = String::from_utf8(version.stdout).unwrap();
11-
stdout.contains("nightly") || stdout.contains("dev")
12-
};
5+
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
6+
let version = std::process::Command::new(rustc).arg("-vV").output().unwrap();
7+
let stdout = String::from_utf8(version.stdout).unwrap();
138

14-
if enable_unstable_features {
9+
if stdout.contains("nightly") || stdout.contains("dev") {
1510
println!("cargo:rustc-cfg=enable_unstable_features");
1611
}
1712
}

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,13 @@ impl Step for Miri {
741741

742742
// Run it again for mir-opt-level 4 to catch some miscompilations.
743743
if builder.config.test_args().is_empty() {
744-
cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4 -Cdebug-assertions=yes");
744+
cargo.env(
745+
"MIRIFLAGS",
746+
format!(
747+
"{} -O -Zmir-opt-level=4 -Cdebug-assertions=yes",
748+
env::var("MIRIFLAGS").unwrap_or_default()
749+
),
750+
);
745751
// Optimizations can change backtraces
746752
cargo.env("MIRI_SKIP_UI_CHECKS", "1");
747753
// `MIRI_SKIP_UI_CHECKS` and `RUSTC_BLESS` are incompatible
@@ -3108,6 +3114,17 @@ impl Step for Crate {
31083114
// does not set this directly, but relies on the rustc wrapper to set it, and we are not using
31093115
// the wrapper -- hence we have to set it ourselves.
31103116
cargo.rustflag("-Zforce-unstable-if-unmarked");
3117+
// Miri is told to invoke the libtest runner and bootstrap sets unstable flags
3118+
// for that runner. That only works when RUSTC_BOOTSTRAP is set. Bootstrap sets
3119+
// that flag but Miri by default does not forward the host environment to the test.
3120+
// Here we set up MIRIFLAGS to forward that env var.
3121+
cargo.env(
3122+
"MIRIFLAGS",
3123+
format!(
3124+
"{} -Zmiri-env-forward=RUSTC_BOOTSTRAP",
3125+
env::var("MIRIFLAGS").unwrap_or_default()
3126+
),
3127+
);
31113128
cargo
31123129
} else {
31133130
// Also prepare a sysroot for the target.

0 commit comments

Comments
 (0)