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

Merged
tedin7 merged 2 commits from upstream-pr/1789 into main 2026-11-24 22:08:05 +00:00
tedin7 commented 2026-11-24 18:43:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:43:05Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588914895 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1789). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:43:05Z. --- 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.
chatgpt-codex-connector[bot commented 2026-11-24 19:01:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:54:42Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141324770 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1789#issuecomment-7141324770). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:54:42Z. --- <!-- 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>
upstream-sync closed this pull request 2026-11-24 23:03:02 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1782
No description provided.