P5.5: migrate the 35 BuildOptions accessors off #compiler to VM-native abi(.compiler)
`BuildOptions :: struct #compiler { ...35 methods... }` becomes
`BuildOptions :: struct { }` (an opaque null-sentinel handle) plus 35 free
`ufcs (self: BuildOptions, …) abi(.compiler)` decls in build.sx, each serviced
by a new `comptime_vm.callBuildOptionFn` arm (off `callCompilerFn`). No legacy
`compiler_lib` handler: the names are registered in `bound_fns` with a single
bailing stub only so `weldedCompilerFn` accepts them.
- String lifetime: setters dupe the arg into the persistent `Vm.gpa` (the
Compilation allocator, threaded into both `tryEval` and `runBuildCallback` —
not the per-eval VM arena) and write/append to the threaded `BuildConfig`.
Getters read the field/slice or compute the target predicate from the triple.
- Dispatch routing (Option B): a `#run`/const-init entry that directly calls a
compiler-domain/welded fn (`emit_llvm.entryNeedsVm`) runs on the VM with no
legacy fallback regardless of the `-Dcomptime-flat` gate, so gate-OFF stays
green without a legacy BuildOptions handler (P5.7 retires the legacy interp).
- Mark the 5 `platform/bundle.sx` getter-calling helpers `abi(.compiler)` (they
are comptime-only bundler code; otherwise their now-welded getter calls trip
the runtime-call gate).
- 37 `.ir` snapshots regenerated (std transitively imports build.sx → string-
pool/type-table indices shift); verified `.ir`-only, zero behavior-stream diffs.
BuildOptions `compiler_call` strict bails gone (1609/1614/1615 strict-clean);
1616 now bails on a separate, pre-existing unported bitwise/shift VM gap (`shr`),
to port first in P5.6. 703/0 both gates.
Also sweep the outdated "flat memory" terminology to "comptime/byte-addressable"
across comptime_vm + the plan/checkpoint/CLAUDE docs: the comptime VM is
arena-backed, byte-addressable memory where `Addr` is a real host pointer, not a
flat contiguous address space (flag names `-Dcomptime-flat`/`SX_COMPTIME_FLAT` kept).
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
//! **Direction note (2026-06-17 pivot).** The byte-weld of TYPES (sx structs whose
|
||||
//! layout was validated to mirror the compiler's Zig records) was stripped — it
|
||||
//! bolted a parallel layout regime + hand-marshaling onto a comptime value model
|
||||
//! that isn't bytes. The replacement is a flat-memory comptime VM where values are
|
||||
//! that isn't bytes. The replacement is a comptime VM where values are
|
||||
//! native bytes, so the compiler-API needs no weld/validation/marshaling (Phase 3
|
||||
//! of the plan re-homes the type/function exposure on that VM). `intern`/`text_of`
|
||||
//! survive here as the first compiler-call seed: clean scalar host-calls (string in,
|
||||
@@ -42,7 +42,7 @@ pub const BoundFn = struct {
|
||||
};
|
||||
|
||||
/// The compiler-function export list. The `StringId` round-trip readers are the
|
||||
/// seed; the type-table API (lookup / register) is re-homed onto the flat-memory
|
||||
/// seed; the type-table API (lookup / register) is re-homed onto the comptime
|
||||
/// VM in Phase 3 of `PLAN-COMPILER-VM.md`.
|
||||
pub const bound_fns = [_]BoundFn{
|
||||
.{ .sx_name = "intern", .handler = handleIntern },
|
||||
@@ -75,8 +75,58 @@ pub const bound_fns = [_]BoundFn{
|
||||
.{ .sx_name = "build_target", .handler = handleBuildPipelineQuery },
|
||||
.{ .sx_name = "build_frameworks", .handler = handleBuildPipelineQuery },
|
||||
.{ .sx_name = "build_flags", .handler = handleBuildPipelineQuery },
|
||||
// ── BuildOptions accessors (Phase 5.5) ───────────────────────────────────
|
||||
// Migrated off the `struct #compiler` hook surface to free `abi(.compiler)`
|
||||
// functions serviced by `comptime_vm.callCompilerFn`. VM-only: any `#run` /
|
||||
// const-init reaching them is routed to the VM (emit_llvm `entryNeedsVm`), so
|
||||
// these legacy stubs are never reached — registered only so `weldedCompilerFn`
|
||||
// recognizes the names. They bail loudly rather than fabricate a silent result.
|
||||
.{ .sx_name = "add_link_flag", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "add_framework", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_output_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_wasm_shell", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "add_asset_dir", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "asset_dir_count", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "asset_dir_src_at", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "asset_dir_dest_at", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_post_link_module", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "binary_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_bundle_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_bundle_id", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_codesign_identity", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_provisioning_profile", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "bundle_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "bundle_id", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "codesign_identity", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "provisioning_profile", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "target_triple", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "is_macos", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "is_ios", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "is_ios_device", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "is_ios_simulator", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "is_android", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "framework_count", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "framework_at", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "framework_path_count", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "framework_path_at", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_manifest_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "set_keystore_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "manifest_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "keystore_path", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "jni_main_count", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "jni_main_runtime_path_at", .handler = handleBuildOptionsAccessor },
|
||||
.{ .sx_name = "jni_main_java_source_at", .handler = handleBuildOptionsAccessor },
|
||||
};
|
||||
|
||||
/// Legacy-path stub for the Phase 5.5 BuildOptions accessors — see the `bound_fns`
|
||||
/// comment. Any `#run` / const-init reaching a BuildOptions accessor is routed to
|
||||
/// the VM (`emit_llvm.entryNeedsVm`), so this is never reached; it bails loudly
|
||||
/// rather than fabricate a silent result.
|
||||
fn handleBuildOptionsAccessor(_: *Interpreter, _: []const Value) InterpError!Value {
|
||||
Interpreter.last_bail_detail = "BuildOptions accessor is VM-only (Phase 5.5); not available on the legacy interpreter";
|
||||
return error.CannotEvalComptime;
|
||||
}
|
||||
|
||||
/// Legacy-path stub for the Phase 5 build-pipeline primitives — see the
|
||||
/// `bound_fns` comment. The only caller (the post-link build driver) runs on the
|
||||
/// VM (`core.invokeByFuncId`), so these legacy handlers are never reached; they
|
||||
@@ -132,7 +182,7 @@ fn handleTextOf(interp: *Interpreter, args: []const Value) InterpError!Value {
|
||||
/// union / tagged-union / error-set) by its interned name and return its handle.
|
||||
/// A name with no matching type yields the dedicated `unresolved` sentinel (a
|
||||
/// `TypeId` of 0), the codebase-blessed "no type" marker — NOT an `?Type` (a
|
||||
/// `Type` value is `.any`-typed, which the flat-memory VM does not represent, and
|
||||
/// `Type` value is `.any`-typed, which the comptime VM does not represent, and
|
||||
/// an optional can't cross the legacy↔VM eval boundary). The caller checks the
|
||||
/// handle against 0 / `unresolved`. The VM mirrors this in `comptime_vm.callCompilerFn`.
|
||||
fn handleFindType(interp: *Interpreter, args: []const Value) InterpError!Value {
|
||||
|
||||
Reference in New Issue
Block a user