Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ jobs:
working-directory: checks/uefi
run: |
set +e
mcpp run --release --target x86_64-uefi -- one "two three" | tee run.log
mcpp run --release --target x86_64-uefi -- one "two three" "a b" | tee run.log
status=${PIPESTATUS[0]}
set -e
grep -q 'uefi ok: \[1, 2, 3\] \["one", "two three"\]' run.log || { echo "::error::the application's output or arguments"; exit 1; }
grep -q 'uefi ok: \[1, 2, 3\] \["one", "two three", "a b"\]' run.log || { echo "::error::the application's output or arguments"; exit 1; }
[ "$status" -eq 42 ] || { echo "::error::the application returned $status, not 42"; exit 1; }
p=$(find target/x86_64-uefi -path '*bin/uefi.efi' -type f | head -1)
file "$p"
Expand Down Expand Up @@ -465,11 +465,24 @@ jobs:
status=${PIPESTATUS[0]}
set -e
grep -q 'dos ok: \["one", "two"\]' run.log && grep -q 'caught: across a frame' run.log \
&& grep -q 'deep: 2080' run.log \
|| { echo "::error::the DOS program's output ($mode)"; exit 1; }
[ "$status" -eq 7 ] || { echo "::error::the DOS program returned $status, not 7 ($mode)"; exit 1; }
done
p=$(find target/i686-dos-musl -path '*bin/dos.exe' -type f | head -1)
file "$p"
# The row's stack (0.29.1): the executable after the stub states 1 MiB in PT_GNU_STACK.
python3 - "$p" <<'PY'
import struct, sys
data = open(sys.argv[1], "rb").read()
at = data.find(b"\x7fELF\x01\x01")
phoff, = struct.unpack_from("<I", data, at + 28)
phentsize, phnum = struct.unpack_from("<HH", data, at + 42)
sizes = [struct.unpack_from("<6I", data, at + phoff + i * phentsize)[5]
for i in range(phnum) if struct.unpack_from("<I", data, at + phoff + i * phentsize)[0] == 0x6474E551]
print("PT_GNU_STACK memsz:", sizes)
sys.exit(0 if sizes == [1048576] else "::error::the DOS program states no 1 MiB stack")
PY

- name: The i386 image carried as a DOS program
working-directory: checks/i386
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,28 @@ builds openkal-run's core runner as a program of the DOS row below, with the
image in its `.oke` section. Measured under DOSBox Staging: the image sorted its
arguments, caught its exception, read DOS's `PATH` and returned 7.

Platform 0.29.0 requires mcpp 2026.11.16.1. Every runner here that boots a
Platform 0.29.0 and 0.29.1 require mcpp 2026.11.16.1. Every runner here that boots a
machine is enabled on request: the UEFI row's (QEMU and OVMF), the DOS row's
(DOSBox Staging), and, new, the hosted rows' runners on another system. FreeBSD
programs run in the FreeBSD virtual machine of xim's disk image packages, and
programs run in the FreeBSD virtual machine of xim's disk image packages (0.29.1:
`freebsd-disk-image` 14.5-1, whose profile runs the command in the directory of
the files a run delivers, `mcpp run --file`), and
an `x86_64-windows-musl` program runs through Wine on an x86_64 Linux machine.
Each fetches a machine image or an emulator, or makes a prefix in the home
directory, on its first use, so `mcpp run` names the runner and how to enable it
until a project or this machine does:

```toml
[target.x86_64-freebsd-musl]
platform = "openkal-platform@0.29.0"
platform = "openkal-platform@0.29.1"
runner = { enabled = true }
```

The UEFI runner passes the program's arguments (`--`, with ovmf 9.2.4-3's Shell
profile, whose arguments dirun 0.5.0 quotes for the Shell, so one with a blank
arrives whole), and openkal-uefi 0.11.0 implements `openkal.fs` over the firmware's
The UEFI runner passes the program's arguments (`--`, with ovmf 9.2.4-4's Shell
profile, whose arguments dirun quotes for the Shell, so one with a blank arrives
whole; openkal-uefi 0.11.1 divides them from the load options, so runs of blanks
inside one are kept). The application's disk is a writable FAT32 image (dirun
0.6.0, `disk = "fat-image"`), so it can write files; openkal-uefi implements `openkal.fs` over the firmware's
file system and `openkal.random` over its RNG protocol, beneath openkal-musl
0.29.8. okrun is a host for `macos-x86_64` (the release build of openkal-macos
0.23.4 links) and `linux-i686` (built as `i686-linux-musl`), so `--systems all`
Expand Down Expand Up @@ -286,7 +290,7 @@ with `import std`:

```toml
[target.x86_64-uefi]
platform = "openkal-platform@0.29.0"
platform = "openkal-platform@0.29.1"
runner = { enabled = true }
```

Expand Down Expand Up @@ -321,7 +325,7 @@ run-time over openkal-dos, so it is written in C++23 with `import std`:

```toml
[target.i686-dos-musl]
platform = "openkal-platform@0.28.0"
platform = "openkal-platform@0.29.1"
```

The row is TECHNICAL EXPERIMENT ONLY (openkal-dos's README). A program is the
Expand All @@ -332,8 +336,8 @@ row's flags are its conventions: `-march=i486`, emulated thread-local storage
(there is no thread register the toolchain can address), unwind tables for
every unit, and the stack aligned to sixteen bytes at a call, as an i386 ok
image's is (the row's code calls images and is called by them). The provider's
link is `ld.lld -static --image-base=0x1000 -z norelro --gc-sections
--eh-frame-hdr`, entered at `okdos_entry`, over `base = "none"`, and
link is `ld.lld -static --image-base=0x1000 -z norelro -z stack-size=1048576
--gc-sections --eh-frame-hdr`, entered at `okdos_entry`, over `base = "none"`, and
the platform's tools it carries are the one its seal names (mcpp 2026.11.13.1):
a DOS build builds `okdos` alone, and an ok image does not build it. `mcpp run`
runs the program with dirun and xim's DOSBox Staging profile, which places
Expand All @@ -345,6 +349,13 @@ listed, resized and removed files and directories there (measured). openkal-dos
provides `abort`, `env`, `exec`, `fs`, `memory`, `stream`, `terminal` and
`time`. `region` is absent, because the DPMI host CWSDPMI is DPMI 0.90.

The stack (0.29.1) is the executable's statement: the row links with `-z
stack-size=1048576`, and openkal-dos 0.1.1's stub reads PT_GNU_STACK's size and
places the stack above a guard page (DPMI `0507h`), so an overflow is a reported
page fault rather than a write over the program. A project states another size
with its own link flags. Measured: 64 frames of 8 KiB return under DOSBox
Staging.

## Version group

`[platform.versions]` names one version of each package of the family. From
Expand Down Expand Up @@ -380,7 +391,7 @@ previous patch's.
| `checks/host-graph` | a build program runs as an ok image |
| `checks/snapshot` | a C++ program starts from a snapshot of its initialisers, and a start whose named value differs does not |
| `checks/i386` | an ok image of i386 is built in both modes, checked by okld and run by okrun built for i686-linux-musl; packed with `--systems dos-i686`, it runs as a DOS program |
| `checks/dos` | a program of i686-dos-musl runs in both modes under DOSBox Staging (technical experiment only) |
| `checks/dos` | a program of i686-dos-musl runs in both modes under DOSBox Staging, with a 512 KiB recursion, and states a 1 MiB stack (technical experiment only) |
| family release | the group's members are tagged and mirrored, both mcpp releases resolve an image of it, and a patch removes no symbol |

## License
Expand Down
11 changes: 10 additions & 1 deletion checks/dos/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
// A DOS program: its arguments sorted, an exception across a frame, the environment, a status.
// A DOS program: its arguments sorted, an exception across a frame, the environment, a deep
// stack, a status. The recursion uses 512 KiB (64 frames of 8 KiB): the row's stack is 1 MiB
// (0.29.1, `-z stack-size'), which openkal-dos 0.1.1's stub reads from PT_GNU_STACK.
import std;

int deep(int n) {
volatile char frame[8192];
frame[0] = static_cast<char>(n);
return n == 0 ? frame[0] : deep(n - 1) + frame[0];
}

int main(int argc, char** argv) {
std::vector<std::string> v(argv + 1, argv + argc);
std::ranges::sort(v);
std::println("dos ok: {}", v);
try { throw std::runtime_error("across a frame"); }
catch (const std::exception& e) { std::println("caught: {}", e.what()); }
std::println("PATH set: {}", std::getenv("PATH") != nullptr);
std::println("deep: {}", deep(64));
return 7;
}
3 changes: 2 additions & 1 deletion checks/uefi/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// The C++ a UEFI application is written in: the standard library's text, ranges and containers
// over openkal-musl and openkal-llvm-runtime, its arguments as the runner passed them (0.29.0: the
// Shell's, an argument with a space whole), and its status returned to the machine that ran it.
// Shell's, an argument with a space whole; 0.29.1: runs of blanks inside one kept), and its status
// returned to the machine that ran it.
import std;

int main(int argc, char** argv) {
Expand Down
31 changes: 18 additions & 13 deletions mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-platform"
version = "0.29.0"
version = "0.29.1"
description = "The platform of ok images (<arch>-openkal): their toolchain, C library and C++ run-time, tools, compile and link conventions, seal, runner and carrier, as one versioned statement mcpp reads."
license = "Apache-2.0"
authors = ["mcpplibs"]
Expand Down Expand Up @@ -82,7 +82,7 @@ okld = "openkal-tools@0.6.4"
okrun = "openkal-tools@0.6.4"
okprof = "openkal-tools@0.6.4"
# The seal of the DOS row (0.28.0): the stub of openkal-dos before an executable.
okdos = "openkal-dos-tools@0.1.0"
okdos = "openkal-dos-tools@0.1.1"

# Every unit of an image (SPEC 12.2):
# -fPIC the image is ET_DYN and has no text relocation;
Expand Down Expand Up @@ -239,7 +239,7 @@ hosted = true
base = "none"
toolchain = "llvm@23.1.3"
layers = { compiler-runtime = "openkal-llvm-runtime@0.20.3", "c++-abi" = "openkal-llvm-runtime@0.20.3", c-abi = { name = "openkal-musl", version = "0.29.8", default-features = false, features = ["posix", "malloc-mimalloc"] } }
runner = { cmd = ["dirun", "--profile", "{pkg:freebsd-disk-image}/dirun.toml", "--emulator", "{pkg:qemu-x86}/bin/qemu-system-x86_64", "--", "{}"], host = "any", hosts = ["linux-x86_64"], requires = ["xim:dirun@0.5.0", "xim:freebsd-disk-image@14.5", "xim:qemu-x86@9.2.4-1"], enabled = false }
runner = { cmd = ["dirun", "--profile", "{pkg:freebsd-disk-image}/dirun.toml", "--emulator", "{pkg:qemu-x86}/bin/qemu-system-x86_64", "--", "{}"], host = "any", hosts = ["linux-x86_64"], requires = ["xim:dirun@0.6.0", "xim:freebsd-disk-image@14.5-1", "xim:qemu-x86@9.2.4-1"], enabled = false }

[[platform.provider]]
name = "freebsd-vm"
Expand All @@ -248,7 +248,7 @@ hosted = true
base = "none"
toolchain = "llvm@23.1.3"
layers = { compiler-runtime = "openkal-llvm-runtime@0.20.3", "c++-abi" = "openkal-llvm-runtime@0.20.3", c-abi = { name = "openkal-musl", version = "0.29.8", default-features = false, features = ["posix", "malloc-mimalloc"] } }
runner = { cmd = ["dirun", "--profile", "{pkg:aarch64-freebsd-disk-image}/dirun.toml", "--var", "firmware={pkg:ovmf}/share/edk2/edk2-aarch64-code.fd", "--emulator", "{pkg:qemu-system}/bin/qemu-system-aarch64", "--", "{}"], host = "any", hosts = ["linux-x86_64"], requires = ["xim:dirun@0.5.0", "xim:aarch64-freebsd-disk-image@14.5", "xim:ovmf@9.2.4-3", "xim:qemu-system@9.2.4"], enabled = false }
runner = { cmd = ["dirun", "--profile", "{pkg:aarch64-freebsd-disk-image}/dirun.toml", "--var", "firmware={pkg:ovmf}/share/edk2/edk2-aarch64-code.fd", "--emulator", "{pkg:qemu-system}/bin/qemu-system-aarch64", "--", "{}"], host = "any", hosts = ["linux-x86_64"], requires = ["xim:dirun@0.6.0", "xim:aarch64-freebsd-disk-image@14.5-1", "xim:ovmf@9.2.4-4", "xim:qemu-system@9.2.4"], enabled = false }

[[platform.provider]]
name = "wine"
Expand Down Expand Up @@ -293,7 +293,7 @@ hosted = true

layers = { compiler-runtime = "openkal-llvm-runtime@0.20.3", "c++-abi" = "openkal-llvm-runtime@0.20.3", c-abi = { name = "openkal-musl", version = "0.29.8", default-features = false, features = ["posix", "malloc-mimalloc"] } }
link = { driver = "lld", start = "efi_main", flags = ["--subsystem", "efi_application", "--gc-sections"], exe = "{name}.efi", inputs = [{ file = "board/qemu-exit.S" }], seal = [] }
runner = { cmd = ["dirun", "--payload", "{}", "--profile", "{pkg:ovmf}/dirun.toml", "--emulator", "{pkg:qemu-x86}/bin/qemu-system-x86_64", "--memory", "2048", "--"], hosts = ["linux-x86_64", "linux-aarch64", "macos-aarch64", "windows-x86_64"], requires = ["xim:dirun@0.5.0", "xim:qemu-x86@9.2.4-1", "xim:ovmf@9.2.4-3"], enabled = false }
runner = { cmd = ["dirun", "--payload", "{}", "--profile", "{pkg:ovmf}/dirun.toml", "--emulator", "{pkg:qemu-x86}/bin/qemu-system-x86_64", "--memory", "2048", "--"], hosts = ["linux-x86_64", "linux-aarch64", "macos-aarch64", "windows-x86_64"], requires = ["xim:dirun@0.6.0", "xim:qemu-x86@9.2.4-1", "xim:ovmf@9.2.4-4"], enabled = false }

# DOS (0.28.0; TECHNICAL EXPERIMENT ONLY, openkal-dos's README): programs a DPMI
# host runs, on the same C library and C++ run-time over openkal-dos
Expand All @@ -309,7 +309,10 @@ runner = { cmd = ["dirun", "--payload", "{}", "--profile", "{pkg:ovmf}/dirun.tom
# them. The processor is the 486, as for the i386 ok image (DOSBox Staging 0.83
# executes no CMPXCHG8B, measured). The runner is dirun with DOSBox Staging and CWSDPMI beside the program
# (xim's `dosbox-staging'). The memory allocator is musl's own (`malloc-mallocng'):
# it asks openkal.memory for blocks and nothing else.
# it asks openkal.memory for blocks and nothing else. The stack (0.29.1) is the
# executable's own statement, PT_GNU_STACK's size, which openkal-dos 0.1.1's stub
# reads and places above a guard page: the row states 1 MiB (`-z stack-size'),
# and a project's own link flags state another.
[[platform.define]]
triple = "i686-dos-musl"
clang-triple = "i386-unknown-none-elf"
Expand All @@ -328,8 +331,8 @@ base = "none"
hosted = true

layers = { compiler-runtime = "openkal-llvm-runtime@0.20.3", "c++-abi" = "openkal-llvm-runtime@0.20.3", c-abi = { name = "openkal-musl", version = "0.29.8", default-features = false, features = ["posix", "malloc-mallocng"] } }
link = { driver = "lld", start = "okdos_entry", flags = ["-static", "--image-base=0x1000", "-z", "norelro", "--gc-sections", "--eh-frame-hdr"], seal = [["okdos", "seal", "{}"]] }
runner = { cmd = ["dirun", "--payload", "{}", "--profile", "{pkg:dosbox-staging}/dirun.toml", "--"], hosts = ["linux-x86_64", "macos-aarch64", "windows-x86_64"], requires = ["xim:dirun@0.5.0", "xim:dosbox-staging@0.83.0-2"], enabled = false }
link = { driver = "lld", start = "okdos_entry", flags = ["-static", "--image-base=0x1000", "-z", "norelro", "-z", "stack-size=1048576", "--gc-sections", "--eh-frame-hdr"], seal = [["okdos", "seal", "{}"]] }
runner = { cmd = ["dirun", "--payload", "{}", "--profile", "{pkg:dosbox-staging}/dirun.toml", "--"], hosts = ["linux-x86_64", "macos-aarch64", "windows-x86_64"], requires = ["xim:dirun@0.6.0", "xim:dosbox-staging@0.83.0-2"], enabled = false }

# The family released together for openkal 0.17 (the 0.17.2 round: okb, the
# runner's bundle and library interfaces, musl's renameat2; the 0.17.3 round:
Expand Down Expand Up @@ -390,7 +393,9 @@ runner = { cmd = ["dirun", "--payload", "{}", "--profile", "{pkg:dosbox-staging}
# 0.29.7 (`uname' names the system a hosted program runs on); 0.29.0, openkal-uefi
# 0.11.0 (openkal.fs over the firmware's file system, openkal.random over its RNG
# protocol, the Shell's arguments) beneath openkal-musl 0.29.8, which admits it:
# one version of each in a build. From 0.24.1 the members name one another by
# one version of each in a build; 0.29.1, openkal-uefi 0.11.1 (the Shell's arguments
# divided from the load options, so whitespace inside a quoted one arrives whole)
# and openkal-dos 0.1.1 (the stack from PT_GNU_STACK above a guard page). From 0.24.1 the members name one another by
# compatible ranges (`^0.28.0`) and this group chooses the versions: mcpp
# 2026.11.7.1 resolves within it, and a fix of one member is that member's
# release and a patch of this group, released together through one index change
Expand All @@ -401,9 +406,9 @@ openkal-linux = "0.26.3"
openkal-macos = "0.23.4"
openkal-windows = "0.21.2"
openkal-freebsd = "0.1.2"
openkal-uefi = "0.11.0"
openkal-dos = "0.1.0"
openkal-dos-tools = "0.1.0"
openkal-uefi = "0.11.1"
openkal-dos = "0.1.1"
openkal-dos-tools = "0.1.1"
openkal-musl = "0.29.8"
openkal-llvm-runtime = "0.20.3"
openkal-ld = "0.6.4"
Expand All @@ -416,4 +421,4 @@ openkal-tools = "0.6.4"
openkal-tools = { version = "0.6.4", tools = ["okld"] }

[build-dependencies.mcpp]
plugins = { version = "0.20.0", features = ["plugins-platform"], host-module = true }
plugins = { version = "0.22.1", features = ["plugins-platform"], host-module = true }
Loading