call Cargo::configure_linker only for specific commands

Calling `Cargo::configure_linker` unconditionally slows down certain
commands (e.g., "check" command) without providing any benefit.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2024-08-09 12:22:00 +03:00
parent 60d146580c
commit 9a29081b49

View file

@ -2446,7 +2446,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
}