`cargo` uses `x86_64-w64-mingw32-ld` even if `linker=lld-link` is specified

432 views Asked by At

I'm trying to build a UEFI binary in stable Rust, so I don't use the x86_64-unknown-uefi target as it requires the Nightly toolchain. To do so, I created .cargo/config.toml:

[build]
target = "x86_64-pc-windows-gnu"

[target.x86_64-pc-windows-gnu]
rustflags = [
    "-C", "link-args=/nologo /nxcompat /nodefaultlib /entry:efi_main /subsystem:efi_application",
    "-C", "code-model=large",
    "-C", "prefer-dynamic=n",
    "-C", "no-redzone=y",
    "-C", "panic=abort",
    "-C", "linker=lld-link",
]

Building succeeds on my local machine but fails on GitHub Actions (log). The x86_64-w64-mingw32-ld is still used even if I specify lld-link as a linker.

How do I force cargo to use lld-link?

1

There are 1 answers

0
RivenSkaye On

Have you tried adding linker = "lld-link" under the [target.x86_64-pc-windows-gnu] table? Alternatively, try CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="lld-link" cargo build. This should force its use throughout the dependency chain.