Files
sx/examples/1661-platform-post-link-vm-list.sx
agra 7cba33ea6d P5.1: post-link build driver runs on the comptime VM (no fallback)
core.invokeByFuncId routes the post-link callback through comptime_vm.tryEval
instead of the legacy Interpreter. REQUIRED because the sx build driver
allocates/grows Lists, which the legacy interp can't do at comptime (issue
0141: struct_get: base has no fields); the VM can. No fallback (a
side-effecting post-link callback can't double-execute): a VM bail is a hard
build error (comptime_vm.last_bail_reason, surfaced by printInterpBailDiag).
BuildConfig + import_sources threaded in; non-empty args rejected loudly.
flushInterpOutput deleted (VM out writes direct via host-FFI).

Smoke test examples/1661-platform-post-link-vm-list (AOT): a post-link
callback grows a List to 3 + returns len==3, so the build succeeds (exit 0)
only via the VM. First corpus coverage of the post-link path.

702/0 both gates.
2026-06-19 07:20:42 +03:00

34 lines
1.2 KiB
Plaintext

#import "modules/std.sx";
#import "modules/build.sx";
// P5.1 smoke test — the post-link build driver runs on the comptime VM,
// not the legacy interpreter.
//
// The callback allocates and GROWS a `List` (three appends). Comptime List
// growth works only on the VM; the legacy interp fails it (issue 0141:
// `struct_get: base has no fields`). So this build SUCCEEDS only because
// `core.invokeByFuncId` routes the post-link callback through the VM.
//
// AOT note: the corpus snapshots an AOT example's *executed binary* streams,
// and the build step's own stdout is discarded — so the callback's success is
// observed via the build EXIT CODE. On the VM the callback returns true, the
// build links cleanly (exit 0), and the binary runs → "runtime main". If the
// driver regressed to the legacy interp the callback would bail, the build
// would exit non-zero, and this snapshot would fail.
post_link :: () -> bool abi(.compiler) {
names := List(string).{};
names.append("alpha");
names.append("beta");
names.append("gamma");
return names.len == 3;
}
configure :: () abi(.compiler) {
opts := build_options();
opts.set_post_link_callback(post_link);
}
#run configure();
main :: () { print("runtime main\n"); }