Skip to content

Commit cfb97e2

Browse files
Rollup 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 89b5130 + 94fbe14 commit cfb97e2

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

src/bootstrap/src/core/builder.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,15 @@ impl Cargo {
24442444
cmd_kind: Kind,
24452445
) -> Cargo {
24462446
let mut cargo = builder.cargo(compiler, mode, source_type, target, cmd_kind);
2447-
cargo.configure_linker(builder);
2447+
2448+
match cmd_kind {
2449+
// No need to configure the target linker for these command types.
2450+
Kind::Clean | Kind::Check | Kind::Suggest | Kind::Format | Kind::Setup => {}
2451+
_ => {
2452+
cargo.configure_linker(builder);
2453+
}
2454+
}
2455+
24482456
cargo
24492457
}
24502458

src/bootstrap/src/utils/cc_detect.rs

Lines changed: 23 additions & 9 deletions
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)