Skip to content

Commit

Permalink
Detect compiling from Linux gnu to Linux musl as cross compiling (#2010)
Browse files Browse the repository at this point in the history
For maturin to correctly use bundled sysconfig Python when compiling from Linux gnu host to Linux musl target, we need to detect it as cross compiling, otherwise it will only find Python interpreters on the host that was compiled for glibc.
  • Loading branch information
messense authored Mar 27, 2024
1 parent 493e7d0 commit fec8722
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 fec8722

Please sign in to comment.