roadmap BUILT

835. A C library, stage 1: files, clock and memory

(The file name is provisional.)

calef chose relibc for nife's C library on 2026-10-08 (UTC), expecting "we end up building our own with a similar approach". §265 (a C library started from relibc) records the ruling. notes/c-library.md is the evaluation this stage is shaped by: take relibc's OS-neutral code and its Pal seam once, into an in-tree crate nife owns, and write the nife platform layer in Rust. This stage is the smallest library that runs a real C benchmark unmodified.

First consumers

Numbered as PR #1854 mints them, provisionally: ioping (834), SQLite's speedtest1 (831) and STREAM (832). Each needs files or memory and a clock, and none needs threads, sockets or a second process. STREAM's number means little until the userspace targets stop being softfloat (that is milestone 534 (the soft-float targets could now be flipped)); it can still run first, as the library's simplest workload.

Reuse: relibc (MIT), chosen by calef on 2026-10-08 over musl and picolibc/newlib; its OS-neutral header code and Pal seam are seeded, its Redox runtime, dynamic linker and dlmalloc are not (notes/c-library.md has the measurement). The platform layer reuses the protocol crates std speaks and crates/user_mode_heap.

What it builds

What this stage decides in its own block

Where the crate lives, and its name (provisional until calef rules). Then whether cbindgen generates the headers or they are written by hand, how user/build.rs's clang finds them, and the startup path (crt0, static TLS for one thread) that replaces relibc's dynamic linker.

Done when

ioping and SQLite's speedtest1 build from their unmodified upstream sources against this library and run to completion on nife under QEMU on all three architectures, and a host test proves the platform layer's errno mapping. STREAM building and running counts too; its number waits on 534.

What is built (2026-10-10, lane milestone/835-a-c-library-stage-one-files-clock-and-memory)

Two unmodified C programs run in the suite on aarch64, riscv64 and x86_64 under QEMU (system_tests/src/user/c_program_tests.rs, three tests), each skipping when its helper has not been run, as rg's do:

The full suite passes on all three architectures with both programs present. The frame ledger holds: 22,838 frames kept on aarch64 and 22,782 on riscv64, against a budget of 23,764. Each test ends its caretaker and its clock service (clock_service::start_in, from milestone 801 (packages over the internet)). A host test proves the errno mapping (crates/c_library_errno, three tests), and c_library checks at compile time that its errno.h values equal the mapping's.

The library is relibc's OS-neutral code seeded into vendor/relibc/ (29,419 lines, every file stamped with its provenance) and nife's own platform layer in c_library/ (1,613 lines), which implements relibc's Pal on nife's Rust std. nifeos/nife:c_library/README.md is the guide, with its BUGS; nifeos/nife:vendor/README.md says what was taken and left.

ioping found what speedtest1 could not. SQLite formats numbers with its own printf, so a C library whose printf lost every double argument still produced SQLite's hash. ioping prints through the library's printf, and every size and time it printed was 0: on nife's soft-float ABI a double vararg travels in a general register, and Rust's va_arg::<f64> on aarch64 and x86_64 reads the floating-point save area. The seed now reads the bits as a u64, and the ioping test asserts the figure that exposed it.

What this block decided

Each was left to this block by §265 (a C library started from relibc, whose Rust platform layer holds the capabilities), and each is reversible:

Which fatal risk it serves

Risk 1 (only software written for nife runs on nife): two foreign programs, neither Rust nor related to ripgrep, now run unmodified on all three architectures. One does a database's work, with results identical to macOS's. They run only where their helpers were run, never in CI, and under QEMU, not on silicon. The verdict is calef's (§216 (fatal-risk facts are correctable, and verdicts are the architect's)).

BUGS

Follow-on

Index row

The first C library that runs somebody else's C program unmodified on nife: relibc's OS-neutral code, seeded once, over a Rust platform layer that holds the process's file, clock and memory capabilities, so the C itself makes no system_calls.