Skip to content

0.2.1: os over the program's own C library on every host - #7

Merged
Sunrisepeak merged 8 commits into
mainfrom
os-0.2.1
Oct 28, 2026
Merged

Sunrisepeak merged 8 commits into
mainfrom
os-0.2.1

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

What

mcpplibs.os 0.2.1 builds and passes its tests in both arrangements of the program's C library, on Linux, macOS and Windows:

  • the system's own C library (glibc, libSystem, the Microsoft C runtime);
  • a C library that sits on openkal on the system's own triple: openkal-musl (posix) with openkal-llvm-runtime. This is mcpp docs/24, the arrangement mcpp-language-server uses, and design 2026-10-28 §5.4 makes it a first-class platform choice.

Why

mcpp-language-server#72 failed to build os 0.2.0 in the second arrangement. That C library presents POSIX and openkal rather than the system, and five consequences followed:

  • Headers: its headers are not the SDK's (sys/sysctl.h, mach/mach.h).
  • Windows types: on Windows its data model is LP64 and its wchar_t 32 bits, so unsigned long is not a DWORD, wchar_t is not a WCHAR, and path::c_str() is char.
  • Linux answers: its uname names openkal and its sysinfo is absent. syscall(SYS_renameat2, …, RENAME_EXCHANGE) became a plain rename that replaced the second entry, an openkal-musl port issue reported separately.
  • Process state: its descriptors and signals are its own, so dup2 and signal did not change the process's standard output or SIGPIPE's disposition.
  • Import sets: a link pointed at a target uses openkal-windows' and openkal-macos' import sets. These list only the names those implementations call.

How

  • Linux: the kernel's calls, one trap per architecture (src/linux/kernel.h, src/linux/arch/).
  • macOS:
    • the kernel's statfs64 and renameatx_np (src/macos/kernel.h), which openkal-macos issues itself;
    • the libSystem names no C library defines (sysctlbyname, mach_host_self, host_page_size, host_statistics64), declared in src/macos/darwin.h and linked with -U. Where the link's libSystem is openkal-macos' stub, they bind at load from libSystem (lib_ordinal -2, measured).
  • Windows:
    • win32.h declares DWORD as 32 bits and WCHAR as char16_t;
    • names are converted from UTF-8 (R7, text.h);
    • kernel32 names that openkal-windows does not call are bound at first use (late::).
  • Process state:
    • On Linux and macOS, the output diversion, SIGPIPE's reset before exec and end_as_output_closed use the kernel's descriptors and dispositions (src/posix/kernel.h).
    • On Windows, the diversion moves the C runtime's descriptor (crt/stdio.cpp). For a C library on openkal it moves that library's descriptor and the process's standard handle (posix/stdio.cpp), selected by cfg(c-abi = "musl").
  • checks/hosted: compiles every test of the package in the second arrangement. CI runs it on Linux x86_64 (dev, release), Linux aarch64, macOS and Windows (dev, release), and checks that every test has a counterpart.

Verified locally

Run Result
Native, Linux x86_64: gcc 16.1.0 dev/release, llvm 23.1.3; R3/R5 checks 7/7
x86_64-openkal images 7/7
Hosted, Linux x86_64, dev/release 7/7
Hosted and native, aarch64 under qemu-user 7/7
x86_64-windows-gnu, native and hosted, cross-linked and run under wine all pass except wine's known lock and drive-root checks, which fail identically on main
aarch64-macos hosted, cross-linked links
riscv64 trap compile-checked

Later in this PR

This PR will also receive the platform migration once mcpp's platform release exists (design 2026-10-28 §11.5): removal of the [target.'cfg(os = "openkal")'] runtime and tool declarations, and the CI image job on mcpp toolchain install --target and self env --target.

Co-authored-by: speak-agent [email protected]

Sunrisepeak and others added 5 commits October 28, 2026 02:02
A C library on openkal (openkal-musl over openkal-<os>, on the system's own
triple) presents POSIX and openkal rather than the system. The per-system units
now reach the system without it:

- Linux: the kernel's calls, one trap per architecture (src/linux/kernel.h,
  src/linux/arch/), for uname, sysinfo, statfs and renameat2. Under such a C
  library uname named openkal, sysinfo was absent and renameat2's
  RENAME_EXCHANGE was a plain rename.
- macOS: the kernel's statfs64 and renameatx_np (src/macos/kernel.h), and the
  libSystem names no C library defines for sysctl and the host's statistics
  (src/macos/darwin.h), declared rather than included and allowed undefined
  (-U) where the link's libSystem is openkal-macos's stub.
- Windows: DWORD as 32 bits and WCHAR as char16_t in win32.h under every C
  environment, names converted from UTF-8 (text.h); kernel32's names beyond the
  ones openkal-windows calls are found when first called.
- The process's output diversion, SIGPIPE's reset before exec and the ending
  for a closed reader use the kernel's descriptors and dispositions on Linux and
  macOS (src/posix/kernel.h); on Windows the diversion is the C runtime's
  (crt/stdio.cpp) or, for a C library on openkal, that library's descriptor and
  the process's standard handle (posix/stdio.cpp), selected by c-abi.

Co-authored-by: speak-agent <[email protected]>
…in CI on four systems

Each test of the package is compiled in that arrangement by an include from
checks/hosted/tests; CI checks that every test has its counterpart and runs the
suite on Linux x86_64 (dev, release), Linux aarch64, macOS and Windows (dev,
release). The tests assert that Linux names the machine as the processor and
that a volume's kind is named, and make a file executable through
os::fs::set_executable, which works over every C library.

Co-authored-by: speak-agent <[email protected]>
…program in this arrangement names it

Co-authored-by: speak-agent <[email protected]>
…uns, threads, environment entries, a bounded read, canonical names

mcppls removes its modules/os and modules/platform in 0.0.18 and calls mcpplibs.os directly; what it needed and
os did not have is here:

- process::run(options, bounds, input): a hard bound, a grace, a drain, and per-output limits; it says whether the
  program was ended at the bound, whether a descendant held an output open (and ends the unit), and which output
  it cut.
- process::threads(id): each thread of a program with its processor time (Linux /proc; none elsewhere).
- env::assignments(entries): `NAME=value` entries as spawn_options overrides.
- fs::read(file, at_most): errc::too_large past the bound (new condition, after timed_out).
- fs::canonical(name): links followed and, on Windows, short components replaced by their long names.

Tests in process_test and fs_test; native and hosted (openkal-musl + openkal-llvm-runtime) pass on Linux x86_64,
and the hosted package cross-builds for x86_64-windows-gnu and aarch64-macos.

Co-authored-by: speak-agent <[email protected]>
Sunrisepeak added a commit to Sunrisepeak/mcpp-language-server that referenced this pull request Oct 27, 2026
…ules/os and modules/platform removed

mcppls kept a layer of its own over mcpplibs.os (modules/os: the system in mcppls's names; modules/platform: files,
processes, the environment, directories, loopback sockets, the standard streams, tool runs). The layer is removed,
as mcpp 2026.10.26.2 removed its modules/platform, and every member calls mcpplibs.os directly.

What was generic moved into mcpplibs.os 0.2.1 (mcpplibs/os#7, branch os-0.2.1, depended on by git until it is in
the index):
- the bounded run (process::run with a hard bound, a grace, a drain and per-output limits; held-open outputs end the
  unit), formerly platform::run and its RunBounds/RunResult;
- the threads of a program (process::threads), formerly platform::thread_cpu;
- `NAME=value` entries as a started program's overrides (env::assignments);
- a bounded read (fs::read(file, at_most), errc::too_large);
- the canonical name of a file (fs::canonical: links followed, Windows short names replaced).

What is mcppls's own stays, in two small places:
- modules/base: its home and cache directories (home.cppm), its payload names (payload.cppm: linux-x64, darwin-arm64,
  ...), the channel the event loop reads (channel.cppm, formerly platform/task), and in path.cppm the spelling of what
  the file system answers (children, files_under, current_directory, canonical_path, file_stamp, make_executable,
  file_time_now -- the file clock's own reading of now, which a sweep's bound must use) and last_lines in text;
- modules/toolrun (new member, formerly platform/toolenv and platform/toolrun): the login shell's environment,
  offline and recorded runs, the rule that a program is never found through a relative PATH entry (find_program),
  the PRoot check (sandbox), and exit_code for a report.

Process identity for leases, CPU time for StuckWatch, the client watch and the daemon's loopback sessions now ask
mcpplibs.os (process::self/describe, net::loopback_listener, ipc::connection; a connection other threads use is
shut down, not closed, as before). The LSP connection holds an os::process::process.

Tests: test_process, test_fs, test_net, test_os, test_sandbox, test_gateway and the call sites of every other test
are on mcpplibs.os; the lease takeover of a zombie is asserted through lease_owner_gone. Locally on Linux x86_64:
`mcpp test --workspace` passes; the server builds for x86_64-windows-gnu, aarch64-macos and x86_64-openkal;
mcpp-split, mcpp-emit-hang, mcpp-watch, build-program-manual, mcpp-emit-broken, clangd-crash-closure, cache-budget,
diagnostic-bundle, reset-cache, xmake-basic, mcpp-target-race, self-mcpp and typing-pause pass (inferred-discover
expects a machine without a compiler); `mcppls-devtools check all` passes, its layers rule now saying that the
operating system is mcpplibs.os's and openkal is imported from nowhere. Traceability evidence for S2-6-3, S2-6-5,
S2-6-6, S2-6-7 points at modules/toolrun, and S5-6.1-1's at the daemon's own `os::net::loopback_listener::listen(0)`.

Co-authored-by: speak-agent <[email protected]>
Sunrisepeak and others added 2 commits October 28, 2026 07:40
…om their platform (mcpp SPEC-013); CI locates the runner through the target's configuration

Co-authored-by: speak-agent <[email protected]>
…e toolchain, the C library and the C++ run-time (no layer named here)

Co-authored-by: speak-agent <[email protected]>
…ages and checks/hosted stand on

Co-authored-by: speak-agent <[email protected]>
@Sunrisepeak
Sunrisepeak merged commit 7231289 into main Oct 28, 2026
33 of 48 checks passed
@Sunrisepeak
Sunrisepeak deleted the os-0.2.1 branch October 28, 2026 13:55
Sunrisepeak added a commit to mcpplibs/mcpp-index that referenced this pull request Oct 28, 2026
…t; mcpp.plugins latest is 0.20.0 (#617)

- **mcpplibs.os 0.2.1** (mcpplibs/os#7): builds and passes its tests over the system's own C library and over openkal-musl with openkal-llvm-runtime on the system's own triple; an ok image's C library, C++ run-time and loader are its platform's (openkal-platform), so the package declares none of them. GLOBAL is the GitHub tag archive, CN the GitCode `mcpp-res/os` mirror (same sha256). Member `tests/examples/os` moves to 0.2.1.
- CI and the openkal measurement run the released mcpp 2026.10.27.1 (the `MCPP_SOURCE_REF` variable that pointed them at its release branch is removed); `mcpp.plugins` names 0.20.0 as latest.

Co-authored-by: speak-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant