@@ -13,14 +13,14 @@ use std::ffi::{OsStr, OsString};
13
13
use std:: path:: PathBuf ;
14
14
use std:: { env, fs} ;
15
15
16
- use crate :: Build ;
17
16
#[ cfg( not( test) ) ]
18
17
use crate :: builder:: Builder ;
19
18
use crate :: builder:: Kind ;
20
19
#[ cfg( not( test) ) ]
21
20
use crate :: core:: build_steps:: tool;
22
21
use crate :: core:: config:: Target ;
23
22
use crate :: utils:: exec:: command;
23
+ use crate :: { Build , Subcommand } ;
24
24
25
25
pub struct Finder {
26
26
cache : HashMap < OsString , Option < PathBuf > > ,
@@ -205,6 +205,20 @@ than building it.
205
205
. map ( |s| s. to_string ( ) )
206
206
. collect ( ) ;
207
207
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
+
208
222
// We're gonna build some custom C code here and there, host triples
209
223
// also build some C++ shims for LLVM so we need a C++ compiler.
210
224
for target in & build. targets {
@@ -278,15 +292,15 @@ than building it.
278
292
}
279
293
}
280
294
281
- if !build . config . dry_run ( ) {
295
+ if !skip_tools_checks {
282
296
cmd_finder. must_have ( build. cc ( * target) ) ;
283
297
if let Some ( ar) = build. ar ( * target) {
284
298
cmd_finder. must_have ( ar) ;
285
299
}
286
300
}
287
301
}
288
302
289
- if !build . config . dry_run ( ) {
303
+ if !skip_tools_checks {
290
304
for host in & build. hosts {
291
305
cmd_finder. must_have ( build. cxx ( * host) . unwrap ( ) ) ;
292
306
0 commit comments