Skip to content

Commit 7142e0d

Browse files
Rollup merge of rust-lang#130398 - ChrisDenton:win-cross, r=jieyouxu
Add system libs for LLVM when cross compiling for Windows Windows uses "import libraries" to link to system libraries. These are a kind of static lib that are distributed with the Windows SDK and therefore they don't rely on the host. All that matters is you have the right SDK installed for the target.
2 parents 9025fe9 + 7223fd8 commit 7142e0d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: compiler/rustc_llvm/build.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ fn main() {
220220
let mut cmd = Command::new(&llvm_config);
221221
cmd.arg(llvm_link_arg).arg("--libs");
222222

223-
if !is_crossed {
223+
// Don't link system libs if cross-compiling unless targetting Windows.
224+
// On Windows system DLLs aren't linked directly, instead import libraries are used.
225+
// These import libraries are independent of the host.
226+
if !is_crossed || target.contains("windows") {
224227
cmd.arg("--system-libs");
225228
}
226229

0 commit comments

Comments
 (0)