P5.4: migrate all callers to on_build; delete set_post_link_callback

on_build is now the sole post-build callback mechanism. Migrated the 9 callers
(0602/0603/1611/1614/1615/1616 + the platform bundle_main) from
opts.set_post_link_callback(cb) to on_build(cb), giving each callback the
(opt: BuildOptions) param. Deleted set_post_link_callback from build.sx,
compiler_lib (bound_fns + handleSetPostLinkCallback), and the VM arm.

Reworked the P5 smoke tests for the new semantics: an on_build override REPLACES
the build (must emit+link or delegate), unlike the old post-link callback which
ran after the auto-link. 1662 (queries) + 1664 (override+List-grow) now delegate
to default_pipeline for the real build; deleted 1661/1663 (the primitives are now
exercised by every AOT build). bundle_main invoked with pass_options=true.

Benign 37-.ir churn (build.sx shrank). 703/0 both gates.
This commit is contained in:
agra
2026-06-19 09:37:05 +03:00
parent d178454841
commit 65ac370683
60 changed files with 36334 additions and 36578 deletions

View File

@@ -93,20 +93,12 @@ BuildOptions :: struct #compiler {
build_options :: () -> BuildOptions abi(.compiler);
// Post-link callback. Registers a sx function the compiler will invoke after
// `target.link()` returns. Used by the sx-side bundler
// (`platform.bundle.bundle_main`) and by user programs that want custom
// post-build steps. Return `false` to fail the build. Migrated off `#compiler`
// onto the comptime compiler-API (`abi(.compiler)`); called as
// `opts.set_post_link_callback(cb)` via UFCS, from inside a `#run { … }` block.
set_post_link_callback :: ufcs (self: BuildOptions, cb: () -> bool) abi(.compiler);
// The build callback registrar (Phase 5). Registers the sx function that drives
// the build — the compiler invokes it after codegen with the `BuildOptions`
// handle. Generalizes `set_post_link_callback` (a free fn, and the callback
// receives `opt`); `#run on_build(build);` is the override form, where
// `build :: (opt: BuildOptions) -> bool abi(.compiler) { … }`. The stdlib default
// implementation lives below (the default `build` script).
// handle. `#run on_build(build);` (from inside a `#run` block) is the override
// form, where `build :: (opt: BuildOptions) -> bool abi(.compiler) { … }`; the
// last registration wins. With no override the compiler auto-invokes the stdlib
// `default_pipeline` (below). This is the sole post-build callback mechanism.
on_build :: (cb: (opt: BuildOptions) -> bool abi(.compiler)) abi(.compiler);
// ── The default build script ────────────────────────────────────────────────

View File

@@ -29,7 +29,7 @@
// `abi(.compiler)` so the backend doesn't lower it and its `build_options()`
// compiler-API call is permitted (it would otherwise be rejected as a
// comptime-only function called at runtime).
bundle_main :: () -> bool abi(.compiler) {
bundle_main :: (opt: BuildOptions) -> bool abi(.compiler) {
opts := build_options();
binary := opts.binary_path();
bundle := opts.bundle_path();