From c61c47faf261f2f2f7c8b8247612591fec3f9836 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 26 Jan 2024 11:11:48 +0900 Subject: [PATCH 1/2] Really try dylib when compiling for Apple platforms Really fixes #84. This is what #85 intended, as far as I can tell, but the logic was such that it didn't work for cross-compiles from e.g. Linux (apple_to_apple would be false, leading to the build_zlib path being taken) --- build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 1368a124..13396fb2 100644 --- a/build.rs +++ b/build.rs @@ -67,11 +67,10 @@ fn main() { // Apple platforms have libz.1.dylib, and it's usually available even when // cross compiling (via fat binary or in the target's Xcode SDK) let cross_compiling = target != host; - let apple_to_apple = host.contains("-apple-") && target.contains("-apple-"); if target.contains("msvc") || target.contains("pc-windows-gnu") || want_static - || (cross_compiling && !apple_to_apple) + || (cross_compiling && !target.contains("-apple-")) { return build_zlib(&mut cfg, &target); } From 213574142753055e208d0e946903696d862b412e Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 26 Jan 2024 11:22:47 +0900 Subject: [PATCH 2/2] Disable debug info when compiling smoke test to detect system zlib When compiling for Apple platforms, with the output set to /dev/null, the test fails because clang invokes dsymutil on the output, and that fails on /dev/null. clang doesn't invoke dsymutil if compiling without debug info. --- build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 13396fb2..9bc2d04d 100644 --- a/build.rs +++ b/build.rs @@ -184,7 +184,11 @@ fn try_vcpkg() -> bool { fn zlib_installed(cfg: &mut cc::Build) -> bool { let mut cmd = cfg.get_compiler().to_command(); - cmd.arg("src/smoke.c").arg("-o").arg("/dev/null").arg("-lz"); + cmd.arg("src/smoke.c") + .arg("-g0") + .arg("-o") + .arg("/dev/null") + .arg("-lz"); println!("running {:?}", cmd); if let Ok(status) = cmd.status() {