From 2f6c560002f11c5d6e60b1eeeb6896dbc50d48bd Mon Sep 17 00:00:00 2001 From: mnikic Date: Sun, 12 Apr 2026 05:07:15 -0700 Subject: [PATCH] build: support GNU Hurd by skipping BSD sysctl checks #38975 Problem: Neovim currently fails to build on GNU Hurd. Because Hurd relies on glibc, `` defines the `BSD` macro for 4.4BSD compatibility. The preprocessor incorrectly routes Hurd into the BSD code paths, which fatally fail during compilation because Hurd lacks `` and the `sysctl()` function. Solution: Update the preprocessor guards in `os/proc.c` to explicitly exclude `__gnu_hurd__` from the BSD-specific `sysctl` blocks. Instead, group GNU Hurd with the `__linux__` paths, as both systems rely on standard POSIX interfaces and `/proc` parsing (which Hurd fully supports via its `procfs` translator). Testing: The test suite does not fully pass yet natively on GNU Hurd (specifically tests involving PTY closures and SIGHUP/SIGTERM trapping, like `autocmd TermClose kills PTY job`). This is due to underlying differences in Hurd's Mach RPC architecture and the `term` translator. This patch does not attempt to fix those test executions, but simply unblocks the core compiler as a necessary first step. --- src/nvim/os/proc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nvim/os/proc.c b/src/nvim/os/proc.c index 5e87f09a93..275a82c41c 100644 --- a/src/nvim/os/proc.c +++ b/src/nvim/os/proc.c @@ -25,13 +25,15 @@ # include #endif -#if defined(__APPLE__) || defined(BSD) +// Exclude GNU Hurd since glibc defines BSD but lacks sysctl.h +#if defined(__APPLE__) || (defined(BSD) && !defined(__gnu_hurd__)) # include # include "nvim/macros_defs.h" #endif -#if defined(__linux__) +// Group Hurd with Linux, as both use glibc and standard POSIX interfaces here +#if defined(__linux__) || defined(__gnu_hurd__) # include #endif @@ -147,7 +149,7 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count) } while (Process32Next(h, &pe)); CloseHandle(h); -#elif defined(__APPLE__) || defined(BSD) +#elif defined(__APPLE__) || (defined(BSD) && !defined(__gnu_hurd__)) # if defined(__APPLE__) # define KP_PID(o) o.kp_proc.p_pid # define KP_PPID(o) o.kp_eproc.e_ppid @@ -201,7 +203,7 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count) return 1; // Process not found. } -#elif defined(__linux__) +#elif defined(__linux__) || defined(__gnu_hurd__) char proc_p[256] = { 0 }; // Collect processes whose parent matches `ppid`. // Rationale: children are defined in thread with same ID of process.