Skip to content

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

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
tedin7:x2w-cmake-batch-py
Nov 24, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
tedin7:x2w-cmake-batch-py

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants