Skip to content

skip compiler tools sanity checks on certain commands #141247

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 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
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
20 changes: 17 additions & 3 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ use std::ffi::{OsStr, OsString};
use std::path::PathBuf;
use std::{env, fs};

use crate::Build;
#[cfg(not(test))]
use crate::builder::Builder;
use crate::builder::Kind;
#[cfg(not(test))]
use crate::core::build_steps::tool;
use crate::core::config::Target;
use crate::utils::exec::command;
use crate::{Build, Subcommand};

pub struct Finder {
cache: HashMap<OsString, Option<PathBuf>>,
Expand Down Expand Up @@ -205,6 +205,20 @@ than building it.
.map(|s| s.to_string())
.collect();

// Compiler tools like `cc` and `ar` are not configured for cross-targets on certain subcommands
// because they are not needed.
//
// See `cc_detect::find` for more details.
let skip_tools_checks = build.config.dry_run()
|| matches!(
build.config.cmd,
Subcommand::Clean { .. }
| Subcommand::Check { .. }
| Subcommand::Suggest { .. }
| Subcommand::Format { .. }
| Subcommand::Setup { .. }
);

// We're gonna build some custom C code here and there, host triples
// also build some C++ shims for LLVM so we need a C++ compiler.
for target in &build.targets {
Expand Down Expand Up @@ -278,15 +292,15 @@ than building it.
}
}

if !build.config.dry_run() {
if !skip_tools_checks {
cmd_finder.must_have(build.cc(*target));
if let Some(ar) = build.ar(*target) {
cmd_finder.must_have(ar);
}
}
}

if !build.config.dry_run() {
if !skip_tools_checks {
for host in &build.hosts {
cmd_finder.must_have(build.cxx(*host).unwrap());

Expand Down
Loading