Skip to content

Commit 7468b69

Browse files
committed
Auto merge of rust-lang#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 rust-lang#128180 cc `@ChrisDenton`
2 parents 9afe713 + 94fbe14 commit 7468b69

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

Diff for: src/bootstrap/src/core/builder.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,15 @@ impl Cargo {
24632463
cmd_kind: Kind,
24642464
) -> Cargo {
24652465
let mut cargo = builder.cargo(compiler, mode, source_type, target, cmd_kind);
2466-
cargo.configure_linker(builder);
2466+
2467+
match cmd_kind {
2468+
// No need to configure the target linker for these command types.
2469+
Kind::Clean | Kind::Check | Kind::Suggest | Kind::Format | Kind::Setup => {}
2470+
_ => {
2471+
cargo.configure_linker(builder);
2472+
}
2473+
}
2474+
24672475
cargo
24682476
}
24692477

Diff for: src/bootstrap/src/utils/cc_detect.rs

+23-9
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,29 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
8787
}
8888

8989
pub fn find(build: &Build) {
90-
// For all targets we're going to need a C compiler for building some shims
91-
// and such as well as for being a linker for Rust code.
92-
let targets = build
93-
.targets
94-
.iter()
95-
.chain(&build.hosts)
96-
.cloned()
97-
.chain(iter::once(build.build))
98-
.collect::<HashSet<_>>();
90+
let targets: HashSet<_> = match build.config.cmd {
91+
// We don't need to check cross targets for these commands.
92+
crate::Subcommand::Clean { .. }
93+
| crate::Subcommand::Check { .. }
94+
| crate::Subcommand::Suggest { .. }
95+
| crate::Subcommand::Format { .. }
96+
| crate::Subcommand::Setup { .. } => {
97+
build.hosts.iter().cloned().chain(iter::once(build.build)).collect()
98+
}
99+
100+
_ => {
101+
// For all targets we're going to need a C compiler for building some shims
102+
// and such as well as for being a linker for Rust code.
103+
build
104+
.targets
105+
.iter()
106+
.chain(&build.hosts)
107+
.cloned()
108+
.chain(iter::once(build.build))
109+
.collect()
110+
}
111+
};
112+
99113
for target in targets.into_iter() {
100114
find_target(build, target);
101115
}

0 commit comments

Comments
 (0)