Skip to content

Commit

Permalink
Rollup merge of rust-lang#68231 - danielframpton:windows-crosscompile…
Browse files Browse the repository at this point in the history
…, 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.
  • Loading branch information
JohnTitor authored Jan 15, 2020
2 parents 2c994f2 + 7d6271b commit 1859d57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ impl Step for Llvm {
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
} else if target.contains("freebsd") {
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
} else if target.contains("windows") {
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
}

cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build"));
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ fn main() {
let mut cmd = Command::new(&llvm_config);
cmd.arg(llvm_link_arg).arg("--ldflags");
for lib in output(&mut cmd).split_whitespace() {
if lib.starts_with("-LIBPATH:") {
println!("cargo:rustc-link-search=native={}", &lib[9..]);
} else if is_crossed {
if lib.starts_with("-L") {
if is_crossed {
if lib.starts_with("-LIBPATH:") {
println!("cargo:rustc-link-search=native={}", lib[9..].replace(&host, &target));
} else if lib.starts_with("-L") {
println!("cargo:rustc-link-search=native={}", lib[2..].replace(&host, &target));
}
} else if lib.starts_with("-LIBPATH:") {
println!("cargo:rustc-link-search=native={}", &lib[9..]);
} else if lib.starts_with("-l") {
println!("cargo:rustc-link-lib={}", &lib[2..]);
} else if lib.starts_with("-L") {
Expand Down

0 comments on commit 1859d57

Please sign in to comment.