Skip to content

Commit 9da637a

Browse files
committed
skip compiler tools sanity checks on certain commands
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent 414482f commit 9da637a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/bootstrap/src/core/sanity.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ use std::ffi::{OsStr, OsString};
1313
use std::path::PathBuf;
1414
use std::{env, fs};
1515

16-
use crate::Build;
1716
#[cfg(not(test))]
1817
use crate::builder::Builder;
1918
use crate::builder::Kind;
2019
#[cfg(not(test))]
2120
use crate::core::build_steps::tool;
2221
use crate::core::config::Target;
2322
use crate::utils::exec::command;
23+
use crate::{Build, Subcommand};
2424

2525
pub struct Finder {
2626
cache: HashMap<OsString, Option<PathBuf>>,
@@ -205,6 +205,20 @@ than building it.
205205
.map(|s| s.to_string())
206206
.collect();
207207

208+
// Compiler tools like `cc` and `ar` are not configured for cross-targets on certain subcommands
209+
// because they are not needed.
210+
//
211+
// See `cc_detect::find` for more details.
212+
let skip_tools_checks = build.config.dry_run()
213+
|| matches!(
214+
build.config.cmd,
215+
Subcommand::Clean { .. }
216+
| Subcommand::Check { .. }
217+
| Subcommand::Suggest { .. }
218+
| Subcommand::Format { .. }
219+
| Subcommand::Setup { .. }
220+
);
221+
208222
// We're gonna build some custom C code here and there, host triples
209223
// also build some C++ shims for LLVM so we need a C++ compiler.
210224
for target in &build.targets {
@@ -278,15 +292,15 @@ than building it.
278292
}
279293
}
280294

281-
if !build.config.dry_run() {
295+
if !skip_tools_checks {
282296
cmd_finder.must_have(build.cc(*target));
283297
if let Some(ar) = build.ar(*target) {
284298
cmd_finder.must_have(ar);
285299
}
286300
}
287301
}
288302

289-
if !build.config.dry_run() {
303+
if !skip_tools_checks {
290304
for host in &build.hosts {
291305
cmd_finder.must_have(build.cxx(*host).unwrap());
292306

0 commit comments

Comments
 (0)