rename std/build.sx -> modules/compiler.sx (the compiler-API surface)
Per user direction: the low-level abi(.compiler) primitive surface is the comptime 'compiler' library, so name the file compiler.sx (a peer of build.sx) instead of the interim std/build.sx — which also frees the 'build' name for the default build IMPLEMENTATION (default_build + on_build slot), which will live in modules/build.sx alongside the BuildOptions DSL. Updated the two example imports + the plan's Phase 5 file-split note. 704/0 both gates.
This commit is contained in:
@@ -471,27 +471,32 @@ a few `abi(.compiler)` PRIMITIVES that take **explicit args** (so nothing is sha
|
||||
keeps the proven Zig linker as a primitive; sx owns config + orchestration + bundle. (Option A — sx shells
|
||||
`cc`/`ld` itself — is a later refinement once the per-target link-line logic is ported to sx.)
|
||||
|
||||
Shape (all syntax verified on the current build 2026-06-18 — void `#run`, `-> !` / `-> !E` failable `#run`,
|
||||
a `raise` at `#run` fails the build with a return trace):
|
||||
**File split (user decision 2026-06-19):** the low-level compiler-API PRIMITIVES live in
|
||||
`library/modules/compiler.sx` (the comptime `compiler` library — renamed from the interim `std/build.sx`); the
|
||||
default `build` IMPLEMENTATION (`default_build` + the `on_build` slot + the sx `BuildConfig`) lives in
|
||||
`library/modules/build.sx` alongside the existing `BuildOptions` DSL. So `compiler.sx` = primitives, `build.sx` =
|
||||
orchestration/default impl. **Build-callback fallibility was DROPPED (user 2026-06-19):** the primitives + the
|
||||
build callback are NOT `-> !` — a failed action (e.g. `link`) BAILS on the VM (hard build error). So the shapes
|
||||
below shed their `-> !`.
|
||||
|
||||
Shape (build-callback fallibility dropped 2026-06-19):
|
||||
```sx
|
||||
// library/modules/std/build.sx (stdlib)
|
||||
BuildErr :: error { EmitFailed, LinkFailed, BundleFailed }
|
||||
BuildConfig :: struct { output: string; target: string; flags: List(string);
|
||||
frameworks: List(string); bundle_path: string; bundle_id: string;
|
||||
is_macos :: (self: *BuildConfig) -> bool { ... }
|
||||
add_framework :: (self: *BuildConfig, n: string) { self.frameworks.append(n); } }
|
||||
// compiler primitives — explicit args, failure on the error channel (NO bool):
|
||||
emit_object :: () -> !string abi(.compiler); // IR → .o path
|
||||
// library/modules/compiler.sx (the comptime `compiler` library — PRIMITIVES)
|
||||
emit_object :: () -> string abi(.compiler); // emitted .o path (query)
|
||||
link :: (objects: List(string), output: string, libraries: List(string),
|
||||
frameworks: List(string), flags: List(string), target: string) -> ! abi(.compiler);
|
||||
frameworks: List(string), flags: List(string), target: string) abi(.compiler); // void; bails on failure
|
||||
c_object_paths :: () -> List(string) abi(.compiler); // metadata queries
|
||||
link_libraries :: () -> List(string) abi(.compiler);
|
||||
default_build :: (config: BuildConfig) -> ! abi(.compiler) { // the default pipeline
|
||||
obj := try emit_object(); objs := c_object_paths(); objs.append(obj);
|
||||
try link(objs, config.output, link_libraries(), config.frameworks, config.flags, config.target);
|
||||
if config.bundle_path.len > 0 { try bundle_app(config); } } // bundle_app = today's sx bundler
|
||||
on_build : (BuildConfig) -> ! abi(.compiler) = default_build; // the override slot
|
||||
// user overrides: build :: (config: BuildConfig) -> ! abi(.compiler) { ... } #run on_build = build;
|
||||
|
||||
// library/modules/build.sx (the build DSL — DEFAULT IMPLEMENTATION + slot)
|
||||
BuildConfig :: struct { output: string; target: string; flags: List(string);
|
||||
frameworks: List(string); bundle_path: string; bundle_id: string; ... }
|
||||
default_build :: (config: BuildConfig) abi(.compiler) { // the default pipeline (void)
|
||||
obj := emit_object(); objs := c_object_paths(); objs.append(obj);
|
||||
link(objs, config.output, link_libraries(), config.frameworks, config.flags, config.target);
|
||||
if config.bundle_path.len > 0 { bundle_app(config); } } // bundle_app = today's sx bundler
|
||||
on_build : (BuildConfig) abi(.compiler) = default_build; // the override slot
|
||||
// user overrides: build :: (config: BuildConfig) abi(.compiler) { ... } #run on_build = build;
|
||||
```
|
||||
The compiler's whole post-IR role: codegen → build the CLI-derived `BuildConfig` → read `on_build` → invoke
|
||||
`on_build(config)` on the VM; a `raise` fails the build. Plain `sx run` fires none of it.
|
||||
@@ -505,7 +510,7 @@ The compiler's whole post-IR role: codegen → build the CLI-derived `BuildConfi
|
||||
bails on legacy with `struct_get`), so the build succeeds (exit 0) only via the VM. Non-empty callback `args`
|
||||
rejected loudly (the `on_build(config)` arg-marshaling entry is P5.3). **702/0 both gates.**
|
||||
- **P5.2 — primitives.** Split: the read-only **metadata queries are DONE (2026-06-19)** — `c_object_paths() ->
|
||||
List(string)` + `link_libraries() -> List(string)` as `abi(.compiler)` fns (stdlib `library/modules/std/build.sx`),
|
||||
List(string)` + `link_libraries() -> List(string)` as `abi(.compiler)` fns (stdlib `library/modules/compiler.sx`),
|
||||
serviced by `comptime_vm.callCompilerFn` over `BuildConfig` fields `main.zig` forwards; new VM `makeStringList`
|
||||
builds the `List(string)` in flat memory from the call's result type (`ins.ty` now threaded through
|
||||
`invoke`/`callCompilerFn`). Smoke test `1662-platform-build-pipeline-queries` (AOT + C companion). 703/0 both
|
||||
|
||||
Reference in New Issue
Block a user