Skip to content

Commit 6cc3d5b

Browse files
authored
Rollup merge of rust-lang#68231 - danielframpton:windows-crosscompile, r=alexcrichton
Better support for cross compilation on Windows. I have been investigating enabling panic=unwind for aarch64-pc-windows-msvc (see rust-lang#65313) and building rustc and cargo hosted on aarch64-pc-windows-msvc. Without the libpath changes we were trying to link a mix of amd64 and arm64 binaries. Without the cmake system name change, the llvm build was trying to run an arm64 build tool on the x86_64 build machine. That said, I haven't tested all different combinations here and am very open to resolving this a different way.
2 parents 919da48 + 7d6271b commit 6cc3d5b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/bootstrap/native.rs

+2
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ impl Step for Llvm {
230230
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
231231
} else if target.contains("freebsd") {
232232
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
233+
} else if target.contains("windows") {
234+
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
233235
}
234236

235237
cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build"));

src/librustc_llvm/build.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,14 @@ fn main() {
215215
let mut cmd = Command::new(&llvm_config);
216216
cmd.arg(llvm_link_arg).arg("--ldflags");
217217
for lib in output(&mut cmd).split_whitespace() {
218-
if lib.starts_with("-LIBPATH:") {
219-
println!("cargo:rustc-link-search=native={}", &lib[9..]);
220-
} else if is_crossed {
221-
if lib.starts_with("-L") {
218+
if is_crossed {
219+
if lib.starts_with("-LIBPATH:") {
220+
println!("cargo:rustc-link-search=native={}", lib[9..].replace(&host, &target));
221+
} else if lib.starts_with("-L") {
222222
println!("cargo:rustc-link-search=native={}", lib[2..].replace(&host, &target));
223223
}
224+
} else if lib.starts_with("-LIBPATH:") {
225+
println!("cargo:rustc-link-search=native={}", &lib[9..]);
224226
} else if lib.starts_with("-l") {
225227
println!("cargo:rustc-link-lib={}", &lib[2..]);
226228
} else if lib.starts_with("-L") {

0 commit comments

Comments
 (0)