diff --git a/src/build_options.rs b/src/build_options.rs index 8327120c1..1624e4262 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -591,7 +591,7 @@ impl BuildOptions { x.compatibility() }) .or(if use_zig { - if target.is_musl_target() { + if target.is_musl_libc() { // Zig bundles musl 1.2 Some(PlatformTag::Musllinux { x: 1, y: 2 }) } else { @@ -601,7 +601,7 @@ impl BuildOptions { } } else { // Defaults to musllinux_1_2 for musl target if it's not bin bindings - if target.is_musl_target() && !bridge.is_bin() { + if target.is_musl_libc() && !bridge.is_bin() { Some(PlatformTag::Musllinux { x: 1, y: 2 }) } else { None @@ -619,6 +619,8 @@ impl BuildOptions { for platform_tag in &platform_tags { if !platform_tag.is_supported() { eprintln!("⚠️ Warning: {platform_tag} is unsupported by the Rust compiler."); + } else if platform_tag.is_musllinux() && !target.is_musl_libc() { + eprintln!("⚠️ Warning: {target} is not compatible with {platform_tag}."); } } @@ -686,7 +688,7 @@ fn validate_bridge_type( match bridge { BridgeModel::Bin(None) => { // Only support two different kind of platform tags when compiling to musl target without any binding crates - if platform_tags.iter().any(|tag| tag.is_musllinux()) && !target.is_musl_target() { + if platform_tags.iter().any(|tag| tag.is_musllinux()) && !target.is_musl_libc() { bail!( "Cannot mix musllinux and manylinux platform tags when compiling to {}", target.target_triple() diff --git a/src/compile.rs b/src/compile.rs index f4e05de57..759a6d49a 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -197,7 +197,7 @@ fn compile_target( // https://github.com/rust-lang/rust/issues/59302#issue-422994250 // We must only do this for libraries as it breaks binaries // For some reason this value is ignored when passed as rustc argument - if context.target.is_musl_target() + if context.target.is_musl_libc() && !rustflags .flags .iter() @@ -300,7 +300,7 @@ fn compile_target( } } else { build.enable_zig_ar = true; - let zig_triple = if target.is_linux() && !target.is_musl_target() { + let zig_triple = if target.is_linux() && !target.is_musl_libc() { match context.platform_tag.iter().find(|tag| tag.is_manylinux()) { Some(PlatformTag::Manylinux { x, y }) => { format!("{target_triple}.{x}.{y}") diff --git a/src/target.rs b/src/target.rs index 999e2aa2c..ff08e5fdc 100644 --- a/src/target.rs +++ b/src/target.rs @@ -190,6 +190,12 @@ pub struct Target { pub(crate) user_specified: bool, } +impl fmt::Display for Target { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.triple) + } +} + impl Target { /// Uses the given target triple or tries the guess the current target by using the one used /// for compilation @@ -502,7 +508,7 @@ impl Target { /// Returns true if the current platform's target env is Musl #[inline] - pub fn is_musl_target(&self) -> bool { + pub fn is_musl_libc(&self) -> bool { matches!( self.env, Environment::Musl diff --git a/tests/common/integration.rs b/tests/common/integration.rs index e3bc2d566..363f6d141 100644 --- a/tests/common/integration.rs +++ b/tests/common/integration.rs @@ -95,7 +95,7 @@ pub fn test_integration( for ((filename, supported_version), python_interpreter) in wheels.iter().zip(interpreter) { if test_zig && build_context.target.is_linux() - && !build_context.target.is_musl_target() + && !build_context.target.is_musl_libc() && build_context.target.get_minimum_manylinux_tag() != PlatformTag::Linux { let rustc_ver = rustc_version::version()?;