Skip to content

Commit fa44c30

Browse files
committed
fix: remove "rust-lld" as custom linker on windows
- Since we already use the lld version packed by rust on windows by default, we can simply set custom_linker to `None` when the user is using "rust-lld" as linker.
1 parent d01a820 commit fa44c30

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

packages/cli/src/build/request.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,21 @@ impl BuildRequest {
861861
let mut custom_linker = cargo_config.linker(triple.to_string()).ok().flatten();
862862
let mut rustflags = cargo_config2::Flags::default();
863863

864+
// Remove "rust-lld" as a custom linker on Windows, since that is already the linker we
865+
// default to.
866+
if let Some(linker) = custom_linker.as_ref()
867+
&& (linker == "rust-lld" || linker == "rust-lld.exe")
868+
&& cfg!(windows)
869+
{
870+
// When using "rust-lld.exe" as linker on windows, it still needs to have a flavor
871+
// given to it. rustc appears to be passing `-flavor "link"` when none is set by the
872+
// user. If no flavor is given, it fails with 'lld is a generic driver'.
873+
// We already use the existing lld-link by default on windows, so we can simply set the
874+
// `custom_linker` to `None` in these cases, since we end up using "lld-link" anyway
875+
// which is the same as "rust-lld.exe -flavor link".
876+
custom_linker = None;
877+
}
878+
864879
// Make sure to take into account the RUSTFLAGS env var and the CARGO_TARGET_<triple>_RUSTFLAGS
865880
for env in [
866881
"RUSTFLAGS".to_string(),

0 commit comments

Comments
 (0)