Rollup merge of #121907 - onur-ozkan:better-target-sanity-check, r=albertlarsan68

skip sanity check for non-host targets in `check` builds

For `check` builds, since we only need to perform a sanity check on the host target, this patch skips target sanity checks on non-host targets.

For more context, see https://github.com/rust-lang/rust/issues/121519#issuecomment-1974836049

cc ``@saethlin``
This commit is contained in:
Jacob Pratt 2024-03-11 03:47:20 -04:00 committed by GitHub
commit 1009859899
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
use crate::builder::Kind;
use crate::core::config::Target; use crate::core::config::Target;
use crate::utils::helpers::output; use crate::utils::helpers::output;
use crate::Build; use crate::Build;
@ -64,6 +65,8 @@ pub fn check(build: &mut Build) {
let mut skip_target_sanity = let mut skip_target_sanity =
env::var_os("BOOTSTRAP_SKIP_TARGET_SANITY").is_some_and(|s| s == "1" || s == "true"); env::var_os("BOOTSTRAP_SKIP_TARGET_SANITY").is_some_and(|s| s == "1" || s == "true");
skip_target_sanity |= build.config.cmd.kind() == Kind::Check;
// Skip target sanity checks when we are doing anything with mir-opt tests or Miri // Skip target sanity checks when we are doing anything with mir-opt tests or Miri
let skipped_paths = [OsStr::new("mir-opt"), OsStr::new("miri")]; let skipped_paths = [OsStr::new("mir-opt"), OsStr::new("miri")];
skip_target_sanity |= build.config.paths.iter().any(|path| { skip_target_sanity |= build.config.paths.iter().any(|path| {
@ -169,11 +172,8 @@ pub fn check(build: &mut Build) {
continue; continue;
} }
// Some environments don't want or need these tools, such as when testing Miri. // skip check for cross-targets
// FIXME: it would be better to refactor this code to split necessary setup from pure sanity if skip_target_sanity && target != &build.build {
// checks, and have a regular flag for skipping the latter. Also see
// <https://github.com/rust-lang/rust/pull/103569#discussion_r1008741742>.
if skip_target_sanity {
continue; continue;
} }
@ -215,11 +215,8 @@ pub fn check(build: &mut Build) {
panic!("All the *-none-* and nvptx* targets are no-std targets") panic!("All the *-none-* and nvptx* targets are no-std targets")
} }
// Some environments don't want or need these tools, such as when testing Miri. // skip check for cross-targets
// FIXME: it would be better to refactor this code to split necessary setup from pure sanity if skip_target_sanity && target != &build.build {
// checks, and have a regular flag for skipping the latter. Also see
// <https://github.com/rust-lang/rust/pull/103569#discussion_r1008741742>.
if skip_target_sanity {
continue; continue;
} }