about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/archivers/zip
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/archivers/zip')
-rw-r--r--nixpkgs/pkgs/tools/archivers/zip/default.nix12
-rw-r--r--nixpkgs/pkgs/tools/archivers/zip/fix-implicit-declarations.patch21
-rw-r--r--nixpkgs/pkgs/tools/archivers/zip/fix-memset-detection.patch15
3 files changed, 46 insertions, 2 deletions
diff --git a/nixpkgs/pkgs/tools/archivers/zip/default.nix b/nixpkgs/pkgs/tools/archivers/zip/default.nix
index 82329537251e..1ac615a3d90f 100644
--- a/nixpkgs/pkgs/tools/archivers/zip/default.nix
+++ b/nixpkgs/pkgs/tools/archivers/zip/default.nix
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
     ];
     sha256 = "0sb3h3067pzf3a7mlxn1hikpcjrsvycjcnj9hl9b1c3ykcgvps7h";
   };
-  patchPhase = ''
+  prePatch = ''
     substituteInPlace unix/Makefile --replace 'CC = cc' ""
   '';
 
@@ -26,7 +26,14 @@ stdenv.mkDerivation rec {
     "INSTALL=cp"
   ];
 
-  patches = lib.optionals (enableNLS && !stdenv.isCygwin) [ ./natspec-gentoo.patch.bz2 ];
+  patches = [
+    # Trying to use `memset` without declaring it is flagged as an error with clang 16, causing
+    # the `configure` script to incorrectly define `ZMEM`. That causes the build to fail due to
+    # incompatible redeclarations of `memset`, `memcpy`, and `memcmp` in `zip.h`.
+    ./fix-memset-detection.patch
+    # Implicit declaration of `closedir` and `opendir` cause dirent detection to fail with clang 16.
+    ./fix-implicit-declarations.patch
+  ] ++ lib.optionals (enableNLS && !stdenv.isCygwin) [ ./natspec-gentoo.patch.bz2 ];
 
   buildInputs = lib.optional enableNLS libnatspec
     ++ lib.optional stdenv.isCygwin libiconv;
@@ -37,5 +44,6 @@ stdenv.mkDerivation rec {
     license = licenses.bsdOriginal;
     platforms = platforms.all;
     maintainers = [ ];
+    mainProgram = "zip";
   };
 }
diff --git a/nixpkgs/pkgs/tools/archivers/zip/fix-implicit-declarations.patch b/nixpkgs/pkgs/tools/archivers/zip/fix-implicit-declarations.patch
new file mode 100644
index 000000000000..df19bf1722f9
--- /dev/null
+++ b/nixpkgs/pkgs/tools/archivers/zip/fix-implicit-declarations.patch
@@ -0,0 +1,21 @@
+--- a/unix/configure	2009-04-16 15:25:12.000000000 -0400
++++ b/unix/configure	2023-05-30 15:18:33.670321348 -0400
+@@ -408,7 +408,7 @@
+ echo Check for errno declaration
+ cat > conftest.c << _EOF_
+ #include <errno.h>
+-main()
++int main()
+ {
+   errno = 0;
+   return 0;
+@@ -419,6 +419,8 @@
+ 
+ echo Check for directory libraries
+ cat > conftest.c << _EOF_
++#include <sys/types.h>
++#include <dirent.h>
+ int main() { return closedir(opendir(".")); }
+ _EOF_
+ 
+
diff --git a/nixpkgs/pkgs/tools/archivers/zip/fix-memset-detection.patch b/nixpkgs/pkgs/tools/archivers/zip/fix-memset-detection.patch
new file mode 100644
index 000000000000..55bda33a2573
--- /dev/null
+++ b/nixpkgs/pkgs/tools/archivers/zip/fix-memset-detection.patch
@@ -0,0 +1,15 @@
+diff -ur a/unix/configure b/unix/configure
+--- a/unix/configure	2008-06-19 21:32:20.000000000 -0600
++++ b/unix/configure	2023-07-11 10:02:57.809867694 -0600
+@@ -519,7 +519,10 @@
+ 
+ 
+ echo Check for memset
+-echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
++cat > conftest.c << _EOF_
++#include <string.h>
++int main(){ char k; memset(&k,0,0); return 0; }
++_EOF_
+ $CC -o conftest conftest.c >/dev/null 2>/dev/null
+ [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"
+