P5.2b: link() build-pipeline action on the VM via a host vtable
The one genuine action primitive: link(objects, output, libraries, frameworks,
flags, target) in library/modules/std/build.sx. Per the user decision to drop
fallibility from the build callback, link is plain VOID — a link failure bails
on the VM (hard build error), no -> ! / failable-tuple needed.
comptime_vm.zig can't depend on the driver (core/main/target), so link
dispatches through a new compiler_hooks.BuildHooks { ctx, link } vtable that
main.zig installs into BuildConfig.build_hooks before the post-link callback.
The driver side is main.LinkHooksCtx (unions explicit + CLI link flags, calls
target.link). New VM readers readStringList / readStringArg (inverse of
makeStringList) decode the List(string)/string args from flat memory.
Smoke test examples/1663-platform-build-pipeline-link (AOT): a post-link
callback re-links the build's own objects (c_object_paths + emit_object) into a
temp output via sx link — the relinked binary is a functional executable that
runs. Negative-probe verified (bad path -> ld fails -> ComptimeVmBail -> build
exit 1). The Zig driver still auto-links; removing that is P5.4.
704/0 both gates.
This commit is contained in:
@@ -96,15 +96,21 @@ with ONE welded mechanism. Branch: `reify` (off `master`). Update after every st
|
||||
> list is well-formed; build exit 0 ONLY if so (negative-probe verified: wrong count → "post-link callback
|
||||
> returned false", exit 1). **`emit_object() -> string` ALSO landed** (a QUERY — the Zig driver emits eagerly, the
|
||||
> primitive returns `BuildConfig.object_path`; NO vtable). So all three QUERY primitives are done. **703/0 both
|
||||
> gates.** **NEXT — P5.2b: `link(...) -> !` (the one genuine ACTION).** In the end state the Zig driver stops
|
||||
> auto-linking and the sx driver calls `link`, so it needs the driver-restructuring (a callback vtable the host
|
||||
> installs into the VM, since `comptime_vm.zig` can't depend on `core`/`main`/`target`) + a List(string)-arg
|
||||
> READER (inverse of `makeStringList`) + the fallible `-> !` return shape (a `(value…, tag=0)` tuple, since `!T`
|
||||
> is a tuple — `makeOkFailable`). Build it tested via a post-link callback linking to a TEMP output (avoids
|
||||
> clobbering the real binary; the Zig driver still links until P5.4). Then P5.3 (`on_build` slot — invoke WITH the `BuildConfig` arg; needs a VM entry
|
||||
> that marshals args, the gap `invokeByFuncId` rejects today) · P5.4 (sx `default_build` + delete
|
||||
> `#compiler`/`compiler_call`/`compiler_hooks` + the S5a `build_options`/`set_post_link_callback`) — P5.4 kills
|
||||
> the 4 strict `compiler_call` bails (1609/1614/1615/1616).
|
||||
> gates.** **P5.2b (`link` ACTION) DONE (2026-06-19, newest Log entry):** `link(objects, output, libraries,
|
||||
> frameworks, flags, target)` dispatches through a host-installed `compiler_hooks.BuildHooks` vtable (`main.zig`
|
||||
> `LinkHooksCtx` → `target.link`); **USER DECISION: the build callback is NOT fallible** — `link` is plain VOID,
|
||||
> a failure BAILS (hard build error), no `-> !`/failable-tuple needed. New VM readers `readStringList`/
|
||||
> `readStringArg`. Smoke test `1663-platform-build-pipeline-link` (AOT): a post-link callback re-links the build's
|
||||
> objects to a temp output via sx `link` — the relinked binary RUNS; negative-probe verified (bad path → bail →
|
||||
> build exit 1). The Zig driver STILL auto-links (1663 links a separate temp output); removing the auto-link is
|
||||
> P5.4. **704/0 both gates.** **ALL build primitives now exist** (queries `emit_object`/`c_object_paths`/
|
||||
> `link_libraries` + action `link`). **NEXT — P5.3: the `on_build` slot.** A comptime-assignable compiler global
|
||||
> (generalizes `post_link_callback_fn`: an assignable typed global w/ a stdlib default, vs a setter). `#run
|
||||
> on_build = build;` captures the FuncId; the compiler invokes `on_build(config)` post-codegen WITH the
|
||||
> CLI-derived `BuildConfig` as an ARG — which needs a VM entry that MARSHALS args (the gap `core.invokeByFuncId`
|
||||
> rejects today with `ComptimeVmArgsUnsupported`). Then P5.4 (sx `default_build` that calls the primitives +
|
||||
> RESTRUCTURE the driver to stop auto-emit/auto-link + delete `#compiler`/`compiler_call`/`compiler_hooks` + the
|
||||
> S5a `build_options`/`set_post_link_callback`) — P5.4 kills the 4 strict `compiler_call` bails (1609/1614/1615/1616).
|
||||
> **FINAL atomic step (4F):** (`out` already done — VM-native via libc `write`) handle `interp_print_frames` +
|
||||
> flip strict-to-default (remove the fallback) + delete `interp.zig`/`Value` + re-express `define`/`make_enum`.
|
||||
> See `PLAN-COMPILER-VM.md` → Phase 4 for the full plan + top risks (bundler test coverage).
|
||||
@@ -416,6 +422,25 @@ when reached (sentinels or accessor fns; see the design doc Risks).
|
||||
`List` growth; orthogonal, see `current/CHECKPOINT-METATYPE.md`.)
|
||||
|
||||
## Log
|
||||
- **P5.2b (`link` ACTION) — the sx `link` primitive links on the VM via a host-installed vtable; build callback de-failable'd (2026-06-19).**
|
||||
Phase 5's one genuine ACTION primitive: `link(objects, output, libraries, frameworks, flags, target)` (in
|
||||
`library/modules/std/build.sx`). **USER DECISION this step: drop fallibility from the build callback** — so
|
||||
`link` is a plain VOID primitive (no `-> !`), and a link failure BAILS on the VM → hard build error (sidesteps
|
||||
the failable-tuple-return construction entirely). **The vtable:** `comptime_vm.zig` can't depend on the driver
|
||||
(`core`/`main`/`target`), so `link` dispatches through a new `compiler_hooks.BuildHooks { ctx, link_fn }` that
|
||||
`main.zig` installs into `BuildConfig.build_hooks` before the post-link callback. The driver side is
|
||||
`main.LinkHooksCtx` (holds allocator/io/base_config/has_jni_main; its `link` adapter unions the explicit
|
||||
`flags` with the CLI ones and calls `target.link(objects[0], objects[1..], …)` — the linker treats first-vs-rest
|
||||
as equal inputs). **New VM readers** (inverse of `makeStringList`): `readStringList` (a `List(string)` arg →
|
||||
`[][]const u8`, element bytes are views into stable flat-memory arena) + `readStringArg` (a `string` arg).
|
||||
Registered `link` on `bound_fns` (legacy stub bails — VM-only). **Smoke test**
|
||||
`examples/1663-platform-build-pipeline-link` (AOT): a post-link callback re-links the build's own objects (via
|
||||
`c_object_paths` + `emit_object`) into a temp output through the sx `link` primitive — and the **relinked binary
|
||||
is a FUNCTIONAL executable that runs** (verified manually). Build exit 0 only if the VM-driven link succeeds;
|
||||
**negative-probe verified** (bad output path → `ld` fails → `ComptimeVmBail: comptime link: linking failed`,
|
||||
build exit 1 — the P5.1 VM-reason diagnostic path). **The driver still auto-links too** (P5.2b does NOT remove
|
||||
the Zig driver's `target.link`; the test links to a SEPARATE temp output) — removing the auto-link + having
|
||||
`on_build` drive everything is P5.3/P5.4. **704/0 both gates.**
|
||||
- **P5.2 (metadata queries) — `c_object_paths` / `link_libraries` compiler primitives + the VM `List(string)` builder (2026-06-19).**
|
||||
Phase 5 step 2 (the read-only slice): two `abi(.compiler)` primitives that the sx build driver will pass to
|
||||
`link` — `c_object_paths() -> List(string)` (the `#import c` companion `.o`s) and `link_libraries() -> List(string)`
|
||||
|
||||
@@ -511,11 +511,13 @@ The compiler's whole post-IR role: codegen → build the CLI-derived `BuildConfi
|
||||
`invoke`/`callCompilerFn`). Smoke test `1662-platform-build-pipeline-queries` (AOT + C companion). 703/0 both
|
||||
gates. **`emit_object() -> string` is also DONE (2026-06-19)** as a QUERY (not an action): the Zig driver emits
|
||||
the object eagerly, so the primitive just returns the path from `BuildConfig.object_path` (no vtable). So all
|
||||
three QUERY primitives are done. **P5.2b — `link(...) -> !` (the one genuine ACTION):** still TODO — it replaces
|
||||
the Zig driver's auto-link, so it needs the driver restructuring + a host-installed callback vtable
|
||||
(`comptime_vm.zig` can't depend on `core`/`main`/`target`) + a `List(string)`-arg reader (inverse of
|
||||
`makeStringList`) + the fallible `-> !` return (a `(value…, tag=0)` tuple, since `!T` is a tuple). Test it via a
|
||||
post-link callback linking to a TEMP output (the Zig driver still links until P5.4).
|
||||
three QUERY primitives are done. **P5.2b — `link(...)` (the one genuine ACTION) — DONE (2026-06-19).** USER
|
||||
DECISION: the build callback is NOT fallible, so `link` is plain VOID (no `-> !`) and a failure BAILS (hard
|
||||
build error) — no failable-tuple construction. It dispatches through a host-installed `compiler_hooks.BuildHooks`
|
||||
vtable (`comptime_vm.zig` can't depend on the driver); `main.LinkHooksCtx.link` adapts to `target.link`. New VM
|
||||
readers `readStringList`/`readStringArg` (inverse of `makeStringList`). Smoke test
|
||||
`1663-platform-build-pipeline-link` (AOT): a post-link callback re-links the build's objects to a temp output —
|
||||
the relinked binary RUNS; negative-probe verified. The Zig driver still auto-links (removed in P5.4). 704/0.
|
||||
- **P5.3 — `on_build` slot:** a comptime-assignable compiler slot (GENERALIZES today's `post_link_callback_fn`:
|
||||
an assignable typed global with a stdlib default, vs a setter). `#run on_build = build;` captures the
|
||||
`FuncId`; the compiler invokes it post-codegen with the CLI-derived `BuildConfig`.
|
||||
|
||||
Reference in New Issue
Block a user