haskell/zlib

Potential issue building on Windows

Closed this issue · 3 comments

Hello,

Recently, while building cabal-install on Windows, I ran into an issue that had to do with upgrading from 0.6.3.0 to 0.7.0.0.

The saga is here: haskell/cabal#9775

To begin, pkg-config isn't available in the Windows environment used in that CI. Since 0.7.0.0 introduced a default dependency on pkg-config, I updated the Cabal project to use constraints: zlib -pkg-config. No real harm done there.

But then, I got a strange error, possibly when linking cabal-install:

Configuring executable 'cabal' for cabal-install-3.11.0.0..
Preprocessing executable 'cabal' for cabal-install-3.11.0.0..
Building executable 'cabal' for cabal-install-3.11.0.0..
[1 of 1] Compiling Main             ( main\Main.hs, C:\\GitLabRunner\builds\0\1797238\dist-newstyle\build\x86_64-windows\ghc-9.2.3\cabal-install-3.11.0.0\x\cabal\build\cabal\cabal-tmp\Main.o )
Linking C:\\GitLabRunner\\builds\\0\\1797238\\dist-newstyle\\build\\x86_64-windows\\ghc-9.2.3\\cabal-install-3.11.0.0\\x\\cabal\\build\\cabal\\cabal.exe ...
Cleaning up project directory and file based variables
ERROR: Job failed: exit status 127

When I looked into the matter, it looks like 0.6.3.0 uses the bundled C zlib by default on Windows, and 0.7.0.0 did not. By adding constraints: zlib +bundled-c-zlib on the Windows build, I was able to get a successful CI pipeline.

Now, this could simply be an issue with the CI environment, or maybe a bug with GHC (or Cabal) when trying to use the zlib that is bundled with GHC. I'm opening this just for visibility. I won't be looking into this much more myself at the present.

p.s. Rather than writing everything I just wrote, I could have just linked to this commit :)

Now, this could simply be an issue with the CI environment

Indeed so. When extra-libraries: z is not found, Cabal fails during build of zlib itself with something like

Error: [Cabal-4345]
Missing dependency on a foreign library:
* Missing (or bad) C library: z

The fact that it proceeds until linking cabal.exe suggests that something is off with the wider environment: libz.a is present, but unlinkable for some reason. Your choice of GHC 9.2.3 is quite unorthodox, I'd suggest upgrading at least to 9.2.8.

To begin, pkg-config isn't available in the Windows environment used in that CI. Since 0.7.0.0 introduced a default dependency on pkg-config, I updated the Cabal project to use constraints: zlib -pkg-config.

This is an automatic flag. You would not have to do anything manual if you used a more modern version of bootstrap Cabal than 3.6.


Feel free to reopen if there is more specific evidence that it's zlib who is at fault.

Thanks for the pointers. This does not surprise me. I (and others) are independently trying to modernize the release CI for cabal, but it's still WIP.