diff --git a/local/AGENTS.md b/local/AGENTS.md index aa5e5baf81..4747bd114f 100644 --- a/local/AGENTS.md +++ b/local/AGENTS.md @@ -907,6 +907,7 @@ This rule applies to ALL Cat 2 fork crates: | `libredox` | `local/sources/libredox/` | `path = "../../../../../local/sources/libredox"` | | `redox-scheme` | `local/sources/redox-scheme/` | `path = "../../../../../local/sources/redox-scheme"` | | `redoxfs` | `local/sources/redoxfs/` | `path = "../../../../../local/sources/redoxfs"` | +| `libc` | `local/sources/libc/` | via `[patch.crates-io]` in the rust workspace — **temporary**, see `local/docs/VENDORED-LIBC-FORK.md` | **Correct pattern (path dep):** ```toml diff --git a/local/docs/VENDORED-LIBC-FORK.md b/local/docs/VENDORED-LIBC-FORK.md new file mode 100644 index 0000000000..a9c80ce601 --- /dev/null +++ b/local/docs/VENDORED-LIBC-FORK.md @@ -0,0 +1,85 @@ +# Vendored `libc` Fork — Redox `waitid` Surface + +**Status:** TEMPORARY. Vendored for as long as it is required; delete once +upstream `libc` carries the Redox bindings. +**Location:** `local/sources/libc/` +**Base:** crates.io `libc` 0.2.189, unmodified except `src/unix/redox/mod.rs`. +**Established:** 2026-08-03. + +Related: `LOCAL-FORK-SUPREMACY-POLICY.md`, `FORK-BUMP-PATCHING-POLICY.md`, +`local/AGENTS.md` § "Local fork dependency rule". + +--- + +## Why this fork exists + +relibc implements the POSIX `waitid` surface in full, but the `libc` crate's +Redox bindings never exposed it — and still do not as of 0.2.189. Any crate +that calls `waitid` therefore cannot build for `x86_64-unknown-redox`: + +``` +error[E0531]: cannot find unit struct, unit variant or constant + `CLD_EXITED` in crate `libc` +error[E0531]: cannot find unit struct, unit variant or constant + `P_ALL` in crate `libc` +``` + +That breaks `nix`, and through it `ctrlc` and rustc's bootstrap tooling — which +is what blocked `rust-native`, and with it the whole native toolchain +(`gcc-native`, `llvm-native`, `rust-native`) that `config/redbear-full.toml` +requires. + +This is a **binding gap, not a missing implementation**. Every symbol added +here is already real in relibc: + +| Symbol | relibc source | Evidence | +|---|---|---| +| `waitid()` | `src/header/sys_wait/mod.rs:153` | `nm libc.a` → `T waitid` | +| `idtype_t` | `src/header/sys_wait/mod.rs:17` | `pub type idtype_t = c_int` | +| `P_ALL` / `P_PID` / `P_PGID` | `src/header/sys_wait/mod.rs:20-24` | `0` / `1` / `2` | +| `CLD_*` (6) | `include/signal.h:457-467` | `CLD_EXITED 1` … `CLD_CONTINUED 6` | + +Values and types are taken from **relibc**, not from Linux. Redox's `idtype_t` +is `c_int` where glibc uses an enum, and copying the Linux definitions would +have produced a silently wrong ABI. + +## What is actually changed + +One file: `src/unix/redox/mod.rs`. Every other target is byte-for-byte upstream +0.2.189, so host builds and all non-Redox targets are unaffected. + +## How it is wired + +`[patch.crates-io]` in the rust workspace, carried durably as +`local/patches/rust/02-libc-redox-fork.patch`: + +```toml +libc = { path = "../../../../local/sources/libc" } +``` + +`+rb` build metadata is what makes this safe: it leaves the upstream semver +(`0.2.189`) intact, so `^0.2` requirements still resolve. A `-rb` suffix would +be read as a pre-release and fail to satisfy them — see `local/AGENTS.md` +§ "Version conventions". + +Registered in `local/fork-upstream-map.toml` as a `snapshot` fork (its history +comes from the registry, not a git clone), with `src/unix/redox/mod.rs` on the +declarative expected-differ list in `verify-fork-versions.sh` so the content +check stays meaningful rather than being blanket-skipped. + +## Retiring this fork + +Upstream-reportable: the gap belongs in the `libc` crate. When upstream exposes +the Redox `waitid` surface: + +1. Confirm `CLD_*`, `P_*`, `idtype_t` and `waitid` are all present in + `src/unix/redox/mod.rs` for the version being resolved. +2. Drop `02-libc-redox-fork.patch` from `recipes/dev/rust/recipe.toml`. +3. Remove the `libc` row from `local/fork-upstream-map.toml` and both + `libc)` arms from `verify-fork-versions.sh`. +4. Delete `local/sources/libc/`. +5. Rebuild `rust-native` to confirm `nix` still compiles. + +Until then this fork stays. Bumping it follows +`FORK-BUMP-PATCHING-POLICY.md`: re-vendor the newer upstream and re-apply the +Redox block — never carry the old base forward. diff --git a/local/fork-upstream-map.toml b/local/fork-upstream-map.toml index c93fe0e1a7..6bc091b365 100644 --- a/local/fork-upstream-map.toml +++ b/local/fork-upstream-map.toml @@ -39,3 +39,9 @@ bootloader https://gitlab.redox-os.org/redox-os/bootloader.git 1.0.0 div installer https://gitlab.redox-os.org/redox-os/installer.git 0.2.42 diverged # fork has TUI GUI + Red Bear config additions not in upstream 0.2.42 -- content check advisory only; full rebase is Phase 2.4+ work userutils https://gitlab.redox-os.org/redox-os/userutils.git 0.1.0 snapshot base https://gitlab.redox-os.org/redox-os/base.git main tracked +# Vendored from the crates.io registry (unrelated git history -> snapshot). +# Divergence is confined to src/unix/redox/mod.rs, which exposes the waitid +# surface relibc already implements and the libc crate still omits as of +# 0.2.189. TEMPORARY: drop this fork once upstream libc carries the Redox +# bindings. See local/docs/VENDORED-LIBC-FORK.md. +libc https://github.com/rust-lang/libc.git 0.2.189 snapshot diff --git a/local/scripts/verify-fork-versions.sh b/local/scripts/verify-fork-versions.sh index 9531b50be8..ef8d1d35a3 100755 --- a/local/scripts/verify-fork-versions.sh +++ b/local/scripts/verify-fork-versions.sh @@ -190,7 +190,8 @@ for fork_dir in local/sources/*/; do # whose local-patches/ dir is empty but the fork has legitimately # diverged via direct commits need explicit entries here. case "$fork_name" in - libredox) expected_differ+=("src/lib.rs") ;; # F_DUPFD_CLOEXEC + AcpiVerb at commit 6908adc + libredox) expected_differ+=("src/lib.rs") ;; + libc) expected_differ+=("src/unix/redox/mod.rs") ;; # waitid/CLD_*/P_* surface # F_DUPFD_CLOEXEC + AcpiVerb at commit 6908adc redoxfs) expected_differ+=("src/filesystem.rs" "src/record.rs" \ "src/mount/redox/mod.rs" "src/mount/redox/scheme.rs") ;; # filesystem.rs + record.rs: a936d00 (Red Bear) import Vec from @@ -241,7 +242,8 @@ for fork_dir in local/sources/*/; do # local-patches/ dir is empty (no patch files) but the fork # itself has legitimately diverged via direct commits. case "$fork_name" in - libredox) patch_modified_files+=("src/lib.rs") ;; # F_DUPFD_CLOEXEC + AcpiVerb + libredox) patch_modified_files+=("src/lib.rs") ;; + libc) patch_modified_files+=("src/unix/redox/mod.rs") ;; # F_DUPFD_CLOEXEC + AcpiVerb redoxfs) patch_modified_files+=("src/filesystem.rs" "src/record.rs" \ "src/mount/redox/mod.rs" "src/mount/redox/scheme.rs") ;; esac