From 9371fe7e762261b51a119073dd1f3067af5bda95 Mon Sep 17 00:00:00 2001 From: Vasilito Date: Sat, 2 May 2026 22:10:00 +0100 Subject: [PATCH] fix: preserve relibc and wayland build surfaces --- local/patches/libwayland/redox.patch | 15 --- .../P0-strtold-cpp-linkage-and-compat.patch | 106 ++++++++++++++++++ local/patches/relibc/P3-threads.patch | 7 +- recipes/wip/wayland/libwayland/recipe.toml | 13 ++- 4 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 local/patches/relibc/P0-strtold-cpp-linkage-and-compat.patch diff --git a/local/patches/libwayland/redox.patch b/local/patches/libwayland/redox.patch index 81799a01..68a5b3e0 100644 --- a/local/patches/libwayland/redox.patch +++ b/local/patches/libwayland/redox.patch @@ -1,18 +1,3 @@ ---- a/src/connection.c -+++ b/src/connection.c -@@ -40,6 +40,12 @@ - #include - #include - -+#ifndef MSG_NOSIGNAL -+#define MSG_NOSIGNAL 0 -+#endif -+ -+extern FILE *open_memstream(char **bufp, size_t *sizep); -+ - #include "wayland-util.h" - #include "wayland-private.h" - #include "wayland-os.h" --- a/src/meson.build +++ b/src/meson.build @@ -81,8 +81,7 @@ diff --git a/local/patches/relibc/P0-strtold-cpp-linkage-and-compat.patch b/local/patches/relibc/P0-strtold-cpp-linkage-and-compat.patch new file mode 100644 index 00000000..cf8ad193 --- /dev/null +++ b/local/patches/relibc/P0-strtold-cpp-linkage-and-compat.patch @@ -0,0 +1,106 @@ +diff --git a/include/features.h b/include/features.h +index 6d0a0d6..d14516f 100644 +--- a/include/features.h ++++ b/include/features.h +@@ -14,6 +14,11 @@ + #define __RELIBC__MAJOR 0 + #define __RELIBC__MINOR 2 + ++#ifndef __RELIBC_C_LONGDOUBLE_DEFINED ++#define __RELIBC_C_LONGDOUBLE_DEFINED 1 ++typedef long double c_longdouble; ++#endif ++ + /* + * Sources: + * https://en.cppreference.com/w/c/language/attributes +diff --git a/include/stddef.h b/include/stddef.h +index 334267f..bb58d55 100644 +--- a/include/stddef.h ++++ b/include/stddef.h +@@ -11,6 +11,11 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; + + typedef long unsigned int size_t; + ++#ifndef __RELIBC_C_LONGDOUBLE_DEFINED ++#define __RELIBC_C_LONGDOUBLE_DEFINED 1 ++typedef long double c_longdouble; ++#endif ++ + typedef struct { long long __ll; long double __ld; } max_align_t; + + #define offsetof(type, member) __builtin_offsetof(type, member) +diff --git a/src/c/stdlib.c b/src/c/stdlib.c +index 62e9810..4040655 100644 +--- a/src/c/stdlib.c ++++ b/src/c/stdlib.c +@@ -1,9 +1,5 @@ + double strtod(const char *nptr, char **endptr); + +-long double strtold(const char *nptr, char **endptr) { +- return (long double)strtod(nptr, endptr); +-} +- + double relibc_ldtod(const long double* val) { + return (double)(*val); + } +diff --git a/src/header/stdlib/cbindgen.toml b/src/header/stdlib/cbindgen.toml +index c105da5..d5bcb23 100644 +--- a/src/header/stdlib/cbindgen.toml ++++ b/src/header/stdlib/cbindgen.toml +@@ -1,21 +1,5 @@ + sys_includes = ["stddef.h", "alloca.h", "wchar.h", "features.h"] + include_guard = "_RELIBC_STDLIB_H" +-trailer = """ +-#ifndef _RELIBC_STDLIB_EXTRA_H +-#define _RELIBC_STDLIB_EXTRA_H +- +-#ifdef __cplusplus +-extern "C" { +-#endif +- +-long double strtold(const char *nptr, char **endptr); +- +-#ifdef __cplusplus +-} +-#endif +- +-#endif +-""" + language = "C" + style = "Type" + no_includes = true +diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs +index 423ee95..43bc912 100644 +--- a/src/header/stdlib/mod.rs ++++ b/src/header/stdlib/mod.rs +@@ -31,7 +31,7 @@ use crate::{ + platform::{ + self, Pal, Sys, + types::{ +- c_char, c_double, c_float, c_int, c_long, c_longlong, c_uint, c_ulong, c_ulonglong, ++ c_char, c_double, c_float, c_int, c_long, c_longdouble, c_longlong, c_uint, c_ulong, c_ulonglong, + c_ushort, c_void, size_t, ssize_t, uintptr_t, wchar_t, + }, + }, +@@ -1490,12 +1494,19 @@ pub unsafe extern "C" fn strtod(s: *const c_char, endptr: *mut *mut c_char) -> c + strto_float_impl!(c_double, s, endptr) + } + +-/// See . ++/// See . + #[unsafe(no_mangle)] + pub unsafe extern "C" fn strtof(s: *const c_char, endptr: *mut *mut c_char) -> c_float { + strto_float_impl!(c_float, s, endptr) + } + ++/// See . ++#[unsafe(no_mangle)] ++pub unsafe extern "C" fn strtold(s: *const c_char, endptr: *mut *mut c_char) -> c_longdouble { ++ let result = unsafe { strtod(s, core::ptr::null_mut()) }; ++ result as c_longdouble ++} ++ + /// See . + #[unsafe(no_mangle)] + pub unsafe extern "C" fn strtol(s: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_long { diff --git a/local/patches/relibc/P3-threads.patch b/local/patches/relibc/P3-threads.patch index 60ff34c9..e33985a2 100644 --- a/local/patches/relibc/P3-threads.patch +++ b/local/patches/relibc/P3-threads.patch @@ -26,7 +26,7 @@ new file mode 100644 index 0000000..9ab9496 --- /dev/null +++ b/src/header/threads/mod.rs -@@ -0,0 +1,31 @@ +@@ -0,0 +1,36 @@ +//! `threads.h` implementation — C11 threads type definitions and constants. +//! +//! Full C11 threads API (thrd_create, mtx_lock, cnd_wait, etc.) requires @@ -58,3 +58,8 @@ index 0000000..9ab9496 + +#[unsafe(no_mangle)] +pub unsafe extern "C" fn thrd_yield() {} ++ ++#[unsafe(no_mangle)] ++pub unsafe extern "C" fn thrd_exit(_ret: *mut c_int) -> ! { ++ loop {} ++} diff --git a/recipes/wip/wayland/libwayland/recipe.toml b/recipes/wip/wayland/libwayland/recipe.toml index b61a0bb4..e529b31b 100644 --- a/recipes/wip/wayland/libwayland/recipe.toml +++ b/recipes/wip/wayland/libwayland/recipe.toml @@ -1,6 +1,6 @@ -#TODO: Requires Redox compatibility patching for missing Linux header paths and -# some POSIX/Linux-only flags during cross-builds. -# redox.patch restores the Redox compatibility stubs plus Meson scanner detection. +#TODO: Requires a narrow Redox delta for native scanner discovery during +# cross-builds and a userspace eventfd fallback because relibc lacks sys/eventfd.h. +# redox.patch keeps only the active scanner/eventfd compatibility surface. [source] tar = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.24.0/downloads/wayland-1.24.0.tar.xz" patches = ["redox.patch"] @@ -26,7 +26,12 @@ COOKBOOK_MESON_FLAGS=( -Ddefault_library=static -Dprefix=/usr ) -cookbook_meson -Ddocumentation=false -Dtests=false -Ddtd_validation=false -Dscanner=false -Dc_args=-Wno-error +cookbook_meson \ + -Ddocumentation=false \ + -Dtests=false \ + -Ddtd_validation=false \ + -Dscanner=false \ + -Dc_args="['-I${COOKBOOK_SYSROOT}/include','-Wno-error']" for pc in "${COOKBOOK_STAGE}/usr/lib/pkgconfig/wayland-client.pc" "${COOKBOOK_STAGE}/usr/lib/pkgconfig/wayland-server.pc"; do if [ -f "$pc" ]; then