getopt: fix build on clang 16

Normally, when getopt builds on a non-glibc platform, it uses C library
headers without including them. That’s fine unless your compiler is
clang 16, which is strict about using functions without prototypes.
Fortunately, Darwin’s headers are compatible enough as are Musl’s, so
defining `__GNU_LIBRARY__` can be done unconditionally.
This commit is contained in:
Randy Eckenrode 2023-06-01 18:50:02 -04:00
parent 323e9a44c2
commit b7d4d9f519
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9

View File

@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
sha256 = "1zn5kp8ar853rin0ay2j3p17blxy16agpp8wi8wfg4x98b31vgyh"; sha256 = "1zn5kp8ar853rin0ay2j3p17blxy16agpp8wi8wfg4x98b31vgyh";
}; };
# This should be fine on Linux and Darwin. Clang 16 requires it because otherwise getopt will
# attempt to use C library functions without declaring them, which is raised as an error.
env.NIX_CFLAGS_COMPILE = "-D__GNU_LIBRARY__";
makeFlags = [ makeFlags = [
"WITHOUT_GETTEXT=1" "WITHOUT_GETTEXT=1"
"LIBCGETOPT=0" "LIBCGETOPT=0"