Files
sx/examples/1663-platform-build-pipeline-link.sx
agra d8affd45e8 rename std/build.sx -> modules/compiler.sx (the compiler-API surface)
Per user direction: the low-level abi(.compiler) primitive surface is the
comptime 'compiler' library, so name the file compiler.sx (a peer of build.sx)
instead of the interim std/build.sx — which also frees the 'build' name for the
default build IMPLEMENTATION (default_build + on_build slot), which will live in
modules/build.sx alongside the BuildOptions DSL.

Updated the two example imports + the plan's Phase 5 file-split note. 704/0
both gates.
2026-06-19 08:17:35 +03:00

32 lines
1.1 KiB
Plaintext

#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"); }