From 80e5a0c061aeeae10d01353146ef1749b8364e29 Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:38:04 +0200 Subject: [PATCH] Do not check pkg-config when cross-compiling for android/haiku Currently when compiling for android/haiku target we check pkg-config for zlib then fallback to using shipped zlib, this can cause problems as pkg-config sometimes returns host's zlib. This patch makes it to always use shipped zlib instead of pkg-config one. Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- build.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index 1472639e..cab160ae 100644 --- a/build.rs +++ b/build.rs @@ -22,6 +22,14 @@ fn main() { return build_zlib_ng(&target, true); } + // All android compilers should come with libz by default, so let's just use + // the one already there. Likewise, Haiku always ships with libz, so we can + // link to it even when cross-compiling. + if target.contains("android") || target.contains("haiku") { + println!("cargo:rustc-link-lib=z"); + return; + } + // Don't run pkg-config if we're linking statically (we'll build below) and // also don't run pkg-config on FreeBSD/DragonFly. That'll end up printing // `-L /usr/lib` which wreaks havoc with linking to an OpenSSL in /usr/local/lib @@ -63,14 +71,6 @@ fn main() { } } - // All android compilers should come with libz by default, so let's just use - // the one already there. Likewise, Haiku always ships with libz, so we can - // link to it even when cross-compiling. - if target.contains("android") || target.contains("haiku") { - println!("cargo:rustc-link-lib=z"); - return; - } - let mut cfg = cc::Build::new(); // Situations where we build unconditionally.