Two abi(.compiler) build-pipeline primitives the sx driver will pass to link: - c_object_paths() -> List(string) (#import c companion objects) - link_libraries() -> List(string) (#library names) They live in a new stdlib home library/modules/std/build.sx and are serviced by comptime_vm.callCompilerFn reading two new BuildConfig fields that main.zig forwards before the post-link callback. New reusable VM helper makeStringList builds a List(string) in flat memory from the call's result type offsets (target-aware); invoke/callCompilerFn now thread ins.ty for that. Legacy handlers bail loudly (VM-only by nature — post-link; List(string) isn't faithfully buildable in the legacy Value model, 0141). Smoke test examples/1662-platform-build-pipeline-queries (AOT + a 1-line C #source → one object): a post-link callback verifies the VM-built list is well-formed; build exit 0 only if so (negative-probe confirmed a real guard). emit_object + link (the actions) deferred to P5.2b — they replace the Zig driver's auto-emit/auto-link and need a host-installed callback vtable. 703/0 both gates.
41 lines
1.4 KiB
Plaintext
41 lines
1.4 KiB
Plaintext
#import "modules/std.sx";
|
|
#import "modules/build.sx";
|
|
#import "modules/std/build.sx";
|
|
|
|
// P5.2 smoke test — the build-pipeline metadata queries (`c_object_paths` /
|
|
// `link_libraries`) run on the comptime VM and return a `List(string)` the VM
|
|
// builds in flat memory. Registered as a post-link callback (which runs on the
|
|
// VM — core.invokeByFuncId), so the lists are 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();
|
|
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()); }
|