summary refs log tree commit diff
path: root/pkgs/tools/misc/getopt
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-06-01 18:50:02 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2023-06-01 21:02:49 -0400
commitb7d4d9f519342669406874b78fbcf7f28384f39a (patch)
tree76c11d47a2fa432eea9c30385647c136e714beb4 /pkgs/tools/misc/getopt
parent323e9a44c251f87da3b77087b9e1f6f36eb719f8 (diff)
downloadnixpkgs-b7d4d9f519342669406874b78fbcf7f28384f39a.tar
nixpkgs-b7d4d9f519342669406874b78fbcf7f28384f39a.tar.gz
nixpkgs-b7d4d9f519342669406874b78fbcf7f28384f39a.tar.bz2
nixpkgs-b7d4d9f519342669406874b78fbcf7f28384f39a.tar.lz
nixpkgs-b7d4d9f519342669406874b78fbcf7f28384f39a.tar.xz
nixpkgs-b7d4d9f519342669406874b78fbcf7f28384f39a.tar.zst
nixpkgs-b7d4d9f519342669406874b78fbcf7f28384f39a.zip
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.
Diffstat (limited to 'pkgs/tools/misc/getopt')
-rw-r--r--pkgs/tools/misc/getopt/default.nix4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkgs/tools/misc/getopt/default.nix b/pkgs/tools/misc/getopt/default.nix
index c3b94465aea..2090fcbd7aa 100644
--- a/pkgs/tools/misc/getopt/default.nix
+++ b/pkgs/tools/misc/getopt/default.nix
@@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
     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 = [
     "WITHOUT_GETTEXT=1"
     "LIBCGETOPT=0"