From 5beeb455ee48c0f27766bba27d3eb055028c6178 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 27 Oct 2026 03:37:25 +0900 Subject: [PATCH 1/2] compat.fribidi on macOS and Windows; compat.xdmcp without arc4random_buf compat.fribidi declared a Linux build only, so every macOS and Windows build that reaches it (openmui's text engine, pango) stopped at install. fribidi is portable C99 whose tables ship in the tarball and whose two config headers are written out here, so the same tarball serves all three platforms. The generated config.h no longer claims and : lib/common.h would include , which MSVC's headers do not have, and nothing in lib/ uses a function from either. compat.xdmcp declared HAVE_ARC4RANDOM_BUF, which assumes glibc 2.36+; on an older sysroot (the aarch64 one) Key.c's call is an implicit declaration, an error under C11. It now declares getentropy (glibc 2.25+) and lets Key.c's own arc4random_buf emulation use it. --- pkgs/c/compat.fribidi.lua | 27 +++++++++++++++++++++++++-- pkgs/c/compat.xdmcp.lua | 6 +++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pkgs/c/compat.fribidi.lua b/pkgs/c/compat.fribidi.lua index 1ee5351d..f39c588e 100644 --- a/pkgs/c/compat.fribidi.lua +++ b/pkgs/c/compat.fribidi.lua @@ -46,6 +46,9 @@ package = { repo = "https://github.com/fribidi/fribidi", type = "package", + -- One source tarball for every platform: fribidi is portable C99 with no + -- platform probes left (the two config headers below are written out), + -- so macOS and Windows build the same files Linux does. xpm = { linux = { ["1.0.16"] = { @@ -56,6 +59,24 @@ package = { sha256 = "1b1cde5b235d40479e91be2f0e88a309e3214c8ab470ec8a2744d82a5a9ea05c", }, }, + macosx = { + ["1.0.16"] = { + url = { + GLOBAL = "https://github.com/fribidi/fribidi/releases/download/v1.0.16/fribidi-1.0.16.tar.xz", + CN = "https://gitcode.com/mcpp-res/fribidi/releases/download/1.0.16/fribidi-1.0.16.tar.xz", + }, + sha256 = "1b1cde5b235d40479e91be2f0e88a309e3214c8ab470ec8a2744d82a5a9ea05c", + }, + }, + windows = { + ["1.0.16"] = { + url = { + GLOBAL = "https://github.com/fribidi/fribidi/releases/download/v1.0.16/fribidi-1.0.16.tar.xz", + CN = "https://gitcode.com/mcpp-res/fribidi/releases/download/1.0.16/fribidi-1.0.16.tar.xz", + }, + sha256 = "1b1cde5b235d40479e91be2f0e88a309e3214c8ab470ec8a2744d82a5a9ea05c", + }, + }, }, mcpp = { @@ -120,10 +141,12 @@ package = { #define HAVE_STDLIB_H 1 #define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_MEMORY_H 1 #define SIZEOF_INT 4 +/* HAVE_STRINGS_H and HAVE_MEMORY_H are left out: lib/common.h would include + (which MSVC's headers do not have) and , and nothing + in lib/ uses a function from either; covers memcpy and friends. */ + /* HAVE_FRIBIDI_CUSTOM_H and HAVE_FRIBIDI_UNICODE_VERSION_H are DELIBERATELY ABSENT rather than 0. - fribidi_custom.h does not exist here (it is a downstream hook), and diff --git a/pkgs/c/compat.xdmcp.lua b/pkgs/c/compat.xdmcp.lua index 4d27967b..7f97b7d4 100644 --- a/pkgs/c/compat.xdmcp.lua +++ b/pkgs/c/compat.xdmcp.lua @@ -23,7 +23,11 @@ package = { language = "c++23", import_std = false, c_standard = "c11", - cflags = {"-D_GNU_SOURCE", "-D_DEFAULT_SOURCE", "-DHAVE_ARC4RANDOM_BUF=1"}, + -- Key.c emulates arc4random_buf with getentropy (glibc 2.25+) when the + -- libc has no arc4random_buf of its own. Declaring HAVE_ARC4RANDOM_BUF + -- instead assumed glibc 2.36+, which an older sysroot (aarch64) lacks: + -- an implicit declaration, an error under C11. + cflags = {"-D_GNU_SOURCE", "-D_DEFAULT_SOURCE", "-DHAVE_GETENTROPY=1", "-DHAVE_SYS_RANDOM_H=1"}, include_dirs = {"*/include", "*"}, sources = { "*/Array.c", From 53411a24fdc83ca9fcc2a871773ddc6427a11958 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 27 Oct 2026 03:48:42 +0900 Subject: [PATCH 2/2] compat.xdmcp: decide arc4random_buf from the libc, in config.h The x86_64 sysroot's glibc (2.36+) declares arc4random_buf, so Key.c's own static definition conflicts with it; the aarch64 sysroot's older glibc does not, so a fixed HAVE_ARC4RANDOM_BUF is an implicit declaration there. A generated config.h reads the libc's version macros and chooses: the libc's arc4random_buf, or Key.c's emulation over getentropy (glibc 2.25+, musl). --- pkgs/c/compat.xdmcp.lua | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/pkgs/c/compat.xdmcp.lua b/pkgs/c/compat.xdmcp.lua index 7f97b7d4..1f70bc93 100644 --- a/pkgs/c/compat.xdmcp.lua +++ b/pkgs/c/compat.xdmcp.lua @@ -23,12 +23,36 @@ package = { language = "c++23", import_std = false, c_standard = "c11", - -- Key.c emulates arc4random_buf with getentropy (glibc 2.25+) when the - -- libc has no arc4random_buf of its own. Declaring HAVE_ARC4RANDOM_BUF - -- instead assumed glibc 2.36+, which an older sysroot (aarch64) lacks: - -- an implicit declaration, an error under C11. - cflags = {"-D_GNU_SOURCE", "-D_DEFAULT_SOURCE", "-DHAVE_GETENTROPY=1", "-DHAVE_SYS_RANDOM_H=1"}, - include_dirs = {"*/include", "*"}, + -- Whether the libc has arc4random_buf is a property of the sysroot, + -- not of the platform: glibc declares it from 2.36 (the x86_64 + -- sysroot), an older glibc or musl does not (the aarch64 sysroot). + -- Key.c either calls the libc's or defines its own over getentropy, + -- so the choice is made where it can be seen — in config.h below, + -- from the libc's own version macros. A fixed -DHAVE_ARC4RANDOM_BUF + -- breaks the older sysroot (an implicit declaration); leaving it out + -- breaks the newer one (Key.c's static definition conflicts). + cflags = {"-D_GNU_SOURCE", "-D_DEFAULT_SOURCE", "-DHAVE_CONFIG_H"}, + generated_files = { + ["mcpp_generated/config.h"] = [[ +/* compat.xdmcp: the one configure answer the sources depend on. */ +#ifndef MCPP_XDMCP_CONFIG_H +#define MCPP_XDMCP_CONFIG_H +#if defined(__has_include) +# if __has_include() +# include +# endif +#endif +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36)) +# define HAVE_ARC4RANDOM_BUF 1 +#else +/* getentropy: glibc 2.25+, musl 1.1.20+. */ +# define HAVE_GETENTROPY 1 +# define HAVE_SYS_RANDOM_H 1 +#endif +#endif +]], + }, + include_dirs = {"mcpp_generated", "*/include", "*"}, sources = { "*/Array.c", "*/Fill.c",