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:
agra
2026-06-19 09:22:54 +03:00
parent 1f796e92ec
commit d178454841
44 changed files with 93042 additions and 80510 deletions

View File

@@ -71,11 +71,11 @@ pub const BuildConfig = struct {
c_object_paths: []const []const u8 = &.{},
link_libraries: []const []const u8 = &.{},
/// Path of the object file the compiler emitted for this build (`.sx-tmp/main.o`
/// or the cached `.o`). Forwarded by main.zig before the post-link callback so
/// the sx build driver can read it via the `emit_object()` compiler primitive
/// (the compiler emits the object eagerly; the primitive returns its path).
object_path: ?[]const u8 = null,
/// The fully-merged link flags (CLI `extra_link_flags` + `#run` build-block
/// flags), forwarded by main.zig. The sx driver reads them via `build_flags()`
/// and passes them to `link`. (Distinct from `link_flags`, which holds only
/// the `#run`-accumulated subset.)
merged_link_flags: []const []const u8 = &.{},
/// Host-installed callbacks for build-pipeline ACTIONS the comptime VM can't
/// perform itself (it can't depend on the driver — `core`/`main`/`target`).
@@ -126,6 +126,10 @@ pub const BuildConfig = struct {
/// error here and the VM surfaces it as a hard build error.
pub const BuildHooks = struct {
ctx: *anyopaque,
/// Verify + emit the codegen'd module to its object file; return the path
/// (ctx-owned). The `emit_object()` primitive — an ACTION, since the driver
/// no longer auto-emits (everything is sx-driven via `default_pipeline`).
emit_object: *const fn (ctx: *anyopaque) anyerror![]const u8,
/// Link `objects` → `output`, with the given `libraries` / `frameworks` /
/// link `flags` / `target` triple. (`objects` is the full object list; the
/// adapter splits it for the underlying linker.)