Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-bridge/blob/main/docs/NATIVE-ABI.md # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-bridge / docs / NATIVE-ABI.md` 1425 lines · 100475 bytes Raw Blame History Source # Native call ABI v1 and v2 ABI v0 (docs/ABI.md) translates Omega source into C or Python source. ABI v1 calls the machine code the seeded Omega compiler itself produced. Nothing is translated: each foreign language calls the same compiled Omega function. Omega's language and its internal calling rules are unchanged; the bridge adapts the foreign side to them. ## Target selection and compiler custody `tools/native [--target aarch64linux|x86linux] [--freestanding] [--host] OUTDIR unit.om...` selects the output ABI explicitly. The default is `aarch64linux`; it keeps the existing generator invocation and compiler inputs unchanged. The tool does not infer a target from the build host or try to execute a generated library. `OMEGA_NATIVE_OMC` remains mandatory for both targets and must have sha256 `734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61`. It builds `src/native.om` into the AArch64-hosted `work/native-gen`. With the default target it also compiles OM-1 units; `OMEGA_NATIVE_OMC2` compiles OM-2 units and supplies their compiler identity, as before. The native-v2 qualification suite needs two explicitly pinned OM-2 compiler roles until the upstream hoist and function-host changes are combined: `OMEGA_NATIVE_OMC2` for ABI/hoist units and `OMEGA_NATIVE_HOST_OMC2` for section 11's host units. This is test configuration, not a change to the production compiler pin or `tools/native`'s interface. See AArch64 qualification below for exact revisions, digests, and the seed-only rebuild. For `--target x86linux` without `--host`, `OMEGA_NATIVE_X86_OMC` compiles both OM-1 and OM-2 units and must have sha256 `be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a`, the committed `seed/out/omc` of omega-mv main `474197e4fa0207e0e2fb3c0494594a975f5031fa` (last changed by omega-mv #994). Its compiler source sha256 is `d4b4b89d8a58cc90d30d15a525b417e4b31e5bfe5288d21d665f1c7958a330f6`. This is a separate candidate compiler pin, not a replacement for the generator's baseline pin. `OMEGA_NATIVE_OMC2` is not used for this target. Each compiler input is `target x86linux\n` followed by the snapshotted source. The directive exists only in `work/.compile.om`: profile detection, generator framing, the `src=` identity and `work/.om` all retain the exact original source bytes. The `omc=` identity records the x86 compiler's digest, not the baseline generator compiler's digest. The x86 generator contract is `native-gen OUTPUT x86linux` for pure output and `native-gen OUTPUT x86host` with `--host`. Default AArch64 calls remain `native-gen OUTPUT`. Set `CC` to a compiler for the selected target; for example: ``` OMEGA_NATIVE_OMC=/path/to/baseline/omc \ OMEGA_NATIVE_X86_OMC=/path/to/x86/omc \ CC=x86_64-linux-gnu-gcc \ tools/native --target x86linux build/native-x86 \ tests/native/madd.om tests/native/v2/vec.om ``` The x86 target is hosted Linux x86-64 SysV output. With `--freestanding` it emits the same freestanding binding (pure-scalar OM-1 units, and OM-2 units with output `fapic`, see below) with a SysV adapter that runs on the caller's stack, keeps the trap anchor in R12 and sets the owned-stack floor R15 to 0 (no bound check, as in the AArch64 freestanding binding). x86 code bytes are packed as little-endian `.quad` words plus a `.byte` tail; the assembled bytes are the compiler's bytes. Before omega-mv#940 the combination refused with exit 110 before creating OUTDIR. An unknown target or malformed option exits 2. A mismatched compiler digest refuses before generating or installing outputs. Evidence boundary: the x86 integration is IMPLEMENTED and EXERCISED under QEMU 10.0.14, not qualified by the historical AArch64 receipts below. At the current x86 compiler pin, see `evidence/native-x86-be8c5130.json` and its command receipts; earlier pins' receipts remain in `evidence/native-x86-62775d2a.json`, `evidence/native-x86-badedbb0/`, `evidence/native-x86-f7752bc5/` and `evidence/native-x86/`. Native physical x86-64 execution remains NOT_RUN. No GPU execution is part of this target. The compiler is merged on omega-mv main. The full compiler differential is recorded separately; this bridge receipt does not qualify the compiler. ### x86 emulator runner and QEMU oracle `sh tests/native/x86/run.sh [EMPTY_OUTPUT]` cross-builds the callers and executes all target programs through `QEMU_X86_64` by default, even on an x86 build host. It requires the baseline and x86 compiler variables above, `CC`/`CXX` targeting x86 Linux, Rust's `x86_64-unknown-linux-gnu` standard library, Zig 0.13, Go with cgo, and an x86 Linux Python interpreter supplied as `OMEGA_NATIVE_X86_PYTHON`. This is not the build host's Python. `OMEGA_NATIVE_X86_SYSROOT` defaults to `/usr/x86_64-linux-gnu`; `OMEGA_NATIVE_X86_LIBPATH` optionally supplies the guest library search path. `tests/native/x86/prepare.py EMPTY_OUTPUT` extracts a Python oracle without installing host packages and prints the Python/library variables; its `runtime-packages.json` records exact archive versions and digests. `OMEGA_NATIVE_X86_EXEC=native` runs the same suite with every target program executed directly on an x86-64 host CPU instead of under QEMU; the QEMU oracle is then not used, and check names and the aggregate line say `NATIVE`. Preflight refuses a non-x86-64 host and any other mode value, and prints the CPU model, hypervisor flag, kernel and detected virtualization. The pinned compilers are AArch64 executables, so the x86 host runs them through binfmt `qemu-aarch64`. NATIVE-X86-PHYSICAL.md is the runbook, the control set and the receipt format; a receipt is labelled PHYSICAL only for `virtualization=none` with the hypervisor flag clear. Select the emulator explicitly for qualification: ``` OMEGA_NATIVE_OMC=/path/to/baseline/omc \ OMEGA_NATIVE_X86_OMC=/path/to/x86/omc \ CC=x86_64-linux-gnu-gcc CXX=x86_64-linux-gnu-g++ \ QEMU_X86_64=/path/to/qemu-10.0.14/build/qemu-x86_64 \ OMEGA_NATIVE_X86_PYTHON=/path/to/amd64-python/root/usr/bin/python3.12 \ OMEGA_NATIVE_X86_LIBPATH=/path/to/amd64-python/root/usr/lib/x86_64-linux-gnu:/path/to/amd64-python/root/lib/x86_64-linux-gnu:/usr/x86_64-linux-gnu/lib \ sh tests/native/x86/run.sh build/native-x86-new ``` Integration observations found crashes in the C signal control and Rust/Go `/proc/self/maps` paths under QEMU 8.2.2. The unchanged callers exited 0 with unpatched QEMU 10.0.14. Do not alter callers or weaken signal/thread controls to accommodate the older emulator. The complete integrated suite and its failed/missing-toolchain controls subsequently passed under 10.0.14 (EMULATED). The suite now checks the emulator before any caller runs. It prints `INFO qemu executable=`, `INFO qemu sha256=` and `INFO qemu version=` for the resolved `QEMU_X86_64`, then cross-builds `tests/native/x86/qemu_probe.c` and runs it in two modes through the same `-L`/`-E` guest command as the callers: - `maps` reads `/proc/self/maps`, as glibc does during Rust and Go thread startup. QEMU 8.2.2 crashes internally (`QEMU internal SIGSEGV {code=MAPERR, addr=0x20}`). - `sigframe` takes SIGALRM while RSP is on a stack laid out like the owned Omega stack and records RSP at handler entry in an assembly handler. The SysV ABI requires RSP+8 to be 16-byte aligned there. QEMU 8.2.2 enters handlers 8 bytes off, so the C caller's reentry handler faults on the `movaps` stack stores in `omega2_vlen` (#GP, reported as signal 11). A mode that does not print exactly `QEMU-PROBE ok` and exit 0 prints `NOT_RUN QEMU-ORACLE-UNUSABLE : …`, and the aggregate ends `NATIVE-X86 NOT_RUN (not run: … qemu-oracle …)` with exit 1. The emulator is judged by behavior, not by a version list. Set `OMEGA_NATIVE_X86_BAD_QEMU` to a known-bad emulator to make `test_build_failures.py` require that refusal; unset, that control prints NOT_RUN. The replacement oracle comes from https://download.qemu.org/qemu-10.0.14.tar.xz , archive SHA256 `c7230968906fdb5540d803e2af1f515e77590a414f2a4dbd3ec9ada3c47083d0`. QEMU is a read-only verification oracle, not a bridge build or production dependency, and does not require an Omega replacement. With the native compiler, Python, Ninja, pkg-config and GLib development prerequisites installed, a minimal user-mode build from the verified, unpacked source is: ``` mkdir qemu-10.0.14/build cd qemu-10.0.14/build ../configure --target-list=x86_64-linux-user --disable-system --disable-docs \ --without-default-features --disable-tools --disable-guest-agent \ --disable-plugins --disable-slirp --disable-pixman --disable-capstone \ --disable-fdt --audio-drv-list= ninja qemu-x86_64 ``` No installation or host binfmt registration is required. Keep its source digest, configure command, binary digest and `--version` output with the execution receipt. An emulator PASS still leaves physical x86 execution NOT_RUN. The exercised aggregate command is `python3 tests/native/x86/test_build_failures.py [EMPTY_OUTPUT]`, with the same environment as the runner above. It requires actual successful C, C++, Python, Rust (2021 and 2024), Zig and Go executions; failed Zig/Go compilers and missing toolchains must refuse aggregate PASS. The positive case also exercises the existing ABI-v2 pointer/status-32, signal-reentry/status-33, stale-identity and thread controls, private-symbol/TLS isolation, and boundary/API mutants. Added controls cover nested traps, bad-runtime/status-34 recovery, SysV saved-register sentinels, and the fixed owned-stack floor after out-buffer allocation. At the `62775d2a` pin all 150 baseline/output comparisons with `0c4cb9ff` passed byte-for-byte, including unchanged AArch64 freestanding refusals. #26 (`f637021`) then changed AArch64 output on purpose (f32 and ushort array kinds, the Python header), so the parity baseline is now the generator at `f637021`, the last accepted AArch64 contract; later `src/native.om` changes keep AArch64 output byte-identical to it (the x86 suite's `aarch64_parity` check). The generator at `f637021^` still matches `0c4cb9ff` on every pre-#26 fixture and output, so the chain back to the pre-x86 generator is unbroken. The receipts retain the earlier failing emulator run rather than rewriting it as a pass. #27 respelled the assembler directives (`OMBR_*` macros in `pre`, `fp`, `fr`, `fv`, `xjmp`) and the Python loader's library name, so the check first applies those spellings to the baseline source: a `~`-separated piece of those texts that equals the same piece at `7af4d11` takes that piece of blob `5115113` (`src/native.om` as #27 left it), and the two `tb` loader literals take #27's text. Both sides are pinned objects, so any other change to those texts in the tree still fails parity. `tests/native/macos/` (the host-word unit, whose C output gains the intended macOS `#error`) is not a parity fixture. ## What Omega produces For the default AArch64 target, a unit with no `fn main` is compiled by the seeded compiler (`seed/out/omc`) in function mode: raw AArch64 words, entry at word 0 (`docs/one_layer/OMEGESE.md` 9.1). Its rules (`docs/osc/OSC-1-DESIGN.md` section 7): parameters in x0..x5 (an `edit`/`view` array arrives as its address; its length is part of its type), result in x0, the runtime table pointer in x7. A trap loads its code into x1, the table into x0 and branches to the table entry at offset 16; it never returns. `madd` below compiles to three instructions (`mul x3, x0, x1; add x0, x3, x2; ret`). ``` fn madd a ulong b ulong c ulong to ulong p = mul a b ret add p c end ``` ## The binding `src/native.om` is an Omega program. It reads units (the unit's source, a 0 byte, the code length as 8 decimal digits, the code) and an argument naming the output: `c` is the library source, one C file; `h`, `python`, `rust`, `zig` and `go` are that library's declarations for those languages (next section), written from the same parsed signatures. An optional second argument `x86linux` selects the x86 binding; omitting it keeps AArch64 output. Output appears only after every unit is accepted; anything outside the supported signature set, and a missing or unknown output word or unknown target, is refused (exit 110, no output). The default AArch64 C file: - embeds each unit's code byte for byte (tests/native/run.sh compares the bytes inside the built library with the compiler's output); - enters the code through a small trampoline that saves the callee-saved registers x19..x28 and d8..d15 on the caller's stack, keeps the caller's stack pointer in x19, sets x7, loads the arguments and runs the code on the binding's own stack (below); - gives the code a read-only 32-entry runtime table whose trap entry restores the caller's stack pointer from x19 and returns the trap code from the exported function (no setjmp/longjmp, nothing crosses the caller's frame) and whose other entries refuse with status 34, since function-mode units of this ABI use none of them. The contract for a unit's code is what the trampoline guarantees: it may write x0..x17, x20..x28, v0..v31 and the flags (x20..x28 and d8..d15 are restored on a return and on a trap); it must not write x18 (the platform register, which the trampoline does not save), x19 or x29 and must keep sp balanced. The hosted and the freestanding trampolines give the same contract. OSC-1 (OM-1) allocates x0..x6, x8..x15 and x17, with x7 the runtime table and x16 scratch; an OM-2 omc with loop-constant hoisting (omega-mv perf/omc-loop-checks) also keeps loop constants in x20..x26, and its int/float conversions can write d8..d15. tests/native/v2 decodes `hoist`'s code (x20..x26 and d8..d15 written, x18, x19 and x29 never named in any unit) and calls both trampolines directly with a hand-assembled unit that writes x20..x29 and d8..d15, with one mutant per restore pair in each; - reaches each unit through a two-instruction stub (`bti c`, branch) so the code runs under branch target identification (BTI) without changing the compiler's bytes; - exports, per unit, `uint32_t omega_(uint64_t *result, ...)`. ### x86-64 SysV entry and trap contract The foreign entry point uses the Linux x86-64 SysV C ABI; embedded Omega code does not. Its private frame ABI stores arguments in the old RBP-relative, negative-offset slot area. The trampoline supplies the initial 256-byte area covering 18 storage slots, establishes the owned stack, and enters the selected six-byte JMP/NOP export slot. The Omega result returns in RAX. R12 retains the native stack anchor, R14 points to the read-only runtime table, and R15 holds the owned-stack floor. The trampoline restores the SysV callee-saved registers and the caller's stack on both success and trap return. The compiler's bare-unit trap hook must put the trap code in ESI and execute `jmp *16(%r14)` to runtime entry 2. The binding's trap handler uses the saved native anchor and returns that code as the public status; it must not terminate the calling process. A compiler that still lowers bare-unit traps to process exit does not satisfy this contract. The pinned candidate includes the bare-unit trap hook; compiler availability is not an execution receipt, and bridge trap-return exercise remains pending. Indirect entry veneers use `endbr64` for Intel CET indirect branch tracking (IBT) landing. This does not support CET shadow-stack enforcement: a trap's nonlocal return abandons intermediate Omega call frames rather than unwinding their shadow-stack entries. Do not claim shadow-stack compatibility or run this binding under enforced shadow stacks. None of these mechanisms changes the compiler's embedded machine bytes or the public argument/status contract. All private `ombr_` and `ombr2_` assembly labels have local binding; private C helpers, runtime tables and per-translation-unit TLS retain static linkage. Independently generated C units can be linked together without helper collisions. Their trap/stack/thread state remains distinct; public `omega_`/`omega2_` exports and compiler machine bytes are unchanged. `tests/native/test_private_symbols.py` regenerates two separate bindings, checks their `nm` visibility and exact public exports, exercises traps and concurrent threads, and requires a `.globl ombr_enter` emitter mutant to fail linking. The emitter has finite pools of `16777216` input bytes and `33554432` output bytes (two `16777216`-byte pools, the per-pool maximum) for the complete framed unit set and one generated output. Input must be strictly smaller than its pool (maximum `16777215` bytes); output may fill its pools exactly. Exhausting a pool traps with resource status 6 (process exit 106), before any generated output is written. This does not relax individual compiler, source-language, slot or unit-count limits. `tests/native/test_capacity.py` compiles a matching 64-unit frame exceeding the former `4194304`-byte input and `16777216`-byte output pools, builds and calls both endpoint units (`cap00`, and `cap63`, whose generated code lies past byte `16777216` and is therefore read from the second output pool `outc`) plus `cap15`, restores each old pool size as a failing mutant, and checks both current overflow boundaries. Its oversized output control is a hostile framing-only resource probe, not compiler-custody or behavioral evidence for the deliberately mismatched code. Names must be C identifiers, a parameter name may not end in `_len` (the binding names a length `o__len`), and each unit name appears once; anything else is refused before any C is written. Supported signatures: up to 6 parameters, each `ulong`, `long`, or `edit`/`view` of `ulong`, `uchar`, `f32` or `ushort` with a fixed length; result `ulong`, `long` or `void`. A length is a decimal number or the name of an integer constant declared on its own line before the signature as exactly `const NAME ulong DIGITS` (OMEGESE 9.12); any other spelling of a constant used as a length is refused, so a shape-specialised unit can be written as one fixed kernel text after a header of constants. An `f32` array is packed binary32 (4-byte elements, 4-byte alignment) and a `ushort` array is packed 16-bit words (2-byte elements, 2-byte alignment), for example binary16 bits that the Omega code converts itself. C and C++ declarations stay `void *` / `const void *`; the generated library checks the element size, alignment, length and overlap. Python ctypes uses `c_float` and `c_uint16`. Rust and Zig declarations type these arrays as byte pointers (`*mut u8` / `*const u8`, Zig `?[*]u8`); Go stays `unsafe.Pointer`. `OMEGA_NATIVE_OMC= sh tests/native/kinds.sh` binds `fsum.om` and `halve.om`, compares every lane to a C `_Float16` oracle, refuses misaligned, wrong-length, overlapping and null arrays (status 32), and requires a mutant that changes fsum's `add` to `sub` to fail. The same script calls both units through the `python` binding (`tests/native/pykinds.py`): lanes and halving against Python `struct` values, wrong lengths refused with status 32 and the arrays untouched, `f64`/`int32` arrays for an `f32` view, `bytes` for an `edit ushort` array and a 2^64 length refused by ctypes; the fsum mutant must fail there too. A unit may hold several functions: the seeded compiler enters function-mode code at the unit's last function (the leading entry branches to it), so the binding exports that one and the earlier functions stay private helpers, called directly inside the embedded code, with any Omega types. Only the last function's signature must be supported (`tests/native/hsum.om`: two helpers, one of which traps). ### Additive public float scalar profile `tools/native --float OUTDIR unit.om...` selects the exact seeded compiler omega-mv `e5b32567` for OM-1 units through `OMEGA_NATIVE_FLOAT_OMC`, sha256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. The baseline `OMEGA_NATIVE_OMC` still builds the generator and its pin does not change. Compiler custody records the selected digest in `work/ident.txt`. The profile is hosted AArch64 only; `--float --freestanding` and `--float --target x86linux` refuse before installing outputs. Direct framed-generator use must likewise select the optional `float` argument (or `fhost` with the existing host-word capability). Without it, every binding mode refuses public float signatures with exit 110 and no stdout. The checked wrapper selects these tokens; it does not broaden the default profile. `--float-next` is an explicit draft profile, selected through `OMEGA_NATIVE_FLOAT_NEXT_OMC`; it pins the omega-mv #1049 candidate at `7e93ca8e29b3fe81314a88c9f1cb70666fca27f5`, executable sha256 `d89bdc08ca21ea9726f1117adc791f683287d3698ea112a9db5519df2e79aeec`. It adds the compiler's scalar `fma` and correctly rounded decimal literals; it has the same hosted AArch64 OM-1 restriction. It is not an implicit refresh of the e5, OM-2, baseline generator, or BridgeHost's integrated compiler pins. Public parameters/results may be `f32` or `f64` in addition to the existing integer signatures. C uses `float`/`double`, Rust and Zig `f32`/`f64`, Go `float32`/`float64`, and Python ctypes `c_float`/`c_double`. The result pointer has the matching scalar type. No arithmetic conversion is used for the native frame: the adapter copies the IEEE bits to/from its canonical integer slots. A float result occupies 4 bytes, not 8, for alignment, overlap and store checks; a double occupies 8. Invalid arguments and traps leave the result unchanged. Python callers can pass a ctypes scalar and inspect result storage with `from_buffer_copy` to retain signaling-NaN payloads without Python float conversion. The caller must retain the seeded floating environment (round-to-nearest-even, subnormals enabled); changing FPCR or using fast-math is outside the contract. `tests/native/float.py` calls the same f32/f64 identity units from C, Python, Rust, Zig and Go, comparing raw NaN payload, signed-zero, denormal and infinity bits. It also checks mixed f32 scalar/view/edit frame slots, array counts, result and mutable-view alias refusals, null results, unsupported profile combinations before output, unprofiled framed-generator refusals, explicit `--host` C marshalling, and kills one result-marshalling mutant per float width. Missing language toolchains are explicitly NOT_RUN, not PASS. OM-2/v2 float signatures and freestanding floats remain outside this profile. Run both profiles with the baseline generator compiler and available toolchains: ``` export OMEGA_NATIVE_OMC=/path/to/baseline-734f0a39-omc export OMEGA_NATIVE_FLOAT_OMC=/path/to/e5b32567-omc export OMEGA_NATIVE_FLOAT_NEXT_OMC=/path/to/draft-1049-omc # RUSTC, ZIG and GO may name installed executables not on PATH. bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 python3 tests/native/float.py bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 env OMEGA_NATIVE_FLOAT_PROFILE=next python3 tests/native/float.py ``` ## Pure freestanding output `OMEGA_NATIVE_OMC= tools/native --freestanding OUTDIR unit.om...` installs `omega_native.c`, `omega_native.h`, `omega_native.o` and compiler-custody `work/` files. Direct framed-input users select generator output `freest`; declarations remain output `h`. Both the default `aarch64linux` target and `--target x86linux` support this output. For OM-1 the public ABI is unchanged: `uint32_t omega_(uint64_t *result, ...)`, with `ulong`/`long` scalar arguments and `ulong`, `long` or `void` results. Compiler bytes are embedded unchanged. A trap returns its status and leaves `*result` unchanged; success writes the result (zero for `void`), and bad result arguments return 32. Unlike hosted output `c`, this mode runs on the caller's stack and needs no pthread, mmap, heap, TLS or mutable runtime state. Its private trampolines and read-only runtime table have translation-unit-local linkage. Nested traps unwind to that call's saved frame, so independent calls and threads do not share trap or stack state. The caller must provide sufficient stack for the compiled functions and their local/out arrays; there is no separate guarded stack, stack-allocation status or hosted reentry restriction. The emitter validates every source token, including unused helpers. An OM-1 unit remains integer-scalar only: integer/bool types, decimal integer literals, scalar locals, functions, arithmetic, comparisons, control flow, contracts and traps. Its arrays and floating-point operations remain refused. OM-2 additionally admits views, layouts, local/out arrays, unrolling, rotations, remainder and private `f32`/`f64` operations with an integer-only public ABI. Public float parameters, results and view elements, globals, text and host words remain refused with exit 110 and no output. An OM-2 frame without its `omega-unit` trailer is also refused. Ordinary compiler source validation still applies. As with hosted transport, framed source and machine bytes must come from the same pinned compiler invocation; this is not an arbitrary-bytecode sandbox. `tools/native` snapshots each input once in private scratch storage; profile detection, compilation, framing and identity all consume that same snapshot. The objects are built with `-ffreestanding -fno-builtin -fno-stack-protector`, against the generated public header. Their unresolved imports must be empty except for the toolchain's `_GLOBAL_OFFSET_TABLE_` linker marker: no libc helper is allowed, including `memcpy`, `memmove` or `memset`. Failed symbol extraction or filtering is a refusal, not an empty accepted import set. Any refused import/inspection leaves prior outputs untouched. `tests/native/test_freestanding.py` exercises epoch increment/MAX refusal, nested trap unwind, independent scalar units, concurrent threads, non-pure source refusals, a pthread-emitter mutant, failed inspectors and a deterministic source-swap control whose old-reread mutant admits mismatched source/code and is caught. OM-2 freestanding (the same `--freestanding` flag with an OM-2 unit; output `freest`). An OM-2 unit without host effects is accepted: its compiler bytes are embedded unchanged and bound as `omega2_`, with the same argument checks as output `c` (views, layouts, out, overlaps). Each out parameter is a zero-filled, 16-byte-aligned buffer in the entry's own frame, rounded up to 16 bytes, passed in its slot and copied back to the caller only after status 0; a nonzero status (a trap, a refused argument) leaves the caller's buffer as it was. The runtime table has one entry, the trap, and nothing else: no TLS, no heap, no stack mapping, no pthread and no stack guard, so the caller must provide a stack large enough for the compiled functions. There are no C library calls: small static byte-transport helpers zero and copy the private out frame through volatile byte stores so C optimization cannot substitute libc calls. The copy source is the entry's private out frame, disjoint from the checked caller destinations; the existing caller-overlap refusal and status-0 copy-back rule are unchanged. A borrowed byte view (`view uchar *`) is admitted on this profile, on both targets, with no libc. The scan never inspects past the bound: an index at or past `len` traps inside the unit, and the wrapper does not walk the pointer. An empty view is admitted, including a NULL pointer with length 0, and its length is 0. A nonempty NULL pointer is refused with status 32 before the unit runs, and the result slot is left unchanged. `tests/native/freestanding/pathlen.om` is that scan (`omega2_pathlen`). `tests/native/test_freestanding_pathlen.py` compares it with a bounded `memchr` for every length 0..256 and every terminator position in that window (WolframLanguageEvaluator: `Sum[n + 1, {n, 0, 256}] + 2` -> 33155), plus three guard pages placed on the next byte, and kills six source mutants and one generated nonempty-NULL mutant on AArch64 and under x86 QEMU. That is host and EMULATED evidence, not chip qualification. Private `f32` and `f64` use the target's hardware floating-point instructions. The caller must enable hardware FP and provide its normal ABI control modes; the wrapper does not configure FPCR/MXCSR control bits. FP exception/status-flag preservation is not promised. This is not soft-float, kernel/firmware FP-state management, or firmware qualification. Public arguments/results and view elements remain integer-only. The source whitelist parses decimal/exponent literals with optional `f32`/`f64` suffixes and function parameter names separately from their types; an unsupported type must not become an accepted identifier through a malformed declaration. The existing binary64 oracle is unchanged: exact C bit comparisons include negative zero, a subnormal and quiet-NaN operands. The x86 compiler reproduces Arm's positive default NaN; that oracle corrects only C's exact negative-indefinite result for signed-zero divided by signed-zero, never an Omega result or operand NaN. Its controls reject a different payload and nonzero status and require negative operand-NaN propagation in both positions. The separate binary32 oracle (`tests/native/freestanding/f32.{om,c}`) uses round-to-nearest, ties-to-even and gradual underflow. Other FP control modes are not qualified. Non-NaN arithmetic results must match C's non-contracting IEEE operations bit-for-bit; arithmetic NaNs compare by class only, with `0x7fffffff` as the documented comparison canonicalization. Operand cases include that canonical qNaN and other payloads. NaN-result payloads are not asserted, including raw zero-divided-by-zero bits. Neither the bridge nor the caller rewrites integer-ABI outputs: the identity operation must preserve even NaN operand bits exactly, and bare/hosted raw output streams must agree for the same compiler. Separate multiply/add, RNE ties and subnormal controls are backed by the Wolfram queries in the FP32 receipt. Source mutants change add to subtract, widen a product before add, and incorrectly canonicalize an integer identity result; all must be caught. The bounded source-name registry contains at most 1024 distinct spellings, not assignment occurrences. Reusing a name, including at full capacity, does not consume another slot; a new name beyond the bound refuses with exit 110. Fixed view extents may use the same earlier positive `const NAME ulong DIGITS` syntax as public extents. A constant extent is consumed without registering a following type as a parameter name; layout views and `fresh` checks retain their existing boundaries. With an OM-2 unit, `--freestanding` also installs `omega_api_decl.h` and `omega_api_defs.{c,o}` (output `fapic`): the same prototypes as output `apih`, but each definition calls `__builtin_trap()` on a nonzero status instead of `abort()`, so the definition object imports no C library function either. It does not install `omega_api.h`, whose inline wrappers call `abort()`. The two objects are inspected together: a global definition in one satisfies a reference in the other (the wrappers calling `omega2_*`), and every other unresolved import must be absent except `_GLOBAL_OFFSET_TABLE_`. `tests/native/test_freestanding_om2.py` (run by `tests/native/v2/run.sh`, step 10b) links the two objects with `-r -nostdlib`, requires no runtime imports, and compares the same caller against hosted output. It exercises FIPS 180-4 digests of `sha256-om2.om` (empty, abc, the 448-bit message, a million `a` through a split update), untouched out buffers after refusal/trap, four hashing threads, private-f64 bit parity and the trap wrapper (exit 133, SIGTRAP). Attributed mutants remove copy-back, write the wrong zero fill, copy on trap, reintroduce a real libc import, and restore duplicate-name exhaustion. Scanner-only framed controls check the exact distinct-name boundary, named/fresh extents, layout-view alignment and private-type/host/storage refusals; deliberately reused frame code is never executed. With `--target x86linux --freestanding` the same OM-2 units are bound through the x86 SysV adapter, with the same out-buffer and import rules. `tests/native/x86/suite.py` (step `freestanding_om2_x86`) cross-builds `fsom2.c` against that output and runs it under QEMU: same digests, untouched out buffers and four threads, the trap wrapper (`ud2`, SIGILL), and the copy-back mutant must leave the pre-call fill in all four digests. That is EMULATED only; native x86 is NOT_RUN. `tests/native/test_freestanding_f32.py --out OUTDIR [--target x86linux]` separately qualifies private FP32 behind the integer-only public ABI: a static no-libc ELF has no undefined symbol, interpreter or TLS and emits the exact raw hosted byte stream. All fourteen public-float parameter/result/fixed-view/edit/out/dynamic-view/edit fixtures compile before direct generator refusal110 with empty stdout, then CLI refusal110 without installed output. The direct check cannot mistake a generator crash for refusal. The unused host-helper control deliberately reuses a clean frame's code solely to reach the whole-source scanner, requires refusal110/no output, and is never executed. Two counted generator mutants remove private-FP32 admission or its literal suffix and must restore refusal110; three source mutants and a wrong-result control must fail their exact runtime assertions. The OM2 test invokes this on AArch64; the x86 gate's `freestanding_f32_x86` step uses its existing guest runner for both bare and hosted callers. `tests/native/test_freestanding_aggregate.py --regalloc CUDAPP_REGALLOC_TREE --core CUDAPP_CORE_TREE --out OUTDIR [--target x86linux]` qualifies the actual six-unit composition without depending on an unpinned checkout location. The allocator owner’s portable `regalloc.om`, `regalloc_ir.om`, `regalloc_live.om` each receive exactly an `om2` line in an immutable input copy; the originals are unchanged. CoreUtil's `native.om`, `cubin.om` and `ampere.om` are already OM-2 and copied unchanged. The receipt records both original-source and composed-input hashes. One generated library contains all six units. The caller executes allocation, IR/liveness decisions, a full-size graph edit, private log-one, padded NOP encoding and CUBIN metadata refusal; it is not the full CUDApp test suite. A linked `-nostdlib -static` Linux ELF must have no undefined symbol, interpreter or TLS, run successfully and produce bytes identical to the same hosted caller. A wrong-length large fixed span must refuse with status 32 and leave outputs unchanged; the wrong-result control must exit 90. C in this test is only an ABI/syscall verification oracle, never the implementation of those algorithms. Adding `--api CUDAPP_API_TREE` composes the actual portable `api_policy.om`, `api_mm_plan.om` and whole `api_at_plan.om` from `om/components/` with the same exact `om2` prefix, for nine units in one library. No attention modes are removed. Portable OM-1 sources are not accepted by the freestanding array path without that explicit composition; the OM-1 scalar boundary is unchanged. The additional bare caller exercises policy remainder acceptance/refusal and matmul plan edits against Wolfram-derived words; short views leave both result and all input words untouched. It calls attention modes 0, 7, 22 and 23: integer planning/refusal, scale validation (including signed zero, finite limits, infinity and NaN), private-FP32 conversion and the binary64 Newton path. Exact output bits are derived with per-operation rounded Wolfram queries; integer outputs are not canonicalized. Mutating the policy remainder predicate exits14, the matmul output write exits15, attention scale validation exits19 and attention's FP32 output packing exits20. Each mutation applies exactly once in a separate copied input; baseline snapshots remain unchanged. This is not the full CUDApp API test suite. Run every acceptance command in a device-free namespace, including mutants and emulation: `bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 COMMAND`. No NVIDIA, cuse or VFIO device is available inside it. Native AArch64 host evidence and x86 EMULATED evidence do not qualify firmware FP state, physical x86 or GPU execution. Receipts: first pure freestanding OM2 profile records the immutable eight-unit profile at `12f8132c`, including its then-correct whole attention/private-FP32 refusal. The private-FP32 followup records the new nine-unit profile, bit oracles, refusal boundaries and fresh regression commands. The full AArch64 V2 gate's known hoist failure is not a green gate; its exact fresh verdict belongs in that receipt. Physical x86, firmware and chip qualification remain NOT_RUN. Drake must review and approve this draft contract before merge. ## The declarations for each language (`tools/native`) `OMEGA_NATIVE_OMC= tools/native OUTDIR unit.om...` compiles the units with the selected target's compiler, runs the generator once per output word and installs, into OUTDIR: file for how a program uses it `omega_native.c` the library source built into `libomega_native.so` by the same command `omega_native.h` C and C++ `#include "omega_native.h"` (`extern "C"` inside for C++) `omega_native.py` Python 3 (ctypes) `import omega_native`; loads `libomega_native.so` from beside itself `omega_native.rs` Rust 1.82 or later, edition 2021 or 2024 `mod omega_native;` beside the crate root; link with `-L OUTDIR` `omega_native.zig` Zig 0.13 `@import("omega_native.zig")`; build with `-L OUTDIR -lomega_native -lc` `omega_native.go` Go (cgo) package `omeganative`: a folder of that name holding the file, `omega_native.h` and the library `work/` the test driver the generator and each unit's compiled code; not an interface Every file carries the unit's Omega signature line as a comment above its declaration, the five status constants (0, 32, 33, 34, 35) and the parameter names prefixed `o_` (so no language's reserved words collide). The scalar type is the language's unsigned 64-bit integer, an array is a pointer then a `uint64_t` count, the status is unsigned 32-bit: C `uint64_t` / `void *` / `const void *`; Rust `u64` / `*mut u64`, `*mut u8`, `*const u64`, `*const u8` (declared in an `unsafe extern "C"` block); Zig `u64` / `?[*]u64`, `?[*]u8`, `?[*]const u64`, `?[*]const u8`; Go `uint64` / `unsafe.Pointer` to memory holding no Go pointers. Python checks instead of trusting: a scalar is an `int` in 0 .. 2^64-1 (a `long` is passed as its two's-complement bits) and anything else, including a negative or an out-of-range value, raises `ctypes.ArgumentError` rather than being truncated; an array is a ctypes array of its element type (`POINTER(c_uint64)` for `edit`/`view ulong`, `POINTER(c_ubyte)` for `edit uchar`, `c_char_p` for `view uchar`, which also takes` bytes`), and an` edit`array must be writable, so`bytes` are refused there. The result pointer is `uint64_t *`, `ctypes.POINTER(c_uint64)` (pass `ctypes.byref`), `*mut u64`, `?*u64`, `*uint64`. The Go file wraps each C function as `Omega_` so the caller needs no cgo of its own; its preamble includes the generated header (so the Go side and the C side cannot disagree) and bakes in no run-time path: the program's build names the folder (`CGO_LDFLAGS=-Wl,-rpath,`) or `LD_LIBRARY_PATH` does. Everything is produced in a scratch folder and installed together after the library compiles. A unit outside the subset, or a name the binding cannot carry, is refused by name (exit 110): nothing is installed and a previous run's outputs in OUTDIR stay as they were. The library is compiled with its own header included (`-include omega_native.h`): a declaration that disagrees with a definition fails that build, so the C file and the header cannot drift apart. The other four files are checked by the qualification below, where each language builds its caller against its generated file only and a one-word type change in the generator must make that build or run fail for the stated reason. ## Contract scalar argument `uint64_t`, the canonical bits of its type; a `long` is its two's-complement bits (-3 is `18446744073709551613`) array argument `void *` (`const void *` for `view`) then `uint64_t` element count, which must equal the declared length; elements are 8 bytes (`ulong`), 1 byte (`uchar`), 4 bytes (`f32`, IEEE-754 binary32) or 2 bytes (`ushort`), and the address must be aligned to the element size result written only on status 0; a `void` function writes 0 status 0 success status 1..14 the Omega trap code (1 overflow, 2 divide by zero, 3 bounds, 4 loop bound, 5 conversion, 6 resource, 7 shift, or a `trap N` code) status 32 foreign argument refused: null pointer, wrong length, misaligned, address overflow, a writable array overlapping any other array or the result status 33 reentry on the same thread (for example from a signal handler during a call) status 34 the code reached a runtime entry this ABI does not provide status 35 the binding could not map its stack for this thread Buffers stay owned by the caller and are borrowed for the call only; Omega keeps no address after it returns. Writes made before a trap stay visible (no rollback). Calls on different threads are independent. The runtime table is one read-only table shared by every call and thread (the code only reads it); a write to it would fault. Stack: on its first call from a thread the binding maps 8 MiB of stack for that thread above an 8 MiB no-access guard, and frees both when the thread exits. The caller's own stack size does not matter (a 4,000,000-byte local array runs from a 256 KiB C thread and a default 2 MiB Rust thread). A function-mode unit has no call cycles and at most 4 MiB of local arrays per function, so a frame that would pass the bottom starts inside the guard and the process faults there; memory below the guard is never written. That fault is a crash, not a status: in function mode the seeded compiler does not check the stack floor before reserving a frame (program mode traps 6 instead). A clean status needs that check in the compiler; it is a compiler gap, not something the binding can add around the code. Host words are not an isolation boundary: permitted function-mode operations make Linux system calls directly in the calling process, using its descriptors. Legacy x86 `read`/`write` use the `om4`/`VT_SYS` path and `xio`, permitted in bare units. With the separately pinned hosted compiler, `xhost` admits the same bounded OM-2 subset as AArch64; OM-1 units and other host words still get compiler error9. Its helpers preserve the binding's R12 native anchor, R14 runtime table and R15 stack floor, use RBX for their saved-slot snapshot and restore R13 scratch before returning. The program-mode syscall emitters are shared, not duplicated. macOS numbers its system calls differently, so an AArch64 unit whose code holds an `svc` instruction word is Linux-only: the generator puts `#error` for that unit under `__APPLE__` (see Platforms). Signals: a call from a signal handler while a call is running on the same thread returns 33. A handler that leaves Omega code with `siglongjmp` abandons the call; every later call on that thread returns 33. ## AArch64 qualification (`OMEGA_NATIVE_OMC= sh tests/native/run.sh`) The compiler is pinned by sha256 (`734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61`, omega-mv PR #696). Expected values come from receipts, not from Omega: (2^64-1)2+5 mod 2^64 = 3 (calc:`93e7b00a`); `1311768467463790320``18364758544493064720`+`1085102592571150095` mod 2^64 = `3637949782307626511` (calc:`9bf5b67e`, Wolfram agrees); -13 as 64-bit bits = `18446744073709551603` (calc:`cbb0735b`); 0+1+...+999999 = `499999500000` (calc:`3f197279`). The six callers (C, C++, Python, Rust, Zig, Go) take every Omega declaration from their generated file (the run fails if any caller source declares an `omega_` function, sets ctypes `argtypes`, loads the library itself or carries its own cgo). All six check values, wrap-around, signed bits, a signed overflow trap with the result left unchanged, a trap after two buffer writes (writes visible, result unchanged), a successful buffer call, a refused null result (C++: a wrong length) and the six-parameter unit `mix` (`view`/`edit` `uchar` and `ulong` arrays, no result: success with the void result written as 0, a `trap 9` after two writes with the result unchanged, a conversion trap 5 after one write). The Python caller also checks that the binding refuses 2^64+3, -1 and 2.0 as scalars and `bytes` for an `edit` array, and that a call works after those refusals. The C caller also checks a null buffer, a wrong length, misalignment, result/buffer overlap, a view overlapping an edit array, a call after traps, reentry from a signal handler (status 33), a trap from a frame holding a 4,000,000-byte local array, that array on a 256 KiB thread, and that x19..x28 and d8..d15 keep the caller's values across a normal return and a trap raised in a callee of the exported function, and runs the hoisting unit on two threads. The Rust caller runs the array on a default thread and is built twice, under edition 2021 and edition 2024, with warnings as errors. The C caller runs a second time against a library built with BTI enforced. `tests/native/reference.c`, prototypes for the seven test units (with `hsum`, bound at its last function) written by hand from this contract, is compiled with the generated header included: a disagreement is a conflicting-types error. The generator is shown to refuse a non-C unit name, a parameter ending in `_len` and a repeated unit name, and to accept the same unit once; `tools/native` is shown to refuse a unit with a `uchar` result by name, with exit 110, leaving a previous run's outputs untouched. Not exercised: status 34 and 35 (no supported unit reaches another runtime entry; mapping failure is not induced). Qualification requires an executed PASS for each caller (`c`, `c-bti`, `cpp`, `python`, `rust`, `zig`, `go`). A present Zig/Go toolchain that fails to build emits `FAIL` and makes the runner exit nonzero. A missing toolchain emits `NOT_RUN` and makes the runner exit nonzero, not a qualified PASS. Run `OMEGA_NATIVE_OMC= sh tests/native/test_build_failures.sh` to check build-failure and missing-toolchain controls, followed by positive calls with the real Zig and Go toolchains. The historical `evidence/native-call-v1/run.log` predates this runner correction and is not rewritten. Red before green (this change): with the generator of commit `e7777ca`, the C caller dies with SIGILL under BTI, and the 4,000,000-byte array on a 2 MiB thread dies with SIGSEGV; with this generator both pass. Extra receipts: 5+20+7 = 32 (calc:`08302bc4`), (7+1)+7 = 15 (calc:`e44bce3f`), 5+20+300 exceeds 255 by 70 (calc:`a6a8bb76`), 4,000,000 bytes is 0.954 of 4 MiB (calc:`ffff21b2`). Negative control: madd's `add` changed to `sub` in the code must make the C caller fail. Separate claims, not made here: source translation (ABI v0) and GPU execution are qualified on their own. These historical qualification results cover AArch64 Linux, not the x86 target. `f32` arrays and constant lengths (2026-10-26, for `pytorch/`): exercised by `pytorch/tests/test_omega_torch.py` (class `Binding`: a `const L ulong 6` f32 unit binds with element size 4 and the right writable flags; a `const L uint 6` length and an `f64` array are refused with exit 110 and no output) and by every PyTorch op test, which calls f32 units through this binding. Those tests use the omega-mv main compiler (`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`, omega-mv `369dbc96`), because floats are newer than the pin above. `tests/native/run.sh` with the pinned compiler still prints `NATIVE-CALL PASS` with this generator. After merging main `7af4d11` (2026-11-04), the f32 kinds are #26's and this change adds only the named lengths (the unit start is kept in `st 9`). The generator now takes its output word as argument 1, so the PyTorch glue and the `Binding` tests call it with `c`; before that fix every unit was refused with exit 110, which the two refusal tests could not tell from a real refusal. Rerun: 22 tests OK (`evidence/omega-torch-m1/tests-merge-main-7af4d11.log`); with `pparam` reverted to `tknum` (named lengths unread) `test_const_f32_bound` fails and `Ops.test_mm` errors with the refusal (exit 110) (`evidence/omega-torch-m1/mutant-const-length-tknum.log`). Which compilers reach a named length (issue #20, 2026-11-04, `evidence/issue-20-const-length/red-green.log`): the AArch64 OM-1 pin `734f0a39` refuses `const` itself (`omc: line 8: error 9`), so through `tools/native` an AArch64 OM-1 unit with a named length stays refused until that pin moves past omega-mv #806. The x86 pin `be8c5130`, omega-mv main `b4f45121` and `2c824805` accept it and emit code byte-identical to the literal form. With `--target x86linux`, main `7af4d11` refuses the unit with exit 110 and this generator binds it; the bindings differ from the literal unit's only in the echoed signature comment, and a C caller under QEMU 10.0.14 gets the same result and the same wrong-length status 32 (EMULATED; physical x86 NOT_RUN). An undeclared name is refused by the compiler (error 16). Zig and Go: run with Zig 0.13.0 and Go 1.27.3 (official aarch64 archives, checksums from ziglang.org/download/index.json and go.dev/dl, unpacked in the user's ~/.local/opt). Both callers pass their checks (12 each in this change). The library is linked with `-soname libomega_native.so`: without that name, Zig records the library as `./libomega_native.so` and the caller fails to load outside the build folder (red: `dd8b9a9`; green: `1e40844`). The embedded code is unchanged by the name. Generated declarations (this change): before it, each caller typed its own prototypes and a wrong type there was the caller's mistake to find. Now `tools/native` builds everything and the generator writes the six files above from the parsed signatures; the C output is byte for byte what the previous generator wrote. The run adds: the no-hand-declaration check; the hand-written reference prototypes; the `tools/native` refusal; refusals of a missing and of an unknown output word; and five generator mutants, one per binding, each changing one scalar type word on the generator's text line (`uint64_t` to `uint32_t`, `c_uint64` to `c_uint32`, `u64` to `u32` twice, `uint64` to `uint32`). The run checks that each mutant changes exactly one generator line and is caught for the stated reason: the header mutant by the library build (`conflicting types for omega_madd`), the Python mutant by wrong results (seven of the eighteen checks fail: the scalar is truncated to 32 bits), the Rust mutant by `mismatched types`, the Zig mutant by` type 'u32' cannot represent integer value`, the Go mutant by` cannot use ... as uint32 value`. Found by reading the output before the run, not by a test: the first Go wrapper called `C.omega_(` with no name; the test that would have caught it is the Go build, which this change runs. Review of the first version of this change led to: the Rust block declared `unsafe extern`(edition 2024 rejects a plain`extern` block); Python scalars range-checked and arrays typed per kind instead of `c_void_p` (which took `bytes` for a writable array and truncated scalars silently); the Go preamble including the header instead of repeating prototypes, with no baked run-time path; `tools/native` producing in a scratch folder, installing together, and naming the refused unit. ## Platforms: macOS arm64 (`sh tests/native/macos/run.sh bundle|run DIR`) One generated AArch64 C file builds on Linux (ELF) and on macOS arm64 (Mach-O); any other object format stops at `#error`, and so does any other architecture than AArch64 (x86-64 has its own target, `--target x86linux`, ELF only). The freestanding object is ELF only. Only the assembler spelling differs, through the `OMBR_*` macros at the top of `omega_native.c`: on Mach-O, C names carry a leading underscore, the code goes in `__TEXT,__text`, there is no `.type`, `.size`, `.local` or `.hidden` (a symbol that is not `.globl` stays local to its object), and `ombr_trap`/`ombr_no_entry` are `.alt_entry` points of `ombr_enter` with the assembler-local label `Lombr_leave`, so the linker cannot split them from the shared exit path. On ELF the macros spell the directives the previous generator wrote: for the AArch64 v1, ABI v2, freestanding and x86-64 units, `tools/native` output from this generator and from `7af4d11`'s differs only in the text of `omega_native.c` and `omega_native.py`; the libraries, the freestanding object and the other declaration files are byte-identical. - x18 is reserved on macOS. The seeded compiler's code uses x0..x16, x29 and x30; the macOS runner disassembles each embedded unit and refuses any `x18`/`w18` (with a control that writes x18). - `hint #34`/`hint #38` (BTI landing pads) execute as no-ops where BTI is not enforced. - The stack mapping uses `MAP_NORESERVE` and `MAP_ANONYMOUS`, both provided by macOS with `-std=gnu11`; the pthread key destructor frees each thread's stack on thread exit on both systems. - Units with host words build on Linux only (see Host words). - The Python binding loads `libomega_native.dylib` when `sys.platform` is `darwin`, otherwise `libomega_native.so`, from its own folder. Generating needs Linux AArch64, because the seeded compiler is a Linux AArch64 executable: run `tools/native OUTDIR unit.om ...` there and copy `omega_native.c`, `omega_native.h` and `omega_native.py` to the Mac. Build there with `clang -std=gnu11 -O2 -fPIC -shared -install_name @rpath/libomega_native.dylib -include omega_native.h -o libomega_native.dylib omega_native.c`. macOS qualification, in two steps: `OMEGA_NATIVE_OMC= sh tests/native/macos/run.sh bundle DIR` on Linux AArch64 runs `tools/native` on the seven test units and writes the bundle; `sh DIR/run.sh run DIR` on macOS arm64 needs only clang, its tools and python3. It builds the dylib, compares each unit's embedded bytes with the compiler's output, checks for x18, runs the C and Python callers, checks that the add -> sub mutant of `madd` is both embedded as generated and caught by the C caller, and checks that the host-word unit `tests/native/macos/hostw.om` is refused by the macOS build. Last line: `NATIVE-CALL-MACOS PASS`. The C++, Rust, Zig and Go callers, the BTI-enforced build, ABI v2 units and the measurements are exercised on Linux only. ## G1 sample (`OMEGA_NATIVE_OMC= sh tests/native/g1/run.sh`) omega-mv #624 milestone G1: `fn calc i0 ulong i1 ulong to ulong` computing `(i0 + i1) * (i0 - i1)` modulo 2^64 with a `new ulong` SSA array in the lowering form of `spec/universal/translation-v1.md` section 5. `OMEGA_G1_UNIT` names the unit: by default `tests/native/g1/calc.om` (hand-written, no semantic `note` line); `tests/native/g1/calc.lowered.om` is the unit the omega-mv pipeline generated from C (`c-import | lower`, producing command and commit in `tests/native/g1/README.md`). The bound function's name and arity come from the unit's last `fn` line and must be `calc` with two inputs (what the callers and the reference implement). `tools/native` builds it; the C, C++, Python, Rust, Zig and Go callers read `i0 i1` lines and print `i0 i1 status result`, and each output must equal, line for line, the Python bigint reference (`tests/native/g1/reference.py`) on 81 vectors: every ordered pair of 0, 1, 2, 2^32, 2^63-1, 2^63, 2^63+1, 2^64-2, 2^64-1. Negative control: the unit with its first `sub` changed to `add` must disagree. The run writes `build/g1/manifest.json`: the unit, its function and arity; the source identity (sha256 of the `.om` bytes); the semantic identity (section 4) when the unit's first line is `note omega.universal.lower.v1 semantic `, else null; the omc, `src/native.om` and `tools/native` sha256; the code, library and binding sha256; ISA aarch64, the ELF class and machine from `readelf -h`, ABI `omega-native-v1`, OS Linux; and each caller's status (PASS, FAIL or NOT_RUN for a missing toolchain) with its vector count and toolchain path. ## ABI v2: OM-2 units (omega-mv #747, contract `spec/omegese-om2.md` section 6, errata E1 and E5) ABI v2 adds to every v1 rule and check above; nothing in v1 changes. An OM-2 unit is one whose first line that is not a note (a line whose first word is `note`) is exactly `om2`; a first such line that starts with the word `om2` but is not exactly `om2` (`om2 diag`, `om2 fmt`) is refused. Every other unit is OM-1 and gets the v1 binding, byte for byte what the generator of `f637021` writes (checked on every unit in `tests/native` and `tests/native/g1`, alone and as the v1 suite's set, in all six outputs; the baseline was `3f05908` until #26 (`f637021`)'s f32 and ushort kinds changed the Python output for every unit). Symbols. Every OM-2 unit is bound as v2, whatever its parameter kinds (erratum E1): each `export fn NAME` (source order) gets `uint32_t omega2_NAME(uint64_t *result, ...)`; without any `export`, the last `fn` is bound (the v1 rule). No `omega_NAME` is emitted for an OM-2 unit, so a caller built from v1 declarations fails to link (the explicit refusal), and every binding names the v2 symbol. Functions that are not exported stay private: no symbol. All exports of a unit share its embedded code and the library's one runtime (stack, table, reentry flag). Bound names (v1 unit names and v2 exports) share one table: a repeat is refused. AArch64 calling convention (agreed with the OM-2 compiler lane, omega-mv S4, ledger L834). Parameters go to x0..x5 in order, result in x0, runtime table in x7, trap through entry 2 with its code in x1 (as v1): Omega parameter slots C argument(s) checks before any Omega code runs (status 32) `x ulong`, `x long` 1 `uint64_t o_x` (a long is its two's-complement bits) none `a view T *`, `a edit T *` (unsized) 2: pointer, then the element count `const T *o_a` (`T *o_a` for edit), `uint64_t o_a_len` if `len > 0`: not NULL; aligned to sizeof(T); `len * sizeof(T)` fits in 64 bits; `ptr + len*sizeof(T)` does not wrap (the end may be at most 2^64-1). `len == 0` is the empty view with any pointer, NULL included, and adds no range `a view T N`, `a edit T N` (sized) 1 `const T *o_a` / `T *o_a`, `uint64_t o_a_len` the v1 checks: not NULL, count == N, aligned, no wrap `c view L`, `c edit L` (layout `L` of SIZE bytes) 1 `const uint8_t *o_c` / `uint8_t *o_c` not NULL; no wrap (alignment 1) `o out T N` 1 `T *o_o` (no count; erratum E1) not NULL; aligned to sizeof(T); no wrap T is any of `uchar ushort uint ulong byte short int long` (C `uint8_t` .. `int64_t`). At most 6 slots; the result is `ulong`, `long` or `void`; parameter names follow the v1 rules (C identifier, no `_len` ending). Overlap (half-open ranges, empty ranges excluded): refused when an `edit` range (arrays and layouts) or the result buffer overlaps any other range, or two `out` ranges overlap; an `out` range may overlap a view. Status 33 keeps its v1 meaning (reentry); 34 and 35 as v1. Outputs. Each `out` parameter is a buffer the binding owns, carved from the top of the calling thread's Omega stack, 16-byte aligned and zero-filled before the call, passed in its slot. Only after status 0 is it copied to the caller's pointer with `memmove`, so it may overlap the inputs (`sha256_hash(buf, n, buf)`), and nothing is written there on a trap or refusal. The generator refuses more than 65536 out bytes per export (they come out of the 8 MiB thread stack). Multi-entry code. With AArch64 exports, words 0 .. E-1 of the unit's code are `b ` (E <= 32, the compiler's limit); the binding enters export k at byte 4k, through its own `bti c` stub, and refuses code shorter than 4E bytes. For `x86linux`, each entry is a six-byte JMP/NOP slot and the binding selects the corresponding slot; it must not apply AArch64 word offsets or BTI stubs. Identity. Each OM-2 binding embeds `omega-ident 1 unit=U abi=2 profile=OM-2 src=S omc=C`: U the unit's file basename with every byte outside `[A-Za-z0-9_]` made `_` (`sha256-om2.om` gives `sha256_om2`), S the sha256 of the unit's exact source bytes, computed by `src/native.om` itself (a FIPS 180-4 SHA-256 in Omega), C the sha256 of the compiler that wrote the code (`OMEGA_NATIVE_OMC2` for AArch64 or the pinned `OMEGA_NATIVE_X86_OMC` for x86), supplied by `tools/native` (contract C3: the compiler does not report its own identity). The library exports `const char *omega2_ident_U(void)`; each binding carries the expected string: C/C++ `OMEGA2_IDENT_U`, Python `OMEGA2_IDENT_U` (bytes; importing the module raises `ImportError` when the library's string differs), Rust `OMEGA2_IDENT_U: &str`, Zig `OMEGA2_IDENT_U`, Go `Omega2Ident_U` and `Omega2_ident_U()`. OM-1 units embed no identity (their bindings stay byte-identical); `tools/native` writes every unit's identity, the OM-1 ones with `abi=1 profile=OM-1` and the selected compiler, to `work/ident.txt` (harness-side; `om/units.sh --check` in omega-mv refuses a stale unit). Generator input. An OM-2 unit's frame is the v1 frame followed by the line `omega-unit U C\n` (U a C identifier, new in the set; C 64 lowercase hex digits); a missing or malformed line is refused. Layouts are read from `layout NAME SIZE` lines (SIZE 1..4096, at most 32). Two `note` forms are read by the bridge (and are comments to the compiler): `note bridge c-type L CNAME` names layout L's C struct type, `note bridge c-define NAME DIGITS` adds a `#define` to the API header; any other `note bridge` line is refused. API header (`omega_api.h`, output word `api`, installed only when the set has an OM-2 unit). It includes `omega_native.h` and gives each layout as `typedef struct { ... } CNAME;` with every field at its declared offset (explicit `uint8_t ombr_padN[...]` padding; a field without COUNT is a scalar, with a COUNT an array, even COUNT 1 (erratum E5); a big-endian or misaligned field is bytes), checked by `sizeof` and `offsetof` static assertions that `tools/native` compiles; and each export as `static inline` C function named exactly as the export, with C types (`const T *, size_t` for an unsized view, `CNAME *` for a layout, `T [N]` for out), calling `omega2_NAME` and calling `abort()` on a nonzero status. This is how the C names of a consumer API (for example `sha256_init`) come from the bridge rather than from handwritten C. Out-of-line API (output words `apih` and `apic`, installed as `omega_api_decl.h` and `omega_api_defs.c` beside `omega_api.h`), for a consumer that must not reference the C library from the objects that use the API (a freestanding object: an inline wrapper puts an `abort` reference into every object that includes `omega_api.h`). `omega_api_decl.h` holds the same layouts, defines and static assertions and only the prototypes of the same C functions (external linkage, no `stdlib.h`); an object including it references only the API functions it calls. `omega_api_defs.c` includes it and `stdlib.h` and holds their definitions, each calling `omega2_NAME` and `abort()` on a nonzero status, exactly as the inline ones; it is compiled into the consumer's hosted binding (for the SHA cutover, the generated `src/omega_om_units.c`). `tools/native` compiles the header alone and the definitions against it (`-Wmissing-prototypes -Werror`). `omega_api.h` is unchanged, byte for byte. Use one form or the other in a program, not both: each defines the functions under the same names. Freestanding API (output word `fapic`, installed as `omega_api_defs.c` by `--freestanding` only, in place of the `apic` output). It is the same definitions except that a nonzero status executes `__builtin_trap()` instead of calling `abort()`, so the object imports no C library function and can be linked into a freestanding binding. The prototypes stay those of output `apih`. Unsupported (caller precondition, not detected), as the contract states: that the memory exists for `len` elements, is writable for edit, or stays alive during the call; forged lengths and read-only memory passed as edit. Function-mode stack exhaustion faults as in v1. Loops in the seeded compiler run at most 1,000,000 passes (trap 4 beyond); a unit over a longer view must loop in parts (`part`). Host words (`tools/native --host`; omega-mv#1008/#1040 and the stacked context-format compiler at omega-mv `a0d12c250` (includes #1047; `fn hostval` in `seed/omc/omc.om`). The context compiler sha256 is `6d1b1cf5a44803389a831b67f750ea4cd1c9f53edfde9d6d9241d7352887f1f8`. It admits the nine file/identity words `fclose fopen fstat stat getuid geteuid getgid getegid lstat`, the clocks` monons sleepns realns`, and the device words` devctl mapnew mapdrop mapread mapwrite devcall uvmctl mapaddr mapget mapset maphold mapbind`. Other host words stay refused in function mode. OM-1 units get none. The bridge admits such a unit only when the caller asks: without `--host`, a unit whose source names any of the host words (outside a note line) is refused with status110 and nothing is installed; with `--host`, these words are admitted in an OM-2 unit and every other host word, or any host word in an OM-1 unit, is still refused. `src/native.om` judges the source itself (`fn hscan`): words are split at blanks, tabs, CR, LF and parentheses as the compiler splits them, and a line whose first word is exactly `note` is skipped, so a note may name a host word. The scan is conservative: a host word inside a text literal also counts. The identity of a unit that uses any admitted host word gains ` host=w1,w2,...` (in compiler keyword-table order, only those used), in the embedded string and in `work/ident.txt`, which then comes from the generator (output word `ident`) for every OM-2 unit; a unit without host words gets the same bytes with and without `--host` when using the same compiler. `--host` supports AArch64 Linux and x86-64 Linux, but `--freestanding` is refused (110) before OUTDIR. The words run on the calling thread with its credentials and file descriptors; a descriptor a unit opens is the process's descriptor until the unit closes it, and a trap between `fopen` and `fclose` leaks it (write units so nothing between them can trap). Out buffers still live on the Omega stack until the copy after status 0: a unit that returns a secret leaves a copy there until the thread's next call overwrites it. Generate one native library per architecture from all device-word units in one invocation; multiple `.om` inputs are supported: ``` tools/native --host OUT UNIT1.om UNIT2.om UNIT3.om ``` The inputs share one runtime, default mapping context and context-management API. A caller can select the same explicit context for exports from different units. Input basenames and exported function names must be unique across the library; exports are not namespaced by unit. Do not independently generate device libraries and combine their duplicate context/runtime definitions. The `ctxnew.om`, `ctxput.om`, `ctxget.om` fixture allocates in one unit, writes in another, then reads and drops in the third, through both default and explicit contexts. It also refuses foreign handles, busy destruction and generation without `--host`. No generator change was needed for multi-input support. Mapping-using libraries provide entry31 as a context-table header followed by owned slots; see Explicit mapping contexts below for the draft C API, capacity, generation partition and exact layout. Ordinary exports use a128-slot default context; each generated `omega2_ctx_EXPORT` selects an explicit context. The per-thread reentry check precedes that context's mutex. Pure/nonmapping libraries acquire no context lock. All three wrapper templates zero-initialize their seven span slots; this intentionally changes generated C text, not Omega code bytes or the public ABI. Dispatch tables remain read-only. `mapset` performs one aligned4- or8-byte store bracketed by `DSB SY` on AArch64 or `MFENCE` on x86-64; `mapget` similarly brackets one aligned load. `cpufence` orders payload writes before a doorbell. Fixed replacement is restricted to an entire owned PROT_NONE reservation; failed bind retires its token after successful cleanup. Failed cleanup quarantines it as described below. No arbitrary syscall, executable mapping or GPU qualification is admitted. Traps do not implicitly release mappings. This strict AArch64 context profile additionally admits exactly these aien-gpu ABI1 `devctl` requests: INFO `0x80704110`/112 bytes, MEM_ALLOC `0xc0304121`/48, MEM_FREE `0xc0184122`/24, CHAN_CREATE `0xc0484123`/72, and CHAN_DESTROY `0xc0184124`/24. The whole request (including type, direction and encoded size) is allowlisted. The compiler's `seed/host/MAPPING.md` and `aien-ioctl-matrix.json` record the UAPI pin and Wolfram recomputation. No BOOT, ARENA_READ or RM_INIT request is added. Exact writable counts are required; short and long counts trap3 without changing a result output. Device identity, ABI/state and payload validation stay with the caller/driver. This is a trust-surface draft: Drake must approve the contract before merge. It does not authorize opening a device or establish driver/GPU behavior. CPU-only qualification: `python3 tests/native/v2/dev/run.py [OUTDIR]`, also called by the v2 suite, compares FIONREAD on a pipe and three ioctl paths on `/dev/null` against libc; maps a memfd and publishes payload plus doorbell to a C consumer thread; checks stale handles, all 128 slots plus exhaustion, and clocks bracketed by libc `clock_gettime`. It checks no-`--host` refusal for each of the15 new words, rejects incompatible compiler metadata and reserved context-export names, exercises explicit capacity4098, owned fixed bind, retirement, cross-context ownership and concurrent contexts, and checks both dispatch tables are read-only. Four C-runtime mutants and six compiler-lowering mutants must fail these same callers. A forced-cleanup-failure control proves quarantine refuses bind/read/write, destroy returns36 until a successful drop, and destroy then succeeds. The two quarantine mutants remove the reservation mark or the read-access guards. Compiler-mutant framing uses the original fingerprint deliberately only inside this negative oracle; production generation hashes the actual compiler. This is host evidence only; chip and NVIDIA driver behavior are NOT_RUN. The runner needs the compiler source beside the selected fixpoint binary (or `OMEGA_NATIVE_OMC2_SOURCE` explicitly) and first confirms that source rebuilds the exact selected compiler fingerprint. The additional `aien.c` caller compares all five requests against libc on fd-1 and checks short/long counts using an oversized backing view, so generic view bounds cannot conceal a missing exact-length guard. Its guard-removal mutant must fail specifically at the short-count assertion (exit42), not merely exit nonzero. Native AArch64 requires EBADF. The explicit test-only QEMU10 profile requires ENOTTY: that emulator rejects untranslated requests before fd checks. The x86 conductor traces exactly two ioctl traversals per request (C and Omega); short/long counts must trap before ioctl. This is EMULATED compiler admission and length-guard evidence, never native-kernel, driver or hardware admission. CPU-only single-edit qualification is `python3 tests/native/v2/test_single_edit.py [OUTDIR]`. It compiles and runs the fixed-size OM1 counterpart, dynamic OM2, mapping-default and explicit-context wrappers with `-O2 -Wall -Wextra -Werror`, without warning suppression. Exact initialized-declaration counts are respectively1,1,4,4. Reverting only the pure-OM2 declaration must reproduce GCC13.3's `sp[1].lo` `maybe-uninitialized` diagnostic (exit1); unrelated failures do not kill this mutant. The two mapping exports produce both default and explicit-context wrappers, hence four declarations per mapping fixture. Historical generated-output comparisons admit only the exact old `ombr_span sp[7];` paired with `ombr_span sp[7] = {{0}};` at the corresponding position. Every other byte is compared unchanged. The expected replacement counts are1 per successful OM1 fixture,9 in the current combined OM1 set (counted independently from the selected input fixtures), and14 in the original v2 runner's fixed OM2 set (madd, vec, lay, one, hoist). Missing, stray, differently spelled or differently sized initializers fail; an unrelated one-byte change in the same wrapper also fails. The x86 conductor reuses that exact comparator only for successful historical AArch64 C output. Its per-OM2-fixture count comes independently from explicit input exports (or the single implicit last export); OM1 counts1. It additionally asserts combined input counts9 and13: its unchanged combined OM2 set is madd, vec, lay and one; hoist remains an individual parity fixture. The original v2 runner's14 count is unchanged. Return codes, stderr, all other output formats and every other C byte remain strict, and the same five refusal controls run inside that gate. This is gate maintenance requiring Drake's review before merge. The pinned compiler's pre-existing hoist failure remains exactly `NATIVE-V2 FAIL 1`. #### Hosted x86-64 device words (draft) `tools/native --host --target x86linux` selects the hosted context compiler in `OMEGA_NATIVE_X86_OMC` (not `OMEGA_NATIVE_OMC2`). This is a separate fingerprint from the pure x86 compiler above. The generator enforces the hosted fingerprint for every mapping unit, so raw128/AArch64/unknown compiler metadata cannot be silently combined with this runtime. `native-gen OUTPUT x86host` grants the same source subset as `host` while selecting SysV entry veneers and runtime assembly. The runtime table's entry31 is `[r14+248]`, pointing at the same header and slots as AArch64. The context API, capacities, generations, locking and read-only dispatch publication are architecture-independent. Its x86 hosted compiler fingerprint is `c5ac9979232afd0d750e1d5088af69692032997136f761e585a25aa9a1cfc87e`, from omega-mv `c6c30fe3`, a new seeded superset of #1047's exact ABI1 allowlist and #1046's hosted-x86 lowerers. The frozen #1046/#68 pair is not modified. AArch64 now pins `6d1b1cf5...`; pure x86 remains on `be8c5130...`. The draft compiler and bridge contracts require Drake's approval before merge. The words lower through the existing x86 compiler's program-mode emitters: Words Linux x86-64 operation `devctl`, `devcall`, `uvmctl` `ioctl`, syscall16, same checked payload rules `mapnew`, `maphold`, `mapbind` `mmap`, syscall9, unchanged flags/access/offset rules `mapdrop` `munmap`, syscall11 `mapread`, `mapwrite` Checked byte copies, not ordered MMIO `mapaddr` Checked owned base address `mapget`, `mapset` Exactly one aligned32/64-bit load/store between MFENCE instructions `cpufence`, `cpurelax` MFENCE, PAUSE respectively Ordinary write-back TSO and a compiler barrier do not suffice for a potentially write-combining doorbell mapping. Intel SDM volume2B, order253667-093US, MFENCE, page4-15, says every prior load/store becomes globally visible before any later load/store and explicitly addresses weakly ordered memory types. SFENCE orders stores, not loads. The ABI keeps the stronger MFENCE common path on both sides of ordered reads and writes instead of weakening either operation. Source: Intel SDM volume2B . This is CPU ordering, not a device-completion, cache-coherency or GPU guarantee. Run the shared fake-device fixtures and x86-specific controls with: ``` OMEGA_NATIVE_OMC=/path/to/baseline/omc \ OMEGA_NATIVE_X86_OMC=/path/to/hosted-x86/omc \ OMEGA_NATIVE_X86_SOURCE=/path/to/hosted-x86/seed/omc/omc.om \ QEMU_X86_64=/path/to/qemu-10.0.14/build/qemu-x86_64 \ X86_CC=x86_64-linux-gnu-gcc \ bwrap --dev-bind / / --dev /dev --proc /proc -- \ taskset -c 10-14 nice -n 10 \ python3 tests/native/x86/device.py build/native-x86-device ``` The conductor reuses `tests/native/v2/dev/{hdev.om,dcall.c,context.c,context-ro.c}` unchanged, adds the explicit QEMU10 oracle for the five exact ABI1 requests, and generates one library from ctxnew, ctxput and ctxget with one shared context API. It runs pipe/ioctl C differentials, a memfd producer/consumer, default128 and explicit4098 mapping exhaustion, stale/foreign handles, owned fixed binding, clocks and read-only dispatch controls under QEMU. Its12 mutants cover the wrong ioctl syscall, missing MFENCE instruction structure, invalid runtime entry31, context generation/capacity/destruction, read-only publication, fixed-map ownership, failed-bind retirement, forced cleanup failure with read-guard and late-quarantine mutants, and an exact-length guard removed (attributed short-count assertion exit42). QEMU cannot qualify WC timing: the fence mutant is caught by an instruction oracle, not a claim that an emulator exhibited hardware reordering. No NVIDIA device is opened. Physical x86 and GPU qualification remain NOT_RUN. The preexisting pure x86 suite retains its original compiler fingerprint and continues to run separately with `sh tests/native/x86/run.sh`. #### Function-table export design (PROPOSED, not implemented) A foreign runtime that needs a C function table with more than four C arguments should keep its exact public C signature in a generated adapter. The adapter packs the arguments into a named OM-2 `layout` (fixed widths and explicit padding), passes one layout view plus any checked view/out ranges to an exported Omega function, and converts its status and result according to that public API. This does not extend the six machine-argument slots or place a foreign callback pointer inside Omega code. The table contains the typed adapter addresses, never raw embedded Omega entry addresses. The next slice must define the table schema/version, refuse duplicate emitted names and unsupported callback signatures, emit C declarations and definitions from the same schema, and compare a greater-than-four-argument call through the table against direct C. Negative controls must include a mismatched table version, incorrect layout size and an unsupported signature. Until that slice is implemented, no C function-table export is claimed by this bridge. ### AArch64 qualification (`OMEGA_NATIVE_OMC= OMEGA_NATIVE_OMC2= sh tests/native/v2/run.sh [measure]`) Current invocation (all callers require their toolchains on `PATH`): ``` OMEGA_NATIVE_OMC=/path/to/pinned-generator-omc \ OMEGA_NATIVE_OMC2=/path/to/omega-hoist/seed/out/omc \ OMEGA_NATIVE_HOST_OMC2=/path/to/omega-host/seed/out/omc \ OMEGA_NATIVE_DEVICE_OMC2=/path/to/context-compiler/seed/out/omc \ OMEGA_NATIVE_OMC2_SOURCE=/path/to/context-compiler/seed/omc/omc.om \ sh tests/native/v2/run.sh # optional argument: measure ``` `OMEGA_NATIVE_OMC` retains the `734f0a39...` pin above. The runner checks all three OM-2 digests before building or replacing its output directory: Role omega-mv source Required `seed/out/omc` sha256 ABI and loop hoisting (`OMEGA_NATIVE_OMC2`) `hoist/865-main` @ `7286d61d23c2b92ef6606c6b66072335e6a09813`, retained by `bridge74-hoist-omc-7286d61d` (#865 port onto main `9920aab1`) `078200466af2dc0452da7793b186d91bc9539f0cf5fafa15bcdb2a48e3bedef7` Function-mode host subset (`OMEGA_NATIVE_HOST_OMC2`) `feat/om2-fn-host-words` @ `2992a68b7a3bc1fa8b322924c3b3e786bebc9ee4`, retained by `bridge74-host-omc-2992a68b` (#1008; feature introduced by `dbc72448`) `c000ec029fb85847084a82e345cb7b384cc678a735ed37e9fcbc0f557534b911` Device and single-edit phases (`OMEGA_NATIVE_DEVICE_OMC2`) `a0d12c250` (includes #1047); source supplied with `OMEGA_NATIVE_OMC2_SOURCE` for mutant rebuilding `6d1b1cf5a44803389a831b67f750ea4cd1c9f53edfde9d6d9241d7352887f1f8` Rebuild each compiler from its own checkout, on AArch64 Linux. The script grows seed0, hex1, asm2, and om4, then requires om4-built, self-built, and second-self-built compilers to match: ``` git -C /path/to/omega-mv worktree add --detach /path/to/omega-hoist 7286d61d23c2b92ef6606c6b66072335e6a09813 git -C /path/to/omega-mv worktree add --detach /path/to/omega-host 2992a68b7a3bc1fa8b322924c3b3e786bebc9ee4 (cd /path/to/omega-hoist && bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 sh seed/omega-from-seed.sh) (cd /path/to/omega-host && bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 sh seed/omega-from-seed.sh) sha256sum /path/to/omega-hoist/seed/out/omc /path/to/omega-host/seed/out/omc ``` Run qualification itself under the same `bwrap` wrapper on the shared Spark. The hoist compiler refuses the host fixtures with compiler error 9; #1008's compiler accepts them but does not hoist loop constants. A single one of these binaries cannot qualify the whole current suite. Section 11 uses the host compiler for actual host units and scanner fixtures, checking its own compiler identity. Its host-free `--host` parity control still uses the hoist compiler on both sides, so all nine files must remain byte-identical. No hoist, refusal, identity, caller, or mutant expectation is relaxed. See `evidence/native-v2-compiler-profile/` for the full PASS and pin-refusal controls. The single-edit and device phases explicitly select the context compiler; they do not inherit the ABI/hoist compiler. Its source must rebuild the exact selected fingerprint. The older PASS at bridge `2954d46` with compiler `13ce76c2...`, and the original freestanding PASS with `2c824805...`, exercised older runners, not this feature set. The hoist gate entered bridge main at `7ffd79d` (#24); section 11 entered at `d112461` (#54), after the audit. The runner itself is unchanged between main `3d01b49` and typed-views heads `758d74aa` / `79e8c36`; neither #71 nor #73 introduced these compiler-feature mismatches. The apparent hscan-off failure with `13ce76c2...` was secondary: error 9 prevented `paren.in` from being framed, so the mutant invocation exited 2 instead of reaching the scanner. The correct pair exercises and catches that mutant. Historical S4 qualification was recorded with omega-mv `om2/compiler-s4` @ `f6a6492fd` (draft PR #764, ledger L834), sha256 `499236398aabc652e2dae27fe4bdc4c5db3d3726314356e0dbef23e3345803ec`, which compiles the three OM-2 test units `tests/native/v2/{vec,lay,one}.om`; that digest is the `omc=` of their identities. Its code follows the convention above with no departure found: the entry table (vec: six `b` words), the slots and element counts, the out pointers, and the traps the callers expect (the `part` checks in the contract's order, element bounds, trap 9 after an out write). Before S4 existed the bridge was developed against hand-written OM-1 stand-ins of these units (commit `1392549`); they are removed. The later historical `hoist` receipt used omega-mv `perf/omc-loop-checks` @ `c4953df7b` (draft PR #865), sha256 `13ce76c274d6bdce50613a242faa7cb07aadf65441ceecddf2d06bcfa4e48b69`, which keeps at most seven constants (x20..x26). Its decoded `hoist` code writes x20..x26 and d13, d14 and s15; that of `0d006207` (no hoisting) writes none of x20..x26, and the hoist check fails with it. The newer `25e264c6` perf-branch compiler (`c4380d3c...`) also hoists but still refuses function-mode host words. The run checks: v1 byte identity (above); every identity string against `sha256sum` (oracle); the embedded code against the compiler's bytes; the exact exported symbol set (15 `omega2_` symbols, 12 exports and 3 identities, and `omega_madd`; no private helper, no v1 name for a v2 unit); no caller declaring an Omega function by hand; the C caller (64 checks) normally and with BTI enforced; the C++, Python, Rust (2021 and 2024), Zig and Go callers (16 to 18 checks each); the link-time refusal in all six languages (v1 bindings of an OM-1 unit named `bsum` against the library: `undefined reference to omega_bsum`, Python` undefined symbol: omega_bsum`); the stale identity (a header from` vec.om` with one note byte changed is detected; its Python binding refuses to import; the matching header passes); 15 generator refusals of OM-2 input with a control; three negative controls (the wrap check, the edit-overlap rule and the out copy each removed from a copy of the generator must make the C caller fail, on the checks named); `hoist`'s decoded destinations (x20..x26 and some of d8..d15 written) and no unit's code naming x19 or x29; and the trampoline called directly (`tests/native/v2/tramp.c`, which includes the generated C, so no C wrapper can keep a register for it) with a hand-assembled unit that writes x20..x29 and d8..d15, on a return and on a trap, plus ten mutants, each removing one restore from `ombr_leave` (x19/x20, x21/x22, x23/x24, x25/x26, x27/x28, the four d pairs, x29) in a copy of the generator, every one of which must make it fail. For the out-of-line API the run also checks: every existing output (`c h python rust zig go api`) byte-identical to `3bb8b8a`'s generator on the v2 set; `tests/native/v2/fsuse.c`, built with `-ffreestanding -fno-builtin` from `omega_api_decl.h`, has exactly the undefined symbols `absorb bsum digest swap8`(no`abort`), while` omega_api_defs.o`holds the`abort` reference; the same object from the inline `omega_api.h` references `abort` (control); linked with `omega_api_defs.o` and the library it computes the right values, and a trapping call aborts (SIGABRT). Two generator mutants are caught: the prototype-only branch disabled (definitions in `omega_api_decl.h`: the freestanding build fails on the undeclared `abort`), and the inline branch disabled (`omega_api.h` loses `static inline`: caught by the byte-identity check). Host words (section11): without `--host`, `tests/native/v2/host/hfile.om` (all nine words) is refused and nothing is installed; `--host --freestanding` is refused for either target before OUTDIR; with `--host` its identity names the nine words, and a C caller (`hcall.c`) and a Rust caller (`hcall.rs`) check its results against libc and `std`: the uid/gid sum, a 5-byte read, `-ENOENT` for a missing path, `-ELOOP` for a symlink (`fopen` with `O_NOFOLLOW`), `st_size`. The v2 set built with `--host` is byte-identical in all nine outputs. The generator, fed directly: `geteuid` after `(`, a tab and before a CR is refused without host and named with it; host words in note lines (also indented, tab-separated) pass without host; `(note geteuid` is not a note; `unlink` (outside the nine) and `geteuid` in an OM-1 unit are refused even with host; `getuidx` is not a host word; the freestanding outputs `freest` and `fapic` refuse `host` (exit 110) on a unit they accept without it. Mutant: the scan removed from `fn unit` lets the parenthesised `geteuid` through without host (caught). The zig and go callers need their toolchains on PATH (zig 0.13.0, go 1.27.3 were used); without them the run reports NOT_RUN and exits 1. The C caller covers: values; empty views (NULL, misaligned); NULL with len 1; misalignment by 1, 2 and 4 for 4- and 8-byte elements and an edit; `len*size` overflow (2^62 x 4, 2^61 x 8, 2^64-1); address wrap at 2^64-16 (end 2^64 refused, end 2^64-8 accepted); a 2^32+5-element length accepted and passed whole (PROT_NONE mapping, no element read); the #748 golden at the boundary (len 2^64-1, o 2^64-2, k 4: 32) and inside the code (len 16, o 2^64-2, k 4: trap 3, the wrapped `o + k` never used), every (o, k) in 0..18 over 16 bytes; splits at every point of 64 bytes; 16 MiB of bytes and 64 MiB of words against a C reference; edit == view, overlap by one element, adjacent ranges, empty ranges, the result inside an edit or a view; the layout through `omega_api.h`; out overlapping a view (in-place reverse) and its own layout view; two outs adjacent, overlapping by one byte and at one address; out untouched after a trap; NULL and misaligned out; 2000 interleaved rounds across the three separately compiled OM-2 units and the OM-1 `madd` in one binary (module boundary); reentry from a signal handler (33); two threads with their own stacks and out buffers. Caller cost (HOST, `run.sh measure`, GB10 host CPU under load average 7-11 from other work, lowest of 7 runs, ns per call, two runs, S4 code): call ns refused (argument checks only, no entry) 2.6-3.1 one view, code returns its len (checks, entry, register saves, stack switch) 8.0-8.2 empty view to `bsum` (its chunk loop runs once and calls `psum`) 9.8 ABI v1, three scalars (baseline) 5.2-6.1 a plain noinline C call (scale) 1.4 one view and an 8-byte out (zero, run, memmove) 14.3-15.0 16-byte view sum (scalar C loop 4.9) 15.0-15.5 4 KiB view sum: 0.346 ns/B (C 0.258) 1418 16 MiB view sum: 0.379-0.384 ns/B (C 0.291-0.295) 6.4 ms a thread's first call (maps its 8 MiB stack and 8 MiB guard), then the second 11.5-12.4 us, 64 The fixed v2 overhead over a plain C call is about 6.6 ns (checks about 1.5, entry and stack switch about 5), about 2 ns over v1 for one view; an out costs its zeroing and copy. Memory: 16 MiB of NORESERVE address space per calling thread; the RSS did not change at KiB resolution over a new thread's first two calls. Not run: status 34 and 35 (as v1). ### Explicit mapping contexts (contract draft; Drake approval required before merge) This stacked extension changes the function-mode entry-31 format. It must not be mixed with the raw 128-slot format from omega-mv#1040 / omega-bridge#66. Mapping units require the exact context-format compiler fingerprint recorded by the generator; pure/nonmapping compiler admission remains unchanged. Program-mode `MAPPING.md` keeps its raw128 slots, eight slot bits and existing semantics. The C compatibility API is: ``` typedef struct omega_native_context omega_native_context; uint32_t omega_native_context_create(uint64_t capacity, omega_native_context **out); uint32_t omega_native_context_destroy(omega_native_context *context); /* Every OM-2 export in a mapping-using library also has: */ uint32_t omega2_ctx_EXPORT(omega_native_context *context, uint64_t *result, /* unchanged export arguments */ ...); ``` Existing `omega2_EXPORT` calls use a default128-slot context. Explicit contexts admit capacity1..4098. A C NVRM context needs4096 live allocation mappings plus one usermode mapping and one transient slot. GPU channel VA bookkeeping is not a CPU mmap reservation. Context selection is explicit, never a TLS selector, and does not consume any of the six private Omega argument words. Mapping-using libraries reserve the `ctx_` export prefix for these generated wrappers and refuse an Omega export that would collide. Context pointers and handles belong to the generated library that created them, not another shared object with its own runtime. Only the C binding exposes the explicit-context API; the other bindings retain their default-context exports. Entry31 points at four u64 header words: capacity, generation base, generation limit, zero-reserved; then capacity slots of four u64 words: address, byte length, generation, access. A slot is live iff address is nonzero. Handle low13 bits are slot+1. Upper50 bits are a nonwrapping generation:24 context-ID bits followed by26 per-slot bits. Default context ID is1; IDs2..`16777215` are issued once per generated library and never reused, including failed creations. Each slot starts at `contextID<<26`; successful allocation increments it, and an exhausted slot is never reused. Thus a handle from another context cannot alias a local slot. WolframLanguageEvaluator: `{4096+1+1,2^13,2^26,2^24-1,2*2^26-1,2^50-1,32+4098*32,32+128*32}` -> `{4098,8192,67108864,16777215,134217727,1125899906842623,131168,4128}`. The last two values are table byte sizes, including the32-byte header. `maphold(address,length)` uses PROT_NONE / MAP_FIXED_NOREPLACE and returns only an exact reservation at the requested address. `mapbind(handle,fd,offset,access)` may replace only the entire live PROT_NONE reservation owned by that context; access is literal1 or3. It accepts no arbitrary target address. A successful bind changes that same slot to a shared mapping. A failed bind marks the slot QUARANTINED (access4), then attempts to unmap the whole former reservation. Successful cleanup retires the token and returns the original negative Linux errno with bridge status0. Cleanup failure traps3 and preserves the droppable owner; the wrapper does not write its result. The caller must retain that owner on nonzero bridge status and retry `mapdrop`. Quarantined tokens refuse bind, read and write, but permit `mapaddr` and `mapdrop`. Destroy returns36 while any live or quarantined slot remains and succeeds after all drops complete. Linux may leave a gap after failed MAP_FIXED: **reservation preservation is not promised**. Reusing a retired token, binding an ordinary mapping, and using a cross-context handle trap3 before replacement. External munmap/mremap/MAP_FIXED over an owned range is outside this ownership contract. One mutex per context serializes bridge calls, with the per-thread/per-library reentry guard checked before locking. The caller additionally serializes each multi-call allocation/bind/cleanup transaction in its NVRM context. Different contexts may run concurrently. Locks cover normal/trap exits and out copies. The dispatch table is initialized in private memory and protected read-only before publication; entry31 alone differs between contexts. The caller must join/drain all context users and waiters before destruction. Destruction refuses any live mapping/reservation with status36 (`OMEGA_CONTEXT_BUSY`), performs no implicit unmap, and never destroys the default context. Null/invalid capacities return32; recursive calls return33; runtime allocation/lock failures return34. A destroyed pointer is invalid. As with the existing runtime, async cancellation/siglongjmp across a bridged call are unsupported. Pure/nonmapping libraries have no context overhead. ## Hosted seeded-C runtime-extent views (explicit profile) This is a converter ABI, not native ABI v2. It is selected with `tools/bridge-seeded --runtime-views c unit.om` or `tools/bridge-seeded --runtime-views h unit.om`. The unchanged `e5b32567` source snapshot validator is required. Default `bridge-seeded` views still require the exact declared count; `--float-next` is not combined with this profile. Omega declaration Public C arguments Live extent `a view uchar CAP` `const void *a, uint64_t a_n` bytes, `0 <= a_n <= CAP` `a view ushort CAP` `const void *a, uint64_t a_n` 16-bit halfwords, bounded by CAP `a view uint CAP` `const void *a, uint64_t a_n` 32-bit words, bounded by CAP `a view ulong CAP` `const void *a, uint64_t a_n` 64-bit words, bounded by CAP `a view f32 CAP` `const void *a, uint64_t a_n` raw IEEE binary32 elements, bounded by CAP `a edit T CAP` `void *a, uint64_t a_n` same count/width policy, writable OM2 `a view T *` / `a edit T *` same pointer/count pair unsized; byte/address envelope only integer scalar/result `uint64_t value` / `uint64_t *result` unchanged canonical bits f32 scalar/result `float value` / `float *result` unchanged For example, numeric bounded input: ``` fn copy a view uint 256 b edit uint 256 i ulong to ulong put b i get a i ret len b end ``` For counts above the fixed-declaration ceiling, use the pinned seed's existing unsized declaration syntax: ``` om2 fn copy a view uint * b edit uint * i ulong to ulong put b i get a i ret len b end ``` Both export the same ABI shape (the generated header uses numbered arguments): ``` uint32_t omega_copy(uint64_t *result, const void *a, uint64_t a_n, void *b, uint64_t b_n, uint64_t i); ``` The result pointer is first; other arguments retain source order. Generated source/header explicitly identify the runtime profile. The original source records numeric capacities versus `*`; consumers must pin both source and converter. A fixed, bounded-runtime and unsized-runtime C declaration alone cannot distinguish their policies. `len` returns the live element count; every access uses that count, including literal indices of unsized views and counts forwarded through helper calls. Passing any same-element array to an unsized helper is supported; a fixed helper still requires the declared fixed shape. Runtime-profile numeric declarations remain source-level capacities, not resized Omega local arrays. Nonempty arguments must be nonnull and naturally aligned. Element-count times element-width and pointer plus byte-length must not overflow. Empty arguments may be NULL or misaligned and contribute no range. Range checks use actual counts, not capacities: adjacent disjoint buffers and readonly/readonly aliases are allowed; any overlap involving a writable view is refused. All views, including readonly ones, must be disjoint from nonempty result storage. Result-pointer checks are unchanged, even when all view counts are zero. Invalid admission returns 32, access outside the live count returns trap 3, reentry returns 33, and success returns 0. Only success writes the result; earlier view writes remain visible after a trap. Six source parameters are available. Numeric views take one native seed slot each, so five numeric views can generate ten C pointer/count arguments. Unsized views take two native slots each, with six slots total; the original seed rejects larger signatures. Only the bare `om2` header and unsized views are added, not arbitrary OM2 layouts/contracts/exports/part syntax. Other converter limits and iteration guards are unchanged. Dimension products and strides remain the caller/unit's responsibility: checked view admission does not validate a wrapping dimension formula. Use `-ffp-contract=off` for sequential floating arithmetic. A borrowed NUL-terminated path can use the pointer plus its readable maximum extent, scanning only within that extent: ``` om2 fn pathlen a view uchar * to ulong for i ulong len a if eq get a i 0 ret i end end ret len a end ``` The C entry is `uint32_t omega_pathlen(uint64_t *result, const void *a, uint64_t a_n)`. A result smaller than` a_n` locates the first NUL; result equal to `a_n` means no NUL inside the bound (including empty input). The caller must supply a genuinely readable extent: the adapter checks arithmetic and aliasing, not virtual-memory mapping permissions. `bridge-seeded` keeps its hosted checked runtime. `tools/bridge-freest c|h SOURCE.om` now additionally supports these borrowed-view signatures with the same checked ABI and refusal codes, using stack-local explicit status/depth propagation instead of TLS/setjmp/longjmp. Its generated object has an empty allowed undefined-symbol set: no libc/POSIX, TLS, int128, abort or printf imports. Units without `om2` retain exact declared counts, matching the default hosted checked profile; the seed-validated `om2` header selects numeric capacities and unsized runtime views, matching hosted `--runtime-views`. No invocation flag is required. Both preserve bounds and alias semantics, partial writes before a refusal and result storage only on success; argument refusal 32 changes neither result nor buffers. This does not extend `tools/native --freestanding` or change the hosted profile. A view-taking unit with an unsupported capability refuses without output and never retries the legacy scalar profile. See CAPABILITIES.md for the exact subset and `tests/freest_views.py` for differential/import/mutation acceptance. The acceptance suite compares this scan to `memchr` on host and x86, including NULL/zero and a terminator immediately outside the bound. `tests/seeded_runtime_views.py` is the host/reference, emulated x86 and mutation acceptance path. No GPU or hardware qualification is claimed.