Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ 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.starts_with("x86_64-pc-windows") && host.starts_with("aarch64-pc-windows") {
// Not cross-compiling to compile for x86-64 Python from Windows arm64,
// Windows arm64 can run x86-64 binaries natively
return Ok(false);
}
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
7 changes: 7 additions & 0 deletions src/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,13 @@ pub(crate) fn detect_arch_from_python(python: &PathBuf, target: &Target) -> Opti
} else if platform.contains("arm64") && target.target_arch() != Arch::Aarch64 {
return Some(TargetTriple::Regular("aarch64-apple-darwin".to_string()));
}
} else if platform.contains("win") {
// On Windows ARM with x86_64 Python (win-amd64), detect the arch mismatch
if platform.contains("amd64") && target.target_arch() != Arch::X86_64 {
return Some(TargetTriple::Regular("x86_64-pc-windows-msvc".to_string()));
} else if platform.contains("arm64") && target.target_arch() != Arch::Aarch64 {
return Some(TargetTriple::Regular("aarch64-pc-windows-msvc".to_string()));
}
}
}
_ => eprintln!("⚠️ Warning: Failed to determine python platform"),
Expand Down
Loading