Files
sx/current/CHECKPOINT-ASM.md
agra c88f4fbcef test(asm): Phase 0.0 — corpus target-gating + .build JSON config
Adds per-example build/run directives to the corpus runner via an optional
`expected/<name>.build` JSON sidecar (`BuildConfig { aot, target }`), replacing
the standalone `.aot` marker. Threads `--target` into the run/build/ir spawns
and gates the execute path on host arch+os match; a cross-target example fails
loudly ("ir-only mode not yet implemented") pending Phase 0.1.

- corpus_run.test.zig: BuildConfig + std.json parse (unknown-key => error),
  hostMatchesTarget (shorthand-expand + arch/os token match, arm64->aarch64),
  withTarget argv helper; unit tests for both.
- migrate 1226/1227 `.aot` markers -> `.build` { "aot": true }.
- lock fixture 1638-platform-target-host (`.build` { "target": "macos" }).

Test-infra only; no compiler code. zig build test green (646 corpus, 444 unit).
2026-06-15 17:37:35 +03:00

52 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# sx Inline Assembly — Checkpoint (ASM stream)
Companion to `current/PLAN-ASM.md`; design in
[docs/inline-asm-design.md](../docs/inline-asm-design.md). Update after every
commit, one step at a time per the cadence rule (no commit may both add a test
and make it pass).
## Last completed step
**0.0** — corpus runner target-gating + `<name>.build` JSON config. Added
`BuildConfig` (`std.json.parseFromSliceLeaky``struct { aot, target }`,
unknown-key ⇒ `error.UnknownField`) replacing the standalone `.aot` marker;
migrated the 2 existing `.aot` markers (1226/1227) to `{ "aot": true }`; threaded
`--target` into the `run`/`build`/`ir` spawns via `withTarget`; added
`hostMatchesTarget` (shorthand-expand + arch/os token match, `arm64``aarch64`)
gating the execute path. Cross-target mismatch fails **loudly** (placeholder until
0.1's ir-only branch) — verified the bail fires (`target=linux,
host=aarch64-macos`). Locked with `examples/1638-platform-target-host.sx`
(`.build` `{ "target": "macos" }`, runs natively + asserts stdout) + unit tests
for the JSON parse and `hostMatchesTarget`. `zig build test` green (646 corpus, 0
failed; 444 unit, 0 failed). Files: `src/corpus_run.test.zig`,
`examples/1638-*`, `examples/expected/{1226,1227,1638}-*`.
## Current state
Phase 0 step 0.0 landed (test-infra only — no compiler code touched). The corpus
runner now reads `expected/<name>.build` and threads/gates `--target`; an
arch-pinned example whose target matches the host **executes**, a mismatch
currently **bails loudly** ("cross-target ir-only mode not yet implemented"). Phase
AE feasibility already confirmed against the live tree (`LLVMGetInlineAsm` /
`LLVMBuildCall2` / `LLVMAppendModuleInlineAsm` in LLVM@19 `Core.h`; ERR-stream
`extractvalue`→tuple machinery in `emit_llvm.zig:726-927`; lib-less `extern`, 60
sites; `--target` a global CLI flag).
## Next step
**0.1** — implement the **mismatch ⇒ ir-only** branch in `sweepRoot` (replace the
loud placeholder bail): when `cfg.target` doesn't match the host, skip
run/build/exec and assert only `.exit`+`.ir`+`.stderr` from `sx ir --target`;
require an `.ir` snapshot (loud failure if absent). Lock with
`examples/16xx-platform-target-cross.sx` (asm-free `() -> i64 { return 0; }`),
`.build` `{ "target": "x86_64-linux" }`, + a checked-in `.ir` snapshot. Then 0.2
(CLAUDE.md §Testing/§Test-layout docs for `.build`), then Phase A (`kw_asm`). See
`PLAN-ASM.md` Phase 0.
## Log
- (init) Plan + design doc written; ASM stream opened.
- (0.0) Corpus runner target-gating: `<name>.build` JSON config (replaces `.aot`
marker), `--target` threading, `hostMatchesTarget` execute-gate, loud
cross-target placeholder bail. Migrated 1226/1227 `.aot``.build`; locked with
1638 fixture + unit tests. `zig build test` green.
## Known issues
None yet.