mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-22 20:14:37 +00:00
zip: fix build with clang 16
Fix implicit declarations of `memset` and `open/closedir` resulting in incorrect feature detection and conflicts with libc headers.
This commit is contained in:
parent
72d5519b60
commit
c407e3cbba
@ -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;
|
||||
|
21
pkgs/tools/archivers/zip/fix-implicit-declarations.patch
Normal file
21
pkgs/tools/archivers/zip/fix-implicit-declarations.patch
Normal file
@ -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_
|
||||
|
||||
|
15
pkgs/tools/archivers/zip/fix-memset-detection.patch
Normal file
15
pkgs/tools/archivers/zip/fix-memset-detection.patch
Normal file
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user