test(ffi-linkage): xfail export fn called from C via AOT (Phase 2.0)

Phase 2 of the extern/export stream verifies `export` (define + expose a
C-ABI sx symbol) end-to-end. C->sx-by-name linkage cannot work under the
corpus's `sx run` JIT mode — a JIT-resident symbol is invisible to a
dlopen'd C dylib's flat-namespace lookup — so this lands a new AOT
execution mode for the corpus: an `expected/<name>.aot` marker switches an
example from JIT `sx run` to a `sx build` + execute flow, linking the sx
object with its C `#source` companions into a native binary.

example/1226 defines `sx_square :: (n: i32) -> i32 export { ... }` and a
companion .c that declares `extern int sx_square(int)` and calls it back.
RED: with `export` not yet lowered, the AOT link fails with an undefined
`_sx_square` (the define path still emits it `internal` + with an implicit
ctx slot, and lazy lowering leaves an uncalled export fn as a bodiless
declare). Phase 2.1 greens it.

Also retires the standalone `tests/run_examples.sh` runner — `zig build
test` (src/corpus_run.test.zig) is now the sole corpus runner, and the
shell mirror would have needed its own AOT-mode port to stay in lockstep.
verify-step.sh drops its redundant step (zig build test already runs the
corpus); CLAUDE.md documents the `.aot` mode.
This commit is contained in:
agra
2026-06-14 14:41:33 +03:00
parent 6932426c41
commit 6a539ca057
11 changed files with 138 additions and 202 deletions

View File

@@ -20,13 +20,12 @@ cd "$ROOT"
echo "── 1/5 zig build ─────────────────────────────────────"
zig build
echo "── 2/5 zig build test ────────────────────────────────"
echo "── 2/4 zig build test ────────────────────────────────"
# Runs the unit tests AND the full example/issue regression corpus
# (src/corpus_run.test.zig) — a failing example fails the build.
zig build test
echo "── 3/5 example regression suite ──────────────────────"
bash tests/run_examples.sh
echo "── 4/5 chess: cross-build for all 3 platforms ────────"
echo "── 3/4 chess: cross-build for all 3 platforms ────────"
# Builds must be serial — sx writes to .sx-tmp/ which would race in parallel.
cd "$GAME"
"$SX" build main.sx > /tmp/sx-game-macos-build.log 2>&1 \
@@ -39,7 +38,7 @@ echo " iOS sim OK"
|| { echo "Android build failed:"; cat /tmp/sx-game-android-build.log; exit 1; }
echo " Android OK"
echo "── 5/5 chess: launch + screenshot on each platform ───"
echo "── 4/4 chess: launch + screenshot on each platform ───"
# macOS — direct binary launch
./sx-out/macos/SxChess > /tmp/sx-game-macos-run.log 2>&1 &