Skip to content

Commit e5e1817

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 e5e1817

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/cli/src/build/request.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,20 @@ 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+
if (linker == "rust-lld" || linker == "rust-lld.exe") && cfg!(windows) {
868+
// When using "rust-lld.exe" as linker on windows, it still needs to have a flavor
869+
// given to it. rustc appears to be passing `-flavor "link"` when none is set by the
870+
// user. If no flavor is given, it fails with 'lld is a generic driver'.
871+
// We already use the existing lld-link by default on windows, so we can simply set the
872+
// `custom_linker` to `None` in these cases, since we end up using "lld-link" anyway
873+
// which is the same as "rust-lld.exe -flavor link".
874+
custom_linker = None;
875+
}
876+
}
877+
864878
// Make sure to take into account the RUSTFLAGS env var and the CARGO_TARGET_<triple>_RUSTFLAGS
865879
for env in [
866880
"RUSTFLAGS".to_string(),

0 commit comments

Comments
 (0)