#import "modules/std.sx"; #import "modules/build.sx"; #import "modules/compiler.sx"; // P5.2b smoke test — the `link` build-pipeline ACTION runs on the comptime VM, // dispatching through the host-installed linker hook (the VM can't link itself). // The post-link callback (which runs on the VM — core.invokeByFuncId) re-links // the build's own objects into a temp output via the sx `link` primitive. A link // failure bails → the build fails; success → the callback returns true and the // build's binary runs ("runtime main"). AOT snapshots the binary, so the link's // success is observed via the build exit code. relink :: () -> bool abi(.compiler) { objs := List(string).{}; cobjs := c_object_paths(); i : i64 = 0; while i < cobjs.len { objs.append(cobjs.items[i]); i += 1; } objs.append(emit_object()); fws := List(string).{}; flags := List(string).{}; link(objs, ".sx-tmp/1663-link-out", link_libraries(), fws, flags, ""); return true; } configure :: () abi(.compiler) { opts := build_options(); opts.set_post_link_callback(relink); } #run configure(); main :: () { print("runtime main\n"); }