compiler.sx needs only `List` (string is a builtin), so import the std/list.sx part-file instead of std.sx. Its standalone transitive footprint drops from ~16k to ~50 lines of IR. Enabled by core.sx now self-declaring its libc, so list.sx → core.sx resolves without the std assembly. Regenerates 40 .ir snapshots: compiler.sx sits in the std import graph (std → cli → build → compiler), so narrowing its import shifts the registration order in every std program, renumbering LLVM symbol suffixes (@foo.N → @foo.N+1) and adding a redundant `declare void @out` (LLVM dedups it). Verified the diffs are purely that — no .exit/.stdout/.stderr changed, no instruction/type/constant changed — and the full suite is green (817/0).
41 lines
2.4 KiB
Plaintext
41 lines
2.4 KiB
Plaintext
// The comptime `compiler` library — the low-level compiler-API surface.
|
|
//
|
|
// These primitives run in the comptime evaluator (`abi(.compiler)`), serviced by
|
|
// `comptime_vm.callCompilerFn`. They are the building blocks of the sx-driven
|
|
// build pipeline (Phase 5); the default `build` implementation that orchestrates
|
|
// them lives in `modules/build.sx`. They are reached from the post-link build
|
|
// driver (a callback registered via `set_post_link_callback`), which always runs
|
|
// on the comptime VM (`core.invokeByFuncId`) — the VM, unlike the legacy
|
|
// interpreter, can allocate/grow the `List`s the driver builds (issue 0141).
|
|
//
|
|
// Only `List` is needed here (`string` is a builtin), so import just the List
|
|
// part-file, not the whole std barrel — keeps compiler.sx's transitive graph
|
|
// small (its standalone import drops from ~16k to ~50 lines of IR). Works
|
|
// because core.sx self-declares its `libc`, so list.sx → core.sx resolves
|
|
// standalone.
|
|
#import "modules/std/list.sx";
|
|
|
|
// The C companion object files for this build (`#import c { #source ... }`,
|
|
// compiled to `.o`) and the `#library` link names. The sx driver passes them to
|
|
// the linker. Answered from the compiler's accumulated build state.
|
|
c_object_paths :: () -> List(string) abi(.compiler);
|
|
link_libraries :: () -> List(string) abi(.compiler);
|
|
|
|
// Verify + emit the codegen'd module to its object file; returns the path. An
|
|
// ACTION — the compiler no longer auto-emits; the sx driver calls this.
|
|
emit_object :: () -> string abi(.compiler);
|
|
|
|
// Build-config metadata the sx driver passes to `link` (the merged CLI + `#run`
|
|
// build config the compiler accumulated for this build).
|
|
build_output :: () -> string abi(.compiler); // the output binary path
|
|
build_target :: () -> string abi(.compiler); // the target triple ("" = host)
|
|
build_frameworks :: () -> List(string) abi(.compiler); // `-framework` names
|
|
build_flags :: () -> List(string) abi(.compiler); // extra link flags
|
|
|
|
// Link `objects` into `output`, with the given libraries / frameworks / link
|
|
// flags / target triple. The one genuine ACTION primitive — the compiler keeps
|
|
// the proven linker (Option B); the sx driver orchestrates. Not fallible (the
|
|
// build callback isn't): a link failure fails the build directly.
|
|
link :: (objects: List(string), output: string, libraries: List(string),
|
|
frameworks: List(string), flags: List(string), target: string) abi(.compiler);
|