interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / docs / NATIVE-X86-PHYSICAL.md

194 lines · 9843 bytes Raw Blame History Source

Native x86-64 execution: runbook and receipt format

Every x86 receipt so far (evidence/native-x86-be8c5130.json, evidence/native-x86-pr44-merge/receipt.json) is EMULATED_PASS: the callers ran under qemu-x86_64 on an AArch64 host and native_x86 is NOT_RUN. This page says how to run the same suite with the callers executing on an x86-64 CPU, and how to record the result.

What the mode does

OMEGA_NATIVE_X86_EXEC=native makes tests/native/x86/suite.py execute every target executable (the six callers, the saved-register and status oracles, the TLS and out-of-line API checks) directly instead of as qemu-x86_64 -L SYSROOT [-E LD_LIBRARY_PATH=…] exe. OMEGA_NATIVE_X86_LIBPATH, when set, becomes the executable's LD_LIBRARY_PATH. Nothing else changes: the same compilers, pins, sources, oracles and checks run, and AArch64 byte parity against f637021 is still required.

The default (qemu, or the variable unset) keeps the emulated run and its output unchanged. Any other value fails preflight before a caller is built.

In native mode preflight:

Check names and the aggregate line say NATIVE instead of EMULATED. A successful run ends with

NATIVE-X86 NATIVE PASS (six languages built and run on the host x86-64 CPU; virtualization=<v>)

The suite never prints PHYSICAL. A cloud VM or a container on a hypervisor is a native run on a virtual CPU, not a physical qualification; the receipt rule below decides the label.

Host prerequisites

An x86-64 Linux host with:

NeedUbuntu 24.04 exampleChecked by
C/C++ for x86-64gcc g++ binutils (x86_64-linux-gnu-gcc, -g++, -nm, -objdump are the host tools)suite CC, CXX, NM, OBJDUMP
Rust with the x86-64 stdrustc (rustup stable is fine)suite RUSTC
Zig 0.13https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz, SHA256 d45312e61ebcc48032b77bc4cf7fd6915c11fa16e4aad116b66c9468211230ea (from ziglang.org download/index.json)suite ZIG
Go with cgoany Go release with cgo enabledsuite GO
x86 Python 3the host python3 (OMEGA_NATIVE_X86_PYTHON=$(command -v python3))suite OMEGA_NATIVE_X86_PYTHON
AArch64 binfmtqemu-user-binfmt or qemu-user-staticnative preflight
Full git clone of omega-bridgegit clone, not --depth 1 (the parity check reads f637021)parity checks

Record the version of each tool (gcc --version, rustc --version, zig version, go version, python3 --version, the binfmt interpreter's --version and sha256) in the receipt.

Compilers

Both are pinned by sha256 in tools/native and checked by the suite before use:

Variablesha256Source
OMEGA_NATIVE_OMC (generator)734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61git -C omega-mv show e17039d9ceeb30e0637ef4145e37afc5821c3773:seed/out/omc
OMEGA_NATIVE_X86_OMC (x86 target)be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448agit -C omega-mv show 474197e4fa0207e0e2fb3c0494594a975f5031fa:seed/out/omc
git -C omega-mv show e17039d9ceeb30e0637ef4145e37afc5821c3773:seed/out/omc > omc-gen
git -C omega-mv show 474197e4fa0207e0e2fb3c0494594a975f5031fa:seed/out/omc > omc-x86
chmod +x omc-gen omc-x86
sha256sum omc-gen omc-x86   # must print the two pins above

These are PIN and X86_PIN in tools/native. The separate hosted pin X86_HOST_PIN (c5ac9979…, selected by tools/native --host) is not used by tests/native/x86/run.sh; a physical receipt names X86_PIN.

Commands

From the omega-bridge checkout at the commit under test, with fresh empty output directories:

export OMEGA_NATIVE_OMC=$PWD/../omc-gen OMEGA_NATIVE_X86_OMC=$PWD/../omc-x86
export ZIG=/opt/zig-linux-x86_64-0.13.0/zig GO=$(command -v go)
export OMEGA_NATIVE_X86_PYTHON=$(command -v python3)
export OMEGA_NATIVE_X86_EXEC=native

# 1. The suite.
sh tests/native/x86/run.sh build/x86-native        2>&1 | tee x86-native.log

# 2. Controls: failed Zig/Go builds, missing Zig/Go and an unknown execution
#    mode must all refuse aggregate PASS; then the positive run must print NATIVE.
#    (The known-bad QEMU control is NOT_RUN in native mode.)
python3 tests/native/x86/test_build_failures.py build/x86-native-controls \
                                                   2>&1 | tee x86-native-controls.log

# 3. Wrong-pin control: the generator compiler offered as the x86 compiler.
OMEGA_NATIVE_X86_OMC=$OMEGA_NATIVE_OMC \
  sh tests/native/x86/run.sh build/x86-native-wrongpin 2>&1 | tee x86-native-wrongpin.log

# 4. Mutated-compiler control: tools/native must refuse a changed x86 compiler.
cp "$OMEGA_NATIVE_X86_OMC" omc-x86-mut && printf '\0' >> omc-x86-mut
OMEGA_NATIVE_X86_OMC=$PWD/omc-x86-mut \
  sh tools/native --target x86linux build/x86-native-mut tests/native/x86/follow.om \
                                                   2>&1 | tee x86-native-mut.log

Expected: 1 and 2 exit 0, ending with the NATIVE PASS line and NATIVE-X86 CONTROLS PASS (NATIVE; …); 3 exits 1 with NATIVE-X86 FAIL x86 compiler pin; 4 exits 1 with tools/native reporting an x86 omc sha256 that differs from the pin.

Receipt

Write evidence/native-x86-physical-<first 8 hex of the x86 pin>.json (for the current pin, evidence/native-x86-physical-be8c5130.json). It extends the schema-1 fields of evidence/native-x86-be8c5130.json:

{
  "schema": 1,
  "status": "NATIVE_PASS",
  "label": "PHYSICAL",
  "bridge_commit": "<full sha under test>",
  "x86_omc_sha256": "be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a",
  "baseline_omc_sha256": "734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61",
  "native_x86": "PASS",
  "host": {
    "cpu_model": "<INFO cpu model=>",
    "hypervisor_flag": "no",
    "virtualization": "none",
    "kernel": "<INFO kernel=>",
    "os": "<PRETTY_NAME from /etc/os-release>",
    "binfmt_qemu_aarch64": {"interpreter": "<path>", "version": "<first line>", "sha256": "<sha256>"}
  },
  "toolchains": {"gcc": "", "g++": "", "rustc": "", "zig": "", "go": "", "python": ""},
  "commands": [
    {"command": "OMEGA_NATIVE_X86_EXEC=native sh tests/native/x86/run.sh EMPTY_OUTPUT", "exit": 0, "result": "<N> PASS, 0 FAIL; NATIVE-X86 NATIVE PASS"},
    {"command": "OMEGA_NATIVE_X86_EXEC=native python3 tests/native/x86/test_build_failures.py EMPTY_OUTPUT", "exit": 0, "result": "NATIVE-X86 CONTROLS PASS (NATIVE)"},
    {"command": "OMEGA_NATIVE_X86_EXEC=native OMEGA_NATIVE_X86_OMC=<734f0a39 omc> sh tests/native/x86/run.sh EMPTY_OUTPUT", "exit": 1, "result": "negative control: FAIL x86 compiler pin"},
    {"command": "OMEGA_NATIVE_X86_OMC=<be8c5130 omc with one byte appended> sh tools/native --target x86linux OUTDIR tests/native/x86/follow.om", "exit": 1, "result": "negative control: tools/native refused"}
  ],
  "logs_sha256": {"x86-native.log": "", "x86-native-controls.log": "", "x86-native-wrongpin.log": "", "x86-native-mut.log": ""}
}

Fill each field from the run's own output; copy no value from this template. Commit the four logs next to the receipt in evidence/native-x86-physical-<pin8>/ so logs_sha256 can be rechecked.

Label rule:

A physical receipt qualifies the ABI v2 boundary on that CPU model and kernel only. It says nothing about CPU timing, other microarchitectures, other kernels or other C libraries.

Checking a receipt

omc < tests/native/x86/check_physical_receipt.om > check_physical_receipt
chmod +x check_physical_receipt
./check_physical_receipt evidence/native-x86-physical-<pin8>.json

omc is the seeded compiler (omega-mv e5b32567, sha256 2c824805…); run the checker from the repository root. It reads the receipt, the four logs in evidence/native-x86-physical-<pin8>/ and the pins in tools/native; it runs nothing. It exits 0 with PHYSICAL-RECEIPT ACCEPTED only if the receipt is PHYSICAL/NATIVE_PASS at the current PIN and X86_PIN, records host, binfmt and toolchain versions, lists the four commands with their expected exits and results, the log hashes match, and the suite log itself ends with NATIVE-X86 NATIVE PASS … virtualization=none, shows INFO virtualization=none and INFO cpu hypervisor flag=no, matches the receipt's CPU model and kernel, and never says EMULATED. Any other receipt, including every EMULATED receipt and an EMULATED log relabelled PHYSICAL, exits 1 with PHYSICAL-RECEIPT REJECTED. Acceptance is a consistency check of the receipt, not evidence by itself.