diff options
| author | bors <bors@rust-lang.org> | 2024-09-07 13:21:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-07 13:21:44 +0000 |
| commit | 7468b6907cb6830fe61e049a476d5d3ca5e8fb26 (patch) | |
| tree | 32e9d02a5c4644b862ca1964f20f3521f7ca7d7f /src/bootstrap | |
| parent | 9afe7136958edaa403f0b0eb00f0353c125b7352 (diff) | |
| parent | 94fbe141558bb866c07f7c5138fba0d186c4ce85 (diff) | |
| download | rust-7468b6907cb6830fe61e049a476d5d3ca5e8fb26.tar.gz rust-7468b6907cb6830fe61e049a476d5d3ca5e8fb26.zip | |
Auto merge of #128871 - onur-ozkan:128180, r=Kobzol
bypass linker configuration and cross target check for specific commands Avoids configuring the linker and checking cross-target-specific tools unless necessary. Resolves #128180 cc `@ChrisDenton`
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/builder.rs | 10 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/cc_detect.rs | 32 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index a28b19d33a6..8f7ade79403 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -2463,7 +2463,15 @@ impl Cargo { cmd_kind: Kind, ) -> Cargo { let mut cargo = builder.cargo(compiler, mode, source_type, target, cmd_kind); - cargo.configure_linker(builder); + + match cmd_kind { + // No need to configure the target linker for these command types. + Kind::Clean | Kind::Check | Kind::Suggest | Kind::Format | Kind::Setup => {} + _ => { + cargo.configure_linker(builder); + } + } + cargo } diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index 29e6b74aace..a2c7ab31df8 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -87,15 +87,29 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build { } pub fn find(build: &Build) { - // For all targets we're going to need a C compiler for building some shims - // and such as well as for being a linker for Rust code. - let targets = build - .targets - .iter() - .chain(&build.hosts) - .cloned() - .chain(iter::once(build.build)) - .collect::<HashSet<_>>(); + let targets: HashSet<_> = match build.config.cmd { + // We don't need to check cross targets for these commands. + crate::Subcommand::Clean { .. } + | crate::Subcommand::Check { .. } + | crate::Subcommand::Suggest { .. } + | crate::Subcommand::Format { .. } + | crate::Subcommand::Setup { .. } => { + build.hosts.iter().cloned().chain(iter::once(build.build)).collect() + } + + _ => { + // For all targets we're going to need a C compiler for building some shims + // and such as well as for being a linker for Rust code. + build + .targets + .iter() + .chain(&build.hosts) + .cloned() + .chain(iter::once(build.build)) + .collect() + } + }; + for target in targets.into_iter() { find_target(build, target); } |
