Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions pkgs/development/libraries/zlib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-mpOyt9/ax3zrpaVYpYDnRmfdb+3kWFuR7vtg8Dty3yM=";
};

patches = [
./mingw-shared.patch
];
Comment on lines +46 to +48

This comment was marked as duplicate.


postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace configure \
--replace '/usr/bin/libtool' '${stdenv.cc.targetPrefix}ar' \
Expand All @@ -58,8 +62,6 @@ stdenv.mkDerivation (finalAttrs: {
setOutputFlags = false;
outputDoc = "dev"; # single tiny man3 page

dontConfigure = stdenv.hostPlatform.isMinGW;

preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
export CHOST=${stdenv.hostPlatform.config}
'';
Expand Down Expand Up @@ -104,7 +106,8 @@ stdenv.mkDerivation (finalAttrs: {
# Non-typical naming confuses libtool which then refuses to use zlib's DLL
# in some cases, e.g. when compiling libpng.
+ lib.optionalString (stdenv.hostPlatform.isMinGW && shared) ''
ln -s zlib1.dll $out/bin/libz.dll
mkdir -p $out/bin
mv $out/lib/*.dll* $out/bin
'';

env =
Expand All @@ -113,7 +116,7 @@ stdenv.mkDerivation (finalAttrs: {
# to the bootstrap-tools libgcc (as uses to happen on arm/mips)
NIX_CFLAGS_COMPILE = "-static-libgcc";
}
// lib.optionalAttrs (stdenv.hostPlatform.linker == "lld") {
// lib.optionalAttrs (stdenv.hostPlatform.linker == "lld" && !stdenv.hostPlatform.isWindows) {
# lld 16 enables --no-undefined-version by default
# This makes configure think it can't build dynamic libraries
# this may be removed when a version is packaged with https://github.com/madler/zlib/issues/960 fixed
Expand All @@ -138,10 +141,6 @@ stdenv.mkDerivation (finalAttrs: {
[
"PREFIX=${stdenv.cc.targetPrefix}"
]
++ lib.optionals stdenv.hostPlatform.isMinGW [
"-f"
"win32/Makefile.gcc"
]
++ lib.optionals shared [
# Note that as of writing (zlib 1.2.11), this flag only has an effect
# for Windows as it is specific to `win32/Makefile.gcc`.
Expand Down
13 changes: 13 additions & 0 deletions pkgs/development/libraries/zlib/mingw-shared.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/configure b/configure
index c55098a..07f7c08 100755
--- a/configure
+++ b/configure
@@ -243,6 +243,8 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log
LDSHARED=${LDSHARED-"$cc -shared"}
LDSHAREDLIBC=""
+ shared_ext='.dll'
+ SHAREDLIB='libz.dll'
EXE='.exe' ;;
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
# (alain.bonnefoy@icbt.com)