diff --git a/local/AGENTS.md b/local/AGENTS.md index 6f96e0298..5b6f9f3e2 100644 --- a/local/AGENTS.md +++ b/local/AGENTS.md @@ -3,6 +3,35 @@ This directory contains ALL custom work on top of mainline Redox. When mainline Redox updates (`git pull` on the build system repo), this directory is untouched. +## STUB AND WORKAROUND POLICY — ZERO TOLERANCE + +**Red Bear OS has zero tolerance for stubs, workarounds, `#ifdef`-guarded no-ops, fake headers, +shell-script patches, sed/awk hacks, `LD_PRELOAD` tricks, rename-to-.disabled wrappers, or any +other "make it compile" shortcut.** + +If something doesn't build because of a missing implementation, the ONLY acceptable response is +to implement the missing functionality in the correct component: + +| Problem | Correct Fix | +|---------|-------------| +| `eventfd()` not found | Implement `eventfd()` in relibc, generate `sys/eventfd.h` via cbindgen | +| `signalfd()` not found | Implement `signalfd()` in relibc, generate `sys/signalfd.h` via cbindgen | +| Missing POSIX type | Add it to the relibc header it belongs to, with proper `stdint.h` include chain | +| Compiler can't find header | Fix the include path in the recipe's sysroot/cookbook, NOT by adding `-I` hacks | +| CMake can't find dependency | Implement the dependency or fix pkg-config, NOT with `-DFEATURE_x=OFF` | +| Qt needs `open_memstream` | Implement it in relibc — never add a static stub in Qt or libwayland source | + +**Any stub found in the tree is a bug to be fixed, not a precedent to follow.** + +When relibc gains a function or type that obsoletes a previously-needed local stub, the stub +MUST be removed and the dependency switched to relibc's implementation. Coexistence of stubs +with real implementations causes header conflicts, linker errors, and silent ABI mismatches. + +This applies to: relibc functions, kernel syscalls, C headers, CMake modules, pkg-config `.pc` +files, Wayland protocol stubs, D-Bus service stubs, and any other layer of the stack. + +**No exceptions. No "temporary." No "until we fix it properly."** + ## DESIGN PRINCIPLE Red Bear OS is a **full fork** based on frozen Redox OS snapshots: diff --git a/local/patches/relibc/P3-bits-eventfd-mod.patch b/local/patches/relibc/P3-bits-eventfd-mod.patch new file mode 100644 index 000000000..8aec9ece4 --- /dev/null +++ b/local/patches/relibc/P3-bits-eventfd-mod.patch @@ -0,0 +1,10 @@ +--- a/src/header/mod.rs ++++ b/src/header/mod.rs +@@ -5,6 +5,7 @@ + pub mod arpa_inet; + pub mod assert; + pub mod bits_arpainet; ++pub mod bits_eventfd; + pub mod bits_iovec; + #[path = "bits_locale-t/mod.rs"] + pub mod bits_locale_t; diff --git a/local/patches/relibc/P3-bits-eventfd.patch b/local/patches/relibc/P3-bits-eventfd.patch new file mode 100644 index 000000000..98c66a916 --- /dev/null +++ b/local/patches/relibc/P3-bits-eventfd.patch @@ -0,0 +1,7 @@ +--- /dev/null 2026-05-03 20:55:05.750445686 +0100 ++++ b/src/header/bits_eventfd/mod.rs +@@ -0,0 +1,4 @@ ++//! `bits/eventfd.h` — eventfd counter type. ++ ++use crate::platform::types::uint64_t; ++pub type eventfd_t = uint64_t; diff --git a/local/patches/relibc/P3-eventfd-cbindgen.patch b/local/patches/relibc/P3-eventfd-cbindgen.patch new file mode 100644 index 000000000..5ac92168c --- /dev/null +++ b/local/patches/relibc/P3-eventfd-cbindgen.patch @@ -0,0 +1,19 @@ +diff --git a/src/header/sys_eventfd/cbindgen.toml b/src/header/sys_eventfd/cbindgen.toml +new file mode 100644 +index 00000000..c47f467f +--- /dev/null ++++ b/src/header/sys_eventfd/cbindgen.toml +@@ -0,0 +1,13 @@ ++sys_includes = ["stdint.h"] ++after_includes = """ ++typedef uint64_t eventfd_t; ++int eventfd(unsigned int initval, int flags); ++""" ++include_guard = "_SYS_EVENTFD_H" ++language = "C" ++style = "Tag" ++no_includes = true ++cpp_compat = true ++ ++[enum] ++prefix_with_name = true diff --git a/local/patches/relibc/P3-eventfd-impl.patch b/local/patches/relibc/P3-eventfd-impl.patch new file mode 100644 index 000000000..7e55774d8 --- /dev/null +++ b/local/patches/relibc/P3-eventfd-impl.patch @@ -0,0 +1,40 @@ +--- /dev/null 2026-05-03 20:55:05.750445686 +0100 ++++ b/src/header/sys_eventfd/mod.rs +@@ -0,0 +1,37 @@ ++//! `sys/eventfd.h` implementation — eventfd() with EFD_SEMAPHORE/CLOEXEC/NONBLOCK. ++ ++use alloc::format; ++use crate::c_str::{CStr, CString}; ++use crate::error::{Errno, ResultExt}; ++use crate::header::fcntl::{O_CLOEXEC, O_NONBLOCK, O_RDWR}; ++use crate::header::errno::EINVAL; ++use crate::platform::{Pal, Sys, types::{c_int, c_uint}}; ++ ++pub const EFD_SEMAPHORE: c_int = 1; ++pub const EFD_CLOEXEC: c_int = 0x80000; ++pub const EFD_NONBLOCK: c_int = 0x800; ++ ++pub type eventfd_t = u64; ++ ++#[unsafe(no_mangle)] ++pub extern "C" fn eventfd(initval: c_uint, flags: c_int) -> c_int { ++ let supported = EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE; ++ if flags & !supported != 0 { ++ return Err::(Errno(EINVAL)).or_minus_one_errno(); ++ } ++ let sem = if flags & EFD_SEMAPHORE != 0 { 1 } else { 0 }; ++ let path = format!("/scheme/event/eventfd/{}/{}", initval, sem); ++ let cpath = match CString::new(path) { ++ Ok(p) => p, ++ Err(_) => return Err::(Errno(EINVAL)).or_minus_one_errno(), ++ }; ++ ++ let mut oflag = O_RDWR; ++ if flags & EFD_CLOEXEC == EFD_CLOEXEC { ++ oflag |= O_CLOEXEC; ++ } ++ if flags & EFD_NONBLOCK == EFD_NONBLOCK { ++ oflag |= O_NONBLOCK; ++ } ++ Sys::open(CStr::borrow(&cpath), oflag, 0).or_minus_one_errno() ++} diff --git a/recipes/core/relibc/P3-bits-eventfd-mod.patch b/recipes/core/relibc/P3-bits-eventfd-mod.patch new file mode 120000 index 000000000..083d65e3a --- /dev/null +++ b/recipes/core/relibc/P3-bits-eventfd-mod.patch @@ -0,0 +1 @@ +../../../local/patches/relibc/P3-bits-eventfd-mod.patch \ No newline at end of file diff --git a/recipes/core/relibc/P3-bits-eventfd.patch b/recipes/core/relibc/P3-bits-eventfd.patch new file mode 120000 index 000000000..ab518c9b1 --- /dev/null +++ b/recipes/core/relibc/P3-bits-eventfd.patch @@ -0,0 +1 @@ +../../../local/patches/relibc/P3-bits-eventfd.patch \ No newline at end of file diff --git a/recipes/core/relibc/P3-eventfd-cbindgen.patch b/recipes/core/relibc/P3-eventfd-cbindgen.patch new file mode 120000 index 000000000..e626c9ee8 --- /dev/null +++ b/recipes/core/relibc/P3-eventfd-cbindgen.patch @@ -0,0 +1 @@ +../../../local/patches/relibc/P3-eventfd-cbindgen.patch \ No newline at end of file diff --git a/recipes/core/relibc/P3-eventfd-impl.patch b/recipes/core/relibc/P3-eventfd-impl.patch new file mode 120000 index 000000000..3396b6f87 --- /dev/null +++ b/recipes/core/relibc/P3-eventfd-impl.patch @@ -0,0 +1 @@ +../../../local/patches/relibc/P3-eventfd-impl.patch \ No newline at end of file diff --git a/recipes/core/relibc/recipe.toml b/recipes/core/relibc/recipe.toml index 6f303b9a6..91fab7178 100644 --- a/recipes/core/relibc/recipe.toml +++ b/recipes/core/relibc/recipe.toml @@ -2,10 +2,15 @@ git = "https://gitlab.redox-os.org/redox-os/relibc.git" rev = "861bbb0" patches = [ - # Module declarations (pub mod sys_eventfd/signalfd/timerfd in header/mod.rs) "P3-eventfd-mod.patch", - # sys_eventfd module (constants only — libwayland has its own eventfd()) - "P3-sys-eventfd-create.patch", + # Add pub mod bits_eventfd to header/mod.rs + "P3-bits-eventfd-mod.patch", + # bits_eventfd module (eventfd_t type) + "P3-bits-eventfd.patch", + # sys_eventfd module — FULL eventfd() implementation (opens /scheme/event/eventfd) + "P3-eventfd-impl.patch", + # cbindgen.toml for sys/eventfd.h C header generation + "P3-eventfd-cbindgen.patch", # sys_signalfd module (cbindgen.toml + mod.rs with cbindgen exports) "P3-signalfd-header.patch", # signalfd implementation (signal/signalfd.rs + signal/mod.rs wiring)