Files
danos/library/kernel/root.zig
Daniel Samson 37326c7664 C5: delete the runtime.zig and system.zig compatibility shims
With every consumer migrated (C2), nothing imports `runtime` or `system` any
longer. Removed both shim files and their build.zig module definitions, dropped
the `runtime` entry from `default_imports`, and rewrote the per-binary root shim
(library/kernel/root.zig) to import `start` (_start + panic) and `logging`
(std_options) directly instead of through `runtime`.

addUserBinary/addThreadedUserBinary/addUserBinaryImpl lose their `runtime_module`
parameter; the root module now pulls the two modules it needs out of
`default_imports` via a small findImport helper.

The runtime dumping ground is gone: the userspace library is library/kernel
(concern modules), library/device (driver/pci/usb/block/model/mmio/acpi data),
library/client (display, input service clients), and library/protocol (wire
contracts). Consumers @import concern modules by name.

Verified: zig build, zig build test, and QEMU (smoke, thread-spawn, thread-mutex,
logger, display-native, device-manager, usb-storage, input).
2026-07-22 23:32:05 +01:00

27 lines
1.1 KiB
Zig

//! The root module every user binary is compiled through (build.zig,
//! `addUserBinary`). The program's own file is imported as `program`, and this
//! shim contributes the declarations Zig resolves from the compilation root —
//! `main` (dispatched by start's comptime dispatch) and the panic handler — and
//! pulls in the `_start` entry shim. A program therefore only defines
//! `pub fn main`; nothing else is required in its source file.
const start = @import("start");
const logging = @import("logging");
const program = @import("program");
/// Resolved as `@import("root").main` by start's comptime dispatch.
pub const main = program.main;
/// The panic handler for every safety check in the image (start.panic).
pub const panic = start.panic;
/// std.log for every user binary goes to the tagged kernel log ring (the kernel
/// stamps the sender; see the logging module). A program overrides by declaring
/// its own `pub const std_options`.
pub const std_options: @import("std").Options =
if (@hasDecl(program, "std_options")) program.std_options else logging.default_options;
comptime {
_ = &start._start; // pull the entry shim into the image
}