P5.4 core: drive the whole build from sx default_pipeline (no auto-emit/link)
The compiler's post-IR role shrinks to: codegen -> invoke the build callback. There is NO Zig auto-emit / auto-link anymore; emit + link are sx-called actions. - emit_object() is now an ACTION (verify + emit via a host BuildHooks vtable), returning the object path. New query primitives build_output/build_target/ build_frameworks/build_flags (data reads from the merged BuildConfig). - library/modules/build.sx imports compiler.sx and defines default_pipeline: emit_object -> gather c_object_paths -> link(objs, output, libs, fws, flags, target). The std<->build import cycle is handled by the resolver. - The compiler FORCE-LOWERS default_pipeline (well-known name) and AUTO-INVOKES it post-codegen when no on_build/set_post_link_callback override was registered (driver's final fallback: invokeByName default_pipeline). - Prelude-less programs (e.g. asm tests) don't import build.sx, so the BUILD path auto-imports modules/build.sx (idempotent if already transitive) so default_pipeline is always available. JIT sx run is untouched (emits in-process). - Removed the build cache short-circuits (incompatible with the always-run sx driver; a future cache can live in default_pipeline). Benign 37-.ir churn (build.sx grew); zero behavior changes (verified diff is .ir-only). 705/0 both gates.
This commit is contained in:
@@ -1523,17 +1523,42 @@ pub const Vm = struct {
|
||||
return self.failMsg("comptime link_libraries: no build config threaded into the VM");
|
||||
return try self.makeStringList(table, result_ty, bc.link_libraries);
|
||||
}
|
||||
// `emit_object() -> string` — the compiler emits the object eagerly (the Zig
|
||||
// driver, before the post-link callback); this returns its path. A query,
|
||||
// not an action — so no driver callback is needed (unlike `link`).
|
||||
// `emit_object() -> string` — ACTION: verify + emit the codegen'd module
|
||||
// to its object file and return the path. Dispatches through the
|
||||
// host-installed hook (the VM can't emit itself); the driver no longer
|
||||
// auto-emits (everything is sx-driven via `default_pipeline`).
|
||||
if (std.mem.eql(u8, name, "emit_object")) {
|
||||
if (args.len != 0) return self.failMsg("comptime emit_object: expected no args");
|
||||
const bc = self.build_config orelse
|
||||
return self.failMsg("comptime emit_object: no build config threaded into the VM");
|
||||
const path = bc.object_path orelse
|
||||
return self.failMsg("comptime emit_object: no object was emitted (object_path unset)");
|
||||
const hooks = bc.build_hooks orelse
|
||||
return self.failMsg("comptime emit_object: no build hooks installed (emit is a post-codegen-only action)");
|
||||
const path = hooks.emit_object(hooks.ctx) catch
|
||||
return self.failMsg("comptime emit_object: object emission failed");
|
||||
return try self.makeStringValue(table, path);
|
||||
}
|
||||
// Build-config metadata the sx driver passes to `link`. Read-only data
|
||||
// forwarded by `main.zig` (the merged CLI + `#run` build config).
|
||||
if (std.mem.eql(u8, name, "build_output")) {
|
||||
if (args.len != 0) return self.failMsg("comptime build_output: expected no args");
|
||||
const bc = self.build_config orelse return self.failMsg("comptime build_output: no build config");
|
||||
return try self.makeStringValue(table, bc.output_path orelse "");
|
||||
}
|
||||
if (std.mem.eql(u8, name, "build_target")) {
|
||||
if (args.len != 0) return self.failMsg("comptime build_target: expected no args");
|
||||
const bc = self.build_config orelse return self.failMsg("comptime build_target: no build config");
|
||||
return try self.makeStringValue(table, bc.target_triple orelse "");
|
||||
}
|
||||
if (std.mem.eql(u8, name, "build_frameworks")) {
|
||||
if (args.len != 0) return self.failMsg("comptime build_frameworks: expected no args");
|
||||
const bc = self.build_config orelse return self.failMsg("comptime build_frameworks: no build config");
|
||||
return try self.makeStringList(table, result_ty, bc.target_frameworks);
|
||||
}
|
||||
if (std.mem.eql(u8, name, "build_flags")) {
|
||||
if (args.len != 0) return self.failMsg("comptime build_flags: expected no args");
|
||||
const bc = self.build_config orelse return self.failMsg("comptime build_flags: no build config");
|
||||
return try self.makeStringList(table, result_ty, bc.merged_link_flags);
|
||||
}
|
||||
// `link(objects, output, libraries, frameworks, flags, target)` — the one
|
||||
// genuine ACTION: dispatch to the host-installed linker (the VM can't link
|
||||
// itself). Void return (the build callback isn't fallible — Phase 5
|
||||
|
||||
Reference in New Issue
Block a user