Skip to content

Commit

Permalink
Detect compiling from Linux gnu to Linux musl as cross compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Mar 26, 2024
1 parent 493e7d0 commit f7c5b79
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,9 @@ 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 let Some(target_without_env) = target_triple
.rfind('-')
.map(|index| &target_triple[0..index])
{
if host.starts_with(target_without_env) {
// Not cross-compiling if arch-vendor-os is all the same
// e.g. x86_64-unknown-linux-musl on x86_64-unknown-linux-gnu host
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);
}

Ok(true)
Expand Down

0 comments on commit f7c5b79

Please sign in to comment.