Skip to content

Commit 8b6f983

Browse files
committed
skip cc and ar sanity checks on certain commands
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent 414482f commit 8b6f983

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/bootstrap/src/core/sanity.rs

Lines changed: 16 additions & 2 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+
// `cc` and `ar` are not configured for cross-targets on certain subcommands because they are
209+
// not needed.
210+
//
211+
// See `cc_detect::find` for more details.
212+
let skip_cc_and_ar_check = 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,7 +292,7 @@ than building it.
278292
}
279293
}
280294

281-
if !build.config.dry_run() {
295+
if !skip_cc_and_ar_check {
282296
cmd_finder.must_have(build.cc(*target));
283297
if let Some(ar) = build.ar(*target) {
284298
cmd_finder.must_have(ar);

0 commit comments

Comments
 (0)