From cd4ab1d9fd9f921451625bc131f8e2d07922ed64 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Wed, 31 May 2023 22:30:43 -0400 Subject: [PATCH] darwin.system_cmds: fix build with clang 16 Clang 16 makes implicit declarations an error by default. The headers are available, so include them. `getline` was renamed to `get_line` to avoid a name clash. `util.h` includes `stdio.h`, which defines `getline`. --- .../system_cmds/default.nix | 7 ++- .../fix-implicit-declarations.patch | 48 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 pkgs/os-specific/darwin/apple-source-releases/system_cmds/fix-implicit-declarations.patch diff --git a/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix index 0c40bc3b18688..f708d77409007 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/system_cmds/default.nix @@ -30,7 +30,12 @@ appleDerivation { "-DAU_SESSION_FLAG_HAS_AUTHENTICATED=0x4000" ] ++ lib.optional (!stdenv.isLinux) " -D__FreeBSD__ "); - patchPhase = '' + patches = [ + # Fix implicit declarations that cause builds to fail when built with clang 16. + ./fix-implicit-declarations.patch + ]; + + postPatch = '' substituteInPlace login.tproj/login.c \ --replace bsm/audit_session.h bsm/audit.h substituteInPlace login.tproj/login_audit.c \ diff --git a/pkgs/os-specific/darwin/apple-source-releases/system_cmds/fix-implicit-declarations.patch b/pkgs/os-specific/darwin/apple-source-releases/system_cmds/fix-implicit-declarations.patch new file mode 100644 index 0000000000000..b08f54045724f --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/system_cmds/fix-implicit-declarations.patch @@ -0,0 +1,48 @@ +diff -ur a/getty.tproj/main.c b/getty.tproj/main.c +--- a/getty.tproj/main.c 2008-06-10 14:50:19.000000000 -0400 ++++ b/getty.tproj/main.c 2023-05-31 18:06:40.121028558 -0400 +@@ -67,6 +67,7 @@ + #include + #include + #include ++#include + #include + + #ifdef __APPLE__ +@@ -152,7 +153,7 @@ + static void putpad(const char *); + static void puts(const char *); + static void timeoverrun(int); +-static char *getline(int); ++static char *get_line(int); + static void setttymode(int); + static int opentty(const char *, int); + +@@ -352,7 +353,7 @@ + if ((fd = open(IF, O_RDONLY)) != -1) { + char * cp; + +- while ((cp = getline(fd)) != NULL) { ++ while ((cp = get_line(fd)) != NULL) { + putf(cp); + } + close(fd); +@@ -744,7 +745,7 @@ + + + static char * +-getline(int fd) ++get_line(int fd) + { + int i = 0; + static char linebuf[512]; +--- a/newgrp.tproj/newgrp.c 2021-10-06 01:38:52.000000000 -0400 ++++ b/newgrp.tproj/newgrp.c 2023-05-31 22:26:50.656157841 -0400 +@@ -47,6 +47,7 @@ + #include + #include + #ifdef __APPLE__ ++#include + #include + #endif /* __APPLE__ */ + static void addgroup(const char *grpname);