diff --git a/docs/NATIVE-ABI.md b/docs/NATIVE-ABI.md index ca89274..a5508ae 100644 --- a/docs/NATIVE-ABI.md +++ b/docs/NATIVE-ABI.md @@ -68,7 +68,7 @@ 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`, even on an x86 build host. It requires +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 @@ -78,6 +78,16 @@ library search path. `tests/native/x86/prepare.py EMPTY_OUTPUT` extracts a Pytho 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](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: ```sh diff --git a/docs/NATIVE-X86-PHYSICAL.md b/docs/NATIVE-X86-PHYSICAL.md new file mode 100644 index 0000000..974b6a8 --- /dev/null +++ b/docs/NATIVE-X86-PHYSICAL.md @@ -0,0 +1,168 @@ +# 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: + +- fails unless `uname -m` is `x86_64` + (`FAIL native execution host is x86-64 (uname -m aarch64)` on the Spark); +- prints `INFO cpu model=`, `INFO cpu hypervisor flag=yes|no`, `INFO kernel=`, + `INFO virtualization=` (from `systemd-detect-virt`; `unknown` if that is + absent) and, if registered, `INFO binfmt qemu-aarch64 interpreter=`; +- requires both pinned compilers to execute on the host. They are AArch64 + executables (`file` reports `ELF 64-bit LSB executable, ARM aarch64`), so an + x86 host needs binfmt_misc `qemu-aarch64`. QEMU here runs only the compilers. + Their outputs are byte-compared against the AArch64 baseline by the suite's + parity checks, and every target executable still runs on the host CPU. +- does not use or probe `qemu-x86_64`. The QEMU oracle probes run only in + `qemu` mode. + +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=) +``` + +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: + +| Need | Ubuntu 24.04 example | Checked by | +| --- | --- | --- | +| C/C++ for x86-64 | `gcc g++ binutils` (`x86_64-linux-gnu-gcc`, `-g++`, `-nm`, `-objdump` are the host tools) | suite `CC`, `CXX`, `NM`, `OBJDUMP` | +| Rust with the x86-64 std | `rustc` (rustup stable is fine) | suite `RUSTC` | +| Zig 0.13 | , SHA256 `d45312e61ebcc48032b77bc4cf7fd6915c11fa16e4aad116b66c9468211230ea` (from ziglang.org `download/index.json`) | suite `ZIG` | +| Go with cgo | any Go release with cgo enabled | suite `GO` | +| x86 Python 3 | the host `python3` (`OMEGA_NATIVE_X86_PYTHON=$(command -v python3)`) | suite `OMEGA_NATIVE_X86_PYTHON` | +| AArch64 binfmt | `qemu-user-binfmt` or `qemu-user-static` | native preflight | +| Full git clone of omega-bridge | `git 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: + +| Variable | sha256 | Source | +| --- | --- | --- | +| `OMEGA_NATIVE_OMC` (generator) | `734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61` | `git -C omega-mv show e17039d9ceeb30e0637ef4145e37afc5821c3773:seed/out/omc` | +| `OMEGA_NATIVE_X86_OMC` (x86 target) | `be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a` | `git -C omega-mv show 474197e4fa0207e0e2fb3c0494594a975f5031fa:seed/out/omc` | + +```sh +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 +``` + +## Commands + +From the omega-bridge checkout at the commit under test, with fresh empty +output directories: + +```sh +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-.json` (for +the current pin, `evidence/native-x86-physical-be8c5130.json`). It extends the +schema-1 fields of `evidence/native-x86-be8c5130.json`: + +```json +{ + "schema": 1, + "status": "NATIVE_PASS", + "label": "PHYSICAL", + "bridge_commit": "", + "x86_omc_sha256": "be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a", + "baseline_omc_sha256": "734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61", + "native_x86": "PASS", + "host": { + "cpu_model": "", + "hypervisor_flag": "no", + "virtualization": "none", + "kernel": "", + "os": "", + "binfmt_qemu_aarch64": {"interpreter": "", "version": "", "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": " 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= 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-/` so `logs_sha256` can be rechecked. + +Label rule: + +- `PHYSICAL` only when the suite printed `virtualization=none` **and** + `cpu hypervisor flag=no`, and the receipt names the machine. +- Any other virtualization value, or the hypervisor flag set, is `VIRTUAL`. + That run shows native-CPU execution on that virtual CPU; it is not physical + qualification. +- `status` is `NATIVE_PASS` only if all four commands gave their expected exit + and result. Otherwise use `NATIVE_FAIL` and keep the failing logs. + +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. diff --git a/evidence/deepinfer-flops-pairs/.crumb b/evidence/deepinfer-flops-pairs/.crumb index ff94d90..be6be26 100644 --- a/evidence/deepinfer-flops-pairs/.crumb +++ b/evidence/deepinfer-flops-pairs/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-31T00:23:54Z", + "compiled_at": "2026-11-05T12:54:22Z", "compiler": "crumb-compile/1", - "digest": "sha256:579eb72ebd1a11bcd3304f4b4a896f8e52dfa65e8b193feaeaea469d24844050", - "evidence_files": 0, - "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 0, - "generated_at_commit": "1958a1895279c0d4869bab39eaa20f070b174a6c", - "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + "digest": "sha256:7c14a81f63904b84316ff03ec3eb080eb86f108f2d12ae70b01e61880c1edd26", + "evidence_files": 5, + "evidence_root": "sha256:76dbb392840f18d72765d4bf0e79016767aa0bb88a3b12f18f3bea4ba0b9a5d4", + "files": 5, + "generated_at_commit": "79b2cce3663ac4e253e98b80488546a0b9a66017", + "source_tree": "sha256:ebe628b15331fac84e10a93d417983cc9f6cb1686fe139d4e6d76191d5f34a0e" } }, "layer": "evidence", diff --git a/examples/deepinfer/.crumb b/examples/deepinfer/.crumb index be6a45a..968e458 100644 --- a/examples/deepinfer/.crumb +++ b/examples/deepinfer/.crumb @@ -3,21 +3,21 @@ "generated": { "children": [ { - "digest": "0930c059d4792c524ead954ccfa16e3dab282f13db861da3cd00a446883eac4f", - "last_commit": "", + "digest": "ed677261fccddbfb3fc759161f5f9f9bc23d8c0cfab2c305e194ee6cbe23014b", + "last_commit": "7af4d11", "name": "callers", "purpose": "c, c-bti, cpp, python, rust, zig and go callers of flops_pairs.om through the generated bindings" } ], - "children_root": "sha256:55b6c520fea9b88868f31919ffa3761fe965588bf9f0f006a9e52928ab6d2a4a", - "compiled_at": "2026-10-31T00:23:54Z", + "children_root": "sha256:2c6c549fbf59bc4ad8c458033c81e732f03432c4b7369fd8f04a8f76e27bd8ea", + "compiled_at": "2026-11-05T12:54:22Z", "compiler": "crumb-compile/1", - "digest": "sha256:d0a686f1689207de43dda23ac1769a106851e542d55b240b3512ed5b0b8294d3", + "digest": "sha256:02850208ca19d8939d5f648383cd4a33230305b7b0d8524d4618d5ac1bcd2dc5", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 0, - "generated_at_commit": "1958a1895279c0d4869bab39eaa20f070b174a6c", - "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + "files": 16, + "generated_at_commit": "79b2cce3663ac4e253e98b80488546a0b9a66017", + "source_tree": "sha256:24a2c12bdc8f561bbb3d7709d850b46a57115e0979cdb3301843f5135ec5f62f" } }, "layer": "examples", diff --git a/examples/deepinfer/callers/.crumb b/examples/deepinfer/callers/.crumb index 1d6198e..7610d2c 100644 --- a/examples/deepinfer/callers/.crumb +++ b/examples/deepinfer/callers/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-31T00:23:54Z", + "compiled_at": "2026-11-05T12:54:22Z", "compiler": "crumb-compile/1", - "digest": "sha256:0930c059d4792c524ead954ccfa16e3dab282f13db861da3cd00a446883eac4f", + "digest": "sha256:ed677261fccddbfb3fc759161f5f9f9bc23d8c0cfab2c305e194ee6cbe23014b", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 0, - "generated_at_commit": "1958a1895279c0d4869bab39eaa20f070b174a6c", - "source_tree": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + "files": 6, + "generated_at_commit": "79b2cce3663ac4e253e98b80488546a0b9a66017", + "source_tree": "sha256:55958ef9dd75210c4686727b6614cbdacfd84091191d171fd0f24c90148bb71c" } }, "layer": "examples", diff --git a/tests/native/x86/.crumb b/tests/native/x86/.crumb index d4a2b76..5f2e724 100644 --- a/tests/native/x86/.crumb +++ b/tests/native/x86/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-28T23:42:26Z", + "compiled_at": "2026-11-05T12:54:22Z", "compiler": "crumb-compile/1", - "digest": "sha256:04e703f9be6d638494401f7ac438adbe71987ea921b99dd8d1637bae4b25da23", + "digest": "sha256:ff4d64b7c4ac5b68db86b51efaa0ccf31e95ef45da15faafd811805528253da7", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 11, - "generated_at_commit": "29087763accea55666ac7a4c14ecb37cef1c2be8", - "source_tree": "sha256:f4f487543a11eaf2366684257529ae670cfbcef2b49be2187735961ce68c5e2d" + "files": 12, + "generated_at_commit": "79b2cce3663ac4e253e98b80488546a0b9a66017", + "source_tree": "sha256:5dbd3c1f0bd2e52abfad3629f822abffff5e19c1b2ca1fccbaf19889fe947930" } }, "layer": "tests", diff --git a/tests/native/x86/run.sh b/tests/native/x86/run.sh index fbd42e8..bda3be1 100755 --- a/tests/native/x86/run.sh +++ b/tests/native/x86/run.sh @@ -1,6 +1,7 @@ #!/bin/sh -# Cross-build every ABI v2 caller, then execute under qemu-x86_64. -# Native x86 hardware is deliberately NOT_RUN; see suite.py for prerequisites. +# Cross-build every ABI v2 caller, then execute under qemu-x86_64 (default) or, +# with OMEGA_NATIVE_X86_EXEC=native on an x86-64 host, directly on the host CPU. +# See suite.py for prerequisites and docs/NATIVE-X86-PHYSICAL.md for the runbook. set -eu ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../../.." && pwd) exec python3 "$ROOT/tests/native/x86/suite.py" "$@" diff --git a/tests/native/x86/suite.py b/tests/native/x86/suite.py index 4f5211a..ee07426 100755 --- a/tests/native/x86/suite.py +++ b/tests/native/x86/suite.py @@ -11,10 +11,18 @@ The emulator's sha256 and version are recorded, and qemu_probe.c must show that provides the guest services the callers use; otherwise QEMU-ORACLE-UNUSABLE refuses aggregate PASS before any caller runs. No CPU timing or native hardware qualification is inferred from emulation. + +OMEGA_NATIVE_X86_EXEC=native runs every target executable directly on the host CPU +instead of under QEMU. It requires an x86-64 host, does not use or probe QEMU, and +still needs the AArch64 compilers to execute there (binfmt_misc qemu-aarch64). The +CPU model, kernel and virtualization detected are printed; check names and the +aggregate line say NATIVE instead of EMULATED. docs/NATIVE-X86-PHYSICAL.md is the +runbook and receipt format for a physical run. """ import hashlib import os from pathlib import Path +import platform import re import shlex import shutil @@ -51,6 +59,10 @@ class Suite: self.zig = command("ZIG", "zig") self.go = command("GO", "go") self.rust = command("RUSTC", "rustc") + self.mode = os.environ.get("OMEGA_NATIVE_X86_EXEC", "qemu") + self.native = self.mode == "native" + self.how = "NATIVE" if self.native else "EMULATED" + self.virt = "unknown" self.qemu = command("QEMU_X86_64", "qemu-x86_64") self.sysroot = os.environ.get("OMEGA_NATIVE_X86_SYSROOT", "/usr/x86_64-linux-gnu") self.python = os.environ.get("OMEGA_NATIVE_X86_PYTHON", "") @@ -91,12 +103,46 @@ class Suite: return result.stdout def guest(self, exe, *args): - # Every target execution goes through QEMU, even on a native x86 host. + # Every target execution goes through QEMU unless native execution was requested. + libpath = os.environ.get("OMEGA_NATIVE_X86_LIBPATH") + if self.native: + cmd = ["env", "LD_LIBRARY_PATH=" + libpath] if libpath else [] + return cmd + [str(exe), *map(str, args)] cmd = self.qemu + ["-L", self.sysroot] - if os.environ.get("OMEGA_NATIVE_X86_LIBPATH"): - cmd += ["-E", "LD_LIBRARY_PATH=" + os.environ["OMEGA_NATIVE_X86_LIBPATH"]] + if libpath: + cmd += ["-E", "LD_LIBRARY_PATH=" + libpath] return cmd + [str(exe), *map(str, args)] + def native_host(self): + # Identify the CPU that runs the callers; the label PHYSICAL needs virtualization=none. + if not self.check("native execution host is x86-64 (uname -m " + platform.machine() + ")", + platform.machine() == "x86_64"): + return False + cpuinfo = Path("/proc/cpuinfo").read_text(errors="replace") + model = re.search(r"^model name\s*:\s*(.*)$", cpuinfo, re.M) + flags = re.search(r"^flags\s*:\s*(.*)$", cpuinfo, re.M) + print("INFO cpu model=" + (model.group(1).strip() if model else "(none)"), flush=True) + print("INFO cpu hypervisor flag=" + ("yes" if flags and "hypervisor" in flags.group(1).split() else "no"), flush=True) + print("INFO kernel=" + platform.release(), flush=True) + if shutil.which("systemd-detect-virt"): + result = subprocess.run(["systemd-detect-virt"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + self.virt = result.stdout.decode(errors="replace").strip() or "unknown" + print("INFO virtualization=" + self.virt, flush=True) + binfmt = Path("/proc/sys/fs/binfmt_misc/qemu-aarch64") + if binfmt.is_file(): + interpreter = re.search(r"^interpreter (.*)$", binfmt.read_text(errors="replace"), re.M) + print("INFO binfmt qemu-aarch64 interpreter=" + (interpreter.group(1) if interpreter else "(none)"), flush=True) + # The pinned compilers are AArch64 executables; they must still run on this host. + for name, path in (("generator", self.omc), ("x86", self.xomc)): + try: + ran = subprocess.run([path], input=b"", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=60) + runs = ran.returncode >= 0 + except (OSError, subprocess.TimeoutExpired): + runs = False + self.check(name + " compiler (AArch64) executes on this host", runs) + return not self.failed + + def qemu_oracle(self): # Identify the emulator, then probe the guest services the callers depend on. # A probe, not a version string: a patched or rebuilt QEMU is judged by behavior. @@ -125,8 +171,13 @@ class Suite: return usable def preflight(self): + if self.mode not in ("qemu", "native"): + self.check("OMEGA_NATIVE_X86_EXEC is qemu or native, not " + repr(self.mode), False) + return False tools = {"c": self.cc, "cpp": self.cxx, "rust": self.rust, "zig": self.zig, "go": self.go, - "qemu": self.qemu, "nm": self.nm, "objdump": self.objdump} + "nm": self.nm, "objdump": self.objdump} + if not self.native: + tools["qemu"] = self.qemu for language, cmd in tools.items(): if not cmd or not shutil.which(cmd[0]): self.missing.append(language) @@ -144,7 +195,9 @@ class Suite: and digest(Path(path).read_bytes()) == match.group(1))) if self.missing or self.failed: return False - if not self.qemu_oracle(): + if self.native and not self.native_host(): + return False + if not self.native and not self.qemu_oracle(): return False rustlib = self.must(self.rust + ["--print", "target-libdir", "--target", "x86_64-unknown-linux-gnu"]).decode().strip() if not list(Path(rustlib).glob("libstd-*.rlib")): @@ -283,14 +336,14 @@ class Suite: continue result = self.call(self.guest(self.lib / ("caller_" + language))) transcript = result.stdout + result.stderr - if self.check(language + " caller EMULATED", result.returncode == 0 and b"PASS" in transcript and b"FAIL" not in transcript): + if self.check(language + " caller " + self.how, result.returncode == 0 and b"PASS" in transcript and b"FAIL" not in transcript): self.ran.add(language) if language == "rust": build = self.build_language(language, self.lib, edition="2024") - self.check("rust-2024 caller EMULATED", build.returncode == 0 and self.call(self.guest(self.lib / "caller_rust")).returncode == 0) + self.check("rust-2024 caller " + self.how, build.returncode == 0 and self.call(self.guest(self.lib / "caller_rust")).returncode == 0) built = self.build_c(self.lib, Path(__file__).with_name("sysv.c"), "sysv", extra=[str(Path(__file__).with_name("sysv.S"))]) - self.check("SysV AMD64 saved-register oracle EMULATED", + self.check("SysV AMD64 saved-register oracle " + self.how, built.returncode == 0 and self.call(self.guest(self.lib / "sysv")).returncode == 0) def stale_and_v1(self): @@ -455,7 +508,7 @@ class Suite: self.check("global helper mutant rejected at link", result.returncode != 0 and b"multiple definition" in result.stderr and b"ombr_enter" in result.stderr) else: self.must_build(result) - self.check("separate bindings and TLS isolation EMULATED", self.call(self.guest(folder / "caller")).returncode == 0) + self.check("separate bindings and TLS isolation " + self.how, self.call(self.guest(folder / "caller")).returncode == 0) def freestanding_api(self): folder = self.out / "api" @@ -475,7 +528,7 @@ class Suite: exe = folder / "fsmain" self.must(self.cc + ["-std=gnu11", "-O2", "-I", str(self.lib), str(T / "fsmain.c"), str(folder / "use.o"), str(folder / "defs.o"), "-L" + str(self.lib), "-lomega_native", "-Wl,-rpath," + str(self.lib), "-o", str(exe)]) result = self.call(self.guest(exe)) - self.check("out-of-line API EMULATED", result.returncode == 0 and b"PASS fs_check 0" in result.stdout) + self.check("out-of-line API " + self.how, result.returncode == 0 and b"PASS fs_check 0" in result.stdout) result = self.call(self.guest(exe, "refuse")) self.check("out-of-line API trap aborts", result.returncode in (-6, 134)) for name, old, new in (("apih", b"if eq get st 5 8\n", b"if eq get st 5 98\n"), @@ -572,7 +625,7 @@ class Suite: extra=["-DEXPECT_TRAP=" + str(expected), str(here / "sysv.S")]) self.must_build(build) result = self.call(self.guest(folder / "trapcheck")) - self.check(name + ": status " + str(expected) + ", sentinel, saved regs and subsequent call EMULATED", + self.check(name + ": status " + str(expected) + ", sentinel, saved regs and subsequent call " + self.how, result.returncode == 0 and b"PASS trap status" in result.stdout) def freestanding_x86(self): @@ -610,10 +663,10 @@ class Suite: "-I", str(lib), str(caller), str(obj), "-o", str(tree / "caller")])) result = self.call(self.guest(tree / "caller")) if source is good: - self.check("freestanding x86 epoch/MAX trap, nested and signed trap, four threads EMULATED", + self.check("freestanding x86 epoch/MAX trap, nested and signed trap, four threads " + self.how, result.returncode == 0) else: - self.check("freestanding x86 result-store mutant caught by caller EMULATED", + self.check("freestanding x86 result-store mutant caught by caller " + self.how, result.returncode == 1) def freestanding_om2_x86(self): @@ -684,14 +737,15 @@ class Suite: "-pthread", "-o", str(folder / "floorcheck")]) result = self.call(self.guest(folder / "floorcheck")) if mutated: - self.check("carved-top floor mutant rejected without crash EMULATED", + self.check("carved-top floor mutant rejected without crash " + self.how, result.returncode == 1 and b"FAIL stack floor" in result.stdout) else: - self.check("actual R15 mapping floor with ABI-v2 out buffer EMULATED", + self.check("actual R15 mapping floor with ABI-v2 out buffer " + self.how, result.returncode == 0 and b"PASS R15 equals actual" in result.stdout) def finish(self): - print("NATIVE-X86 NATIVE NOT_RUN (physical x86 execution not requested)", flush=True) + if not self.native: + print("NATIVE-X86 NATIVE NOT_RUN (physical x86 execution not requested)", flush=True) if self.failed: print("NATIVE-X86 FAIL " + "; ".join(self.failed), flush=True) return 1 @@ -699,6 +753,10 @@ class Suite: if missing: print("NATIVE-X86 NOT_RUN (not run: " + " ".join(sorted(missing)) + ")", flush=True) return 1 + if self.native: + print("NATIVE-X86 NATIVE PASS (six languages built and run on the host x86-64 CPU; " + "virtualization=" + self.virt + ")", flush=True) + return 0 print("NATIVE-X86 EMULATED PASS (six languages built and run; native x86 NOT_RUN)", flush=True) return 0 diff --git a/tests/native/x86/test_build_failures.py b/tests/native/x86/test_build_failures.py index 0c25be5..3c3ddc2 100755 --- a/tests/native/x86/test_build_failures.py +++ b/tests/native/x86/test_build_failures.py @@ -5,6 +5,8 @@ Requires the same real toolchains/interpreter as run.sh; never emulates a build. OMEGA_NATIVE_X86_BAD_QEMU, when set, names an emulator known to break the callers (for example Ubuntu's QEMU 8.2.2); the suite must refuse it with QEMU-ORACLE-UNUSABLE before any caller runs. Unset, that control is NOT_RUN. +OMEGA_NATIVE_X86_EXEC=native runs every case natively (see suite.py); the +known-bad QEMU control is then NOT_RUN and the positive case must print NATIVE. Optional EMPTY_OUTPUT retains every case's stdout, command/status and numbered build/run logs. By default a fresh timestamped directory is created under @@ -34,6 +36,10 @@ def main(): out.mkdir(parents=True, exist_ok=True) print("INFO control evidence: " + str(out), flush=True) env = dict(os.environ) + native = env.get("OMEGA_NATIVE_X86_EXEC", "qemu") == "native" + how = b"NATIVE" if native else b"EMULATED" + # No control may print an aggregate PASS line, in either execution mode. + aggregate_pass = b" PASS (six languages built and run" # The positive run must resolve actual compilers, not control scripts. for key, default_tool in (("ZIG", "zig"), ("GO", "go")): value = env.get(key, default_tool) @@ -58,20 +64,28 @@ def main(): # The failing compiler's signal is in a numbered command log, and # the aggregate must be FAIL, not a silent skip or green run. signals = b"".join(p.read_bytes() for p in (out / key).glob("*.log")) - if run.returncode == 0 or b"NATIVE-X86 FAIL" not in run.stdout or b"EMULATED PASS" in run.stdout or f"CONTROL: {key} build refused".encode() not in signals: + if run.returncode == 0 or b"NATIVE-X86 FAIL" not in run.stdout or aggregate_pass in run.stdout or f"CONTROL: {key} build refused".encode() not in signals: sys.stdout.buffer.write(run.stdout) print("FAIL control " + key + ": failed build was not refused; logs: " + str(out)) return 1 print("PASS failed-toolchain control " + key, flush=True) missing = dict(env, ZIG=str(out / "absent-zig"), GO=str(out / "absent-go")) run = run_case("missing", missing) - if run.returncode == 0 or b"NATIVE-X86 NOT_RUN" not in run.stdout or b"NOT_RUN zig" not in run.stdout or b"NOT_RUN go" not in run.stdout or b"EMULATED PASS" in run.stdout: + if run.returncode == 0 or b"NATIVE-X86 NOT_RUN" not in run.stdout or b"NOT_RUN zig" not in run.stdout or b"NOT_RUN go" not in run.stdout or aggregate_pass in run.stdout: sys.stdout.buffer.write(run.stdout) print("FAIL missing-toolchain control; logs: " + str(out)) return 1 print("PASS missing Zig and Go refuse aggregate PASS (#34)", flush=True) + run = run_case("bad-mode", dict(env, OMEGA_NATIVE_X86_EXEC="hardware")) + if run.returncode == 0 or b"NATIVE-X86 FAIL" not in run.stdout or b" caller " in run.stdout or aggregate_pass in run.stdout: + sys.stdout.buffer.write(run.stdout) + print("FAIL unknown execution mode control: mode was not refused; logs: " + str(out)) + return 1 + print("PASS unknown OMEGA_NATIVE_X86_EXEC refused before any caller ran", flush=True) bad = env.get("OMEGA_NATIVE_X86_BAD_QEMU") - if bad: + if native: + print("INFO known-bad QEMU control NOT_RUN: native execution does not use QEMU", flush=True) + elif bad: run = run_case("bad-qemu", dict(env, QEMU_X86_64=bad)) if run.returncode == 0 or b"NOT_RUN QEMU-ORACLE-UNUSABLE" not in run.stdout or b"NATIVE-X86 NOT_RUN" not in run.stdout or b"caller EMULATED" in run.stdout or b"EMULATED PASS" in run.stdout: sys.stdout.buffer.write(run.stdout) @@ -82,14 +96,17 @@ def main(): print("INFO known-bad QEMU control NOT_RUN: OMEGA_NATIVE_X86_BAD_QEMU unset", flush=True) run = run_case("positive", env) sys.stdout.buffer.write(run.stdout) - if run.returncode != 0 or b"NATIVE-X86 EMULATED PASS (six languages built and run; native x86 NOT_RUN)" not in run.stdout: + positive = (b"NATIVE-X86 NATIVE PASS (six languages built and run on the host x86-64 CPU; virtualization=" + if native else b"NATIVE-X86 EMULATED PASS (six languages built and run; native x86 NOT_RUN)") + if run.returncode != 0 or positive not in run.stdout: print("FAIL real-toolchain positive control; logs: " + str(out)) return 1 for language in ("c", "cpp", "python", "rust", "zig", "go"): - if ("PASS " + language + " caller EMULATED").encode() not in run.stdout: + if ("PASS " + language + " caller ").encode() + how not in run.stdout: print("FAIL positive caller missing: " + language) return 1 - print("NATIVE-X86 CONTROLS PASS (EMULATED; native x86 NOT_RUN)") + print("NATIVE-X86 CONTROLS PASS (NATIVE; see the positive case's virtualization line)" if native + else "NATIVE-X86 CONTROLS PASS (EMULATED; native x86 NOT_RUN)") return 0