From 527daeec1ff5a62dc100ad581a2c67b777081aff Mon Sep 17 00:00:00 2001
From: Bryan Richter <bryan@haskell.foundation>
Date: Mon, 4 Mar 2024 14:26:46 +0200
Subject: [PATCH] Tell zlib not to use pkg-config in GitLab CI.

(cherry picked from commit 62c74fe15bc4cbd915ea26dbc9e37a9f05efa490)
---
 .gitlab/ci.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index 737bbede17..9966bb86f6 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -34,6 +34,22 @@ if [ "$(getconf LONG_BIT)" = "32" -o "${PLATFORM:=xxx}" = "x86_64-linux-centos7"
     echo 'constraints: lukko -ofd-locking' >> cabal.project.release.local
 fi
 
+# In February 2024, cabal started using zlib-0.7.0.0, which uses pkg-config by
+# default. The GitLab CI environment doesn't (yet) supply pkg-config, and zlib
+# does just fine without it on modern GHCs. That said, the CI environment
+# probably *should* have pkg-config installed. See
+# https://github.com/haskell/cabal/issues/9774.
+echo 'constraints: zlib -pkg-config' >> cabal.project.release.local
+# Furthermore, on Windows, zlib claims that libz is shipped with GHC, so it just
+# uses @extra-libraries: z@ if pkg-config is False. If you are reading this
+# comment, however, this didn't work. Thus we switch to using the bundled libz,
+# as was done in zlib <0.7.0.0.
+case "$(uname)" in
+    MSYS_*|MINGW*)
+        echo 'constraints: zlib +bundled-c-zlib' >> cabal.project.release.local
+    ;;
+esac
+
 args=(
     --disable-profiling
     --enable-executable-stripping
-- 
GitLab