diff options
author | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2023-08-06 01:06:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-06 01:06:13 +0200 |
commit | 00caa4926c704a3dc8f11d7511ac2f4e29e1acb6 (patch) | |
tree | 316c6da1892671e4214a214ff67791aeb824815c /pkgs/tools/archivers | |
parent | e02790cc08f6d746b013f7b601c22d747288570a (diff) | |
parent | c407e3cbbaaba05db64c8e1ec929c75cfa4eba50 (diff) | |
download | nixlib-00caa4926c704a3dc8f11d7511ac2f4e29e1acb6.tar nixlib-00caa4926c704a3dc8f11d7511ac2f4e29e1acb6.tar.gz nixlib-00caa4926c704a3dc8f11d7511ac2f4e29e1acb6.tar.bz2 nixlib-00caa4926c704a3dc8f11d7511ac2f4e29e1acb6.tar.lz nixlib-00caa4926c704a3dc8f11d7511ac2f4e29e1acb6.tar.xz nixlib-00caa4926c704a3dc8f11d7511ac2f4e29e1acb6.tar.zst nixlib-00caa4926c704a3dc8f11d7511ac2f4e29e1acb6.zip |
Merge pull request #246670 from reckenrode/zip-clang16
zip: fix build with clang 16
Diffstat (limited to 'pkgs/tools/archivers')
-rw-r--r-- | pkgs/tools/archivers/zip/default.nix | 11 | ||||
-rw-r--r-- | pkgs/tools/archivers/zip/fix-implicit-declarations.patch | 21 | ||||
-rw-r--r-- | pkgs/tools/archivers/zip/fix-memset-detection.patch | 15 |
3 files changed, 45 insertions, 2 deletions
diff --git a/pkgs/tools/archivers/zip/default.nix b/pkgs/tools/archivers/zip/default.nix index 82329537251e..75a7c81f3276 100644 --- a/pkgs/tools/archivers/zip/default.nix +++ b/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; diff --git a/pkgs/tools/archivers/zip/fix-implicit-declarations.patch b/pkgs/tools/archivers/zip/fix-implicit-declarations.patch new file mode 100644 index 000000000000..df19bf1722f9 --- /dev/null +++ b/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/pkgs/tools/archivers/zip/fix-memset-detection.patch b/pkgs/tools/archivers/zip/fix-memset-detection.patch new file mode 100644 index 000000000000..55bda33a2573 --- /dev/null +++ b/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" + |