unzip: fix configure script when using clang 16

Clang 16 makes implicit int and function declarations an error by
default in any mode except for C89. The configure script has two of
these that cause it to misdetect features when using Clang 16.

* Implicit `int main` in the errno check. This is fixed by adding the
  missing `int`.
* Implicit definitions of `opendir` and `closedir`. These are fixed by
  including the required headers.
This commit is contained in:
Randy Eckenrode
2023-05-31 23:42:53 -04:00
parent 4265b54868
commit 1364837d91
2 changed files with 25 additions and 0 deletions
+4
View File
@@ -60,6 +60,9 @@ stdenv.mkDerivation rec {
];
sha256 = "sha256-on79jElQ+z2ULWAq14RpluAqr9d6itHiZwDkKubBzTc=";
})
# Clang 16 makes implicit declarations an error by default for C99 and newer, causing the
# configure script to fail to detect errno and the directory libraries on Darwin.
./implicit-declarations-fix.patch
] ++ lib.optional enableNLS
(fetchurl {
url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/unzip/files/unzip-6.0-natspec.patch?id=56bd759df1d0c750a065b8c845e93d5dfa6b549d";
@@ -67,6 +70,7 @@ stdenv.mkDerivation rec {
sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1";
});
nativeBuildInputs = [ bzip2 ];
buildInputs = [ bzip2 ] ++ lib.optional enableNLS libnatspec;
@@ -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_