build: write the variants of each x87 fixture in one Python process #1789

Manually merged
github merged 2 commits from gh-pr/1789/head into gh-pr/1789/base 2026-11-26 23:33:42 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 18:43 UTC · original
tedin7:x2w-cmake-batch-py → main · +267 −147 · 3 files · 2 commits · merged 2026-11-24 22:08 UTC

Writes the variants of each x87 fixture from one Python process instead of one process per variant. No generated file, dependency, target or CTest name changes.

What changed

  • tools/emit_variants.py (new): emit_variants.py <script> <image> <variant>=<output>... loads the fixture script as a module and calls its own emit(image, output, control) for each variant, in order. The interpreter, the PE reader and the lifter modules load once per fixture. Accepts one or more <variant>=<output> pairs and rejects missing or malformed pairs.
  • CMakeLists.txt: a helper x2w_emit_variants() makes one custom command per fixture with every variant file as OUTPUT (same path as before: <image>_<variant>.cpp in the build directory) and the same DEPENDS (plus the new driver). The 21 foreach(variant ...) groups for tests/cpu/x87_*.py call it; their add_library lines and the CTest names are untouched.
  • tests/emit_variants_check.py + CTest emit_variants: a synthetic fixture script; the driver must write the same bytes as one process per variant (both multi-variant and single-variant), fail when a variant fails, and refuse malformed or missing pairs.

Verification on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + Ninja + MASM)
At commit 6a1729779bc00454b97cd32ceb22e4796c90acce (building cpu_x87_harness plus 4 x87 fixture groups — cpu_x87_add, cpu_x87_mul, cpu_x87_fnstcw, cpu_x87_bcd — 4 batched Python steps instead of 29, 29 generated DLLs):

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target cpu_x87_harness cpu_x87_{add,mul,fnstcw,bcd}* -- -j 8): 4.98s (configure 1.84s)
    • Test (ctest --preset dev -R '^(emit_variants|cpu_aot_x87_add|cpu_aot_x87_mul|cpu_aot_x87_fnstcw|cpu_aot_x87_bcd)$' --parallel 6 --no-tests=error --output-on-failure): 5/5 passed (3.93s: emit_variants 0.96s, cpu_aot_x87_fnstcw 1.18s, cpu_aot_x87_add 2.07s, cpu_aot_x87_mul 3.63s, cpu_aot_x87_bcd 3.82s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target cpu_x87_harness cpu_x87_{add,mul,fnstcw,bcd}* -- -j 8): 2.01s (configure 1.76s)
    • Test (ctest --preset release -R '^(emit_variants|cpu_aot_x87_add|cpu_aot_x87_mul|cpu_aot_x87_fnstcw|cpu_aot_x87_bcd)$' --parallel 6 --no-tests=error --output-on-failure): 5/5 passed (4.02s: emit_variants 0.95s, cpu_aot_x87_fnstcw 1.17s, cpu_aot_x87_add 2.20s, cpu_aot_x87_mul 3.61s, cpu_aot_x87_bcd 3.92s)
  • sccache: 58/58 hits (100.00%, confirming identical generated C++ outputs); total wall 25.12s.
  • Mutation check on Windows: mutating tools/emit_variants.py to always pass "lifted" instead of variant caused ctest -R '^emit_variants$' to fail (AssertionError: pc64: batch wrote b'image.dll:lifted:True', one process per variant wrote b'image.dll:pc64:True', 0.30s).

Linux byte-for-byte & hygiene checks

  • Python processes for these 21 fixtures: 166 -> 21.
  • All 166 generated .cpp files matched byte-for-byte (diff -rq) against one process per variant.
  • git diff --check, tests/emit_variants_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py: pass.
  • git merge-tree against origin/main, #1173, #1740, #1752: 0 conflicts.

Scope note

  • The 12 other emit <image> <out> <variant> groups (rcx_branches, string_ops, trap, ...) are not changed here; they can use the same helper in a follow-up.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 18:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1789) `tedin7:x2w-cmake-batch-py` → `main` · +267 −147 · 3 files · 2 commits · merged 2026-11-24 22:08 UTC Writes the variants of each x87 fixture from one Python process instead of one process per variant. No generated file, dependency, target or CTest name changes. **What changed** - `tools/emit_variants.py` (new): `emit_variants.py <script> <image> <variant>=<output>...` loads the fixture script as a module and calls its own `emit(image, output, control)` for each variant, in order. The interpreter, the PE reader and the lifter modules load once per fixture. Accepts one or more `<variant>=<output>` pairs and rejects missing or malformed pairs. - `CMakeLists.txt`: a helper `x2w_emit_variants()` makes one custom command per fixture with every variant file as `OUTPUT` (same path as before: `<image>_<variant>.cpp` in the build directory) and the same `DEPENDS` (plus the new driver). The 21 `foreach(variant ...)` groups for `tests/cpu/x87_*.py` call it; their `add_library` lines and the CTest names are untouched. - `tests/emit_variants_check.py` + CTest `emit_variants`: a synthetic fixture script; the driver must write the same bytes as one process per variant (both multi-variant and single-variant), fail when a variant fails, and refuse malformed or missing pairs. **Verification on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + Ninja + MASM)** At commit `6a1729779bc00454b97cd32ceb22e4796c90acce` (building `cpu_x87_harness` plus 4 x87 fixture groups — `cpu_x87_add`, `cpu_x87_mul`, `cpu_x87_fnstcw`, `cpu_x87_bcd` — 4 batched Python steps instead of 29, 29 generated DLLs): - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target cpu_x87_harness cpu_x87_{add,mul,fnstcw,bcd}* -- -j 8`): `4.98s` (configure `1.84s`) - Test (`ctest --preset dev -R '^(emit_variants|cpu_aot_x87_add|cpu_aot_x87_mul|cpu_aot_x87_fnstcw|cpu_aot_x87_bcd)$' --parallel 6 --no-tests=error --output-on-failure`): **5/5 passed** (`3.93s`: `emit_variants` `0.96s`, `cpu_aot_x87_fnstcw` `1.18s`, `cpu_aot_x87_add` `2.07s`, `cpu_aot_x87_mul` `3.63s`, `cpu_aot_x87_bcd` `3.82s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target cpu_x87_harness cpu_x87_{add,mul,fnstcw,bcd}* -- -j 8`): `2.01s` (configure `1.76s`) - Test (`ctest --preset release -R '^(emit_variants|cpu_aot_x87_add|cpu_aot_x87_mul|cpu_aot_x87_fnstcw|cpu_aot_x87_bcd)$' --parallel 6 --no-tests=error --output-on-failure`): **5/5 passed** (`4.02s`: `emit_variants` `0.95s`, `cpu_aot_x87_fnstcw` `1.17s`, `cpu_aot_x87_add` `2.20s`, `cpu_aot_x87_mul` `3.61s`, `cpu_aot_x87_bcd` `3.92s`) - `sccache`: 58/58 hits (`100.00%`, confirming identical generated C++ outputs); total wall `25.12s`. - **Mutation check on Windows**: mutating `tools/emit_variants.py` to always pass `"lifted"` instead of `variant` caused `ctest -R '^emit_variants$'` to fail (`AssertionError: pc64: batch wrote b'image.dll:lifted:True', one process per variant wrote b'image.dll:pc64:True'`, `0.30s`). **Linux byte-for-byte & hygiene checks** - Python processes for these 21 fixtures: 166 -> 21. - All 166 generated `.cpp` files matched byte-for-byte (`diff -rq`) against one process per variant. - `git diff --check`, `tests/emit_variants_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`: pass. - `git merge-tree` against `origin/main`, `#1173`, `#1740`, `#1752`: 0 conflicts. **Scope note** - The 12 other `emit <image> <out> <variant>` groups (`rcx_branches`, `string_ops`, `trap`, ...) are not changed here; they can use the same helper in a follow-up. AI-assisted; commands listed were executed locally.
Each of the 21 x87 fixture groups started one Python process per variant (166 in all) and every process loaded the interpreter, the PE reader and the lifter again. tools/emit_variants.py now writes all variants of one fixture from one process, through the same emit() the script runs from its command line. Output paths, dependencies and target names are unchanged; x2w_emit_variants() creates one command with every variant file as OUTPUT. tests/emit_variants_check.py checks the driver against one process per variant.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:33:41 +00:00
github manually merged commit 0bf9c546c9 into gh-pr/1789/base 2026-11-26 23:33:42 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 18:54 UTC · original · edited 2026-11-24 18:58 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T18:58:46.678225Z 6a17297 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 18:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1789#issuecomment-7141324770) · edited 2026-11-24 18:58 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6a1729779bc00454b97cd32ceb22e4796c90acce","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T18:58:46.678225Z">2026-11-24T18:58:46.678225Z</relative-time> | `6a17297` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.