#import "modules/std.sx"; #import "modules/build.sx"; #import "modules/compiler.sx"; // P5.2 smoke test — the build-pipeline query primitives (`c_object_paths` / // `link_libraries` / `emit_object`) run on the comptime VM: the list queries // return a `List(string)` the VM builds in flat memory; `emit_object` returns // the compiler-emitted object path. Registered as a post-link callback (which // runs on the VM — core.invokeByFuncId), so the build state is live there. // // The `#import c` source compiles to one `.o`, so `c_object_paths()` must return // a one-element list whose single string is the (non-empty) object path. AOT // snapshots the executed binary, so success is observed via the build exit code: // the callback returns true only if the VM-built list is well-formed. #import c { #source "1662-platform-build-pipeline-queries.c"; }; c_marker :: () -> i64 extern; check :: () -> bool abi(.compiler) { objs := c_object_paths(); libs := link_libraries(); obj := emit_object(); // the compiler-emitted sx object path if obj.len == 0 { return false; } if objs.len != 1 { return false; } if objs.items[0].len == 0 { return false; } // `link_libraries` must be a well-formed (possibly empty) list — touch each // entry so a malformed fat pointer would fault rather than pass silently. sum : i64 = 0; i : i64 = 0; while i < libs.len { sum += libs.items[i].len; i += 1; } return sum >= 0; } configure :: () abi(.compiler) { opts := build_options(); opts.set_post_link_callback(check); } #run configure(); main :: () { print("runtime main: {}\n", c_marker()); }