mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-01 07:13:24 +03:00
752b6637ce
The unstable features of the `test` crate used to be default-enabled, and manually disabled when building the beta and stable channels. Commitdae8ea92a7flipped that to default-disabled, only enabled for nightly and dev channels. However, this broke miri testing on the beta/stable channels, because it also uses unstable features -- which should be fine to enable just for its own sysroot build. Now the `test` build script makes that happen by noticing the `MIRI_CALLED_FROM_SETUP` environment variable. (cherry picked from commit30d7ed4c47)
18 lines
788 B
Rust
18 lines
788 B
Rust
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rustc-check-cfg=cfg(enable_unstable_features)");
|
|
|
|
// Miri testing uses unstable features, so always enable that for its sysroot.
|
|
// Otherwise, only enable unstable if rustc looks like a nightly or dev build.
|
|
let enable_unstable_features = std::env::var("MIRI_CALLED_FROM_SETUP").is_ok() || {
|
|
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
|
|
let version = std::process::Command::new(rustc).arg("-vV").output().unwrap();
|
|
let stdout = String::from_utf8(version.stdout).unwrap();
|
|
stdout.contains("nightly") || stdout.contains("dev")
|
|
};
|
|
|
|
if enable_unstable_features {
|
|
println!("cargo:rustc-cfg=enable_unstable_features");
|
|
}
|
|
}
|