Skip to content

Commit

Permalink
Do not use xwin to compile from x86_64/aarch64 to aarch64/x86_64 Wi…
Browse files Browse the repository at this point in the history
…ndows
  • Loading branch information
messense committed Dec 1, 2024
1 parent 5708c78 commit 3bd978d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ fn cargo_build_command(
let mut build_command = if target.is_msvc() && target.cross_compiling() {
#[cfg(feature = "xwin")]
{
println!("🛠️ Using xwin for cross-compiling to {target_triple}");
let xwin_options = {
use clap::Parser;

Expand Down Expand Up @@ -320,6 +321,7 @@ fn cargo_build_command(
build.target = vec![target_triple.to_string()];
}
} else {
println!("🛠️ Using zig for cross-compiling to {target_triple}");
build.enable_zig_ar = true;
let zig_triple = if target.is_linux() && !target.is_musl_libc() {
match context.platform_tag.iter().find(|tag| tag.is_manylinux()) {
Expand Down
15 changes: 15 additions & 0 deletions src/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ pub fn is_cross_compiling(target: &Target) -> Result<bool> {
// Not cross-compiling to compile for 32-bit Python from windows 64-bit
return Ok(false);
}
if (target_triple == "aarch64-pc-windows-msvc" && host == "x86_64-pc-windows-msvc")
|| (target_triple == "x86_64-pc-windows-msvc" && host == "aarch64-pc-windows-msvc")
{
// Not cross-compiling if the Windows MSVC compiler can compile for the target
let native_compile = cc::Build::new()
.opt_level(0)
.host(host)
.target(target_triple)
.cargo_metadata(false)
.cargo_warnings(false)
.cargo_output(false)
.try_get_compiler()
.is_ok();
return Ok(!native_compile);
}
if target_triple.ends_with("windows-gnu") && host.ends_with("windows-msvc") {
// Not cross-compiling to compile for Windows GNU from Windows MSVC host
return Ok(false);
Expand Down

0 comments on commit 3bd978d

Please sign in to comment.