Skip to content

D30 R3 step 1: the runtime as an embedded bundle, built at compiler build time, byte-identical across stages - #2486

Merged
ehartford merged 5 commits into
mainfrom
d30-rt-unit
Oct 20, 2026
Merged

ehartford merged 5 commits into
mainfrom
d30-rt-unit

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

D30 R3, step 1 of the order in docs/proposals/d30-implementation-plan.md §10 (rulings 2026-10-20). Still behind WITH_RT_IN_UNIT.

  • Compiler: --bundle-corpus rt names the embedded runtime tree; use rt.<module> resolves there; a module's own foreign seam (extern var, c facade) is omitted from an interface, not refused; comptime keeps answering with_sysinfo_os/arch from the build's target (D91) when the interface declares them bodiless; an embedded bundle named rt joins the link only under the lane and only when the embedded runtime is this compiler's generation (D132, D30 implementation: retire the internal runtime ABI — runtime compiles in-unit; rt objects only a keyed cache; boundaries speak C #761), and fiber_asm.o joins with it.
  • Build: build/rt_bundle.w — rt-bundle-root generates the root, stage1-rt-bundle / rt-bundle compile it as its own full unit under the lane into out/bootstrap/lib / out/lib, check the emitted interface against the source fingerprint, and the stage compilers embed the blobs; rt-bundle-fixpoint (in :fixpoint) proves stage1's bundle is byte for byte stage2's.
  • Measured: hello world under the lane with the release 0.20 s vs 0.19 s in the object world (was 1.52 s compiling the runtime in-unit per program).
  • Two things the bytes taught (commit 49014e3): one generated root under the D50 prefix map, and the stage compiles' --link-bundle pairs forwarded to the bundle builds (stage1's empty .wo slots otherwise compile pcre2 into the unit and renumber every l_str.N).
  • Filed dev-tier stage1 under WITH_RT_IN_UNIT=1: a c_import program compiles and segfaults at run (release passes) #2485: dev-tier stage1 under the lane crashes a c_import program (also on main's stage1).

Evidence (seed-driven, worktree ~/.local/with-staging/d30-rt-unit at 918457f): src/main build :gate green; lane sweeps on the release WITH_RT_IN_UNIT=1: plain behavior 1702/1702, compile_errors 1790/1790, spec+internals 283/283; with run tools/battery.w → GREEN (287 s). The docs commit on top is excluded from the green key (D49).

Eric Hartford added 5 commits October 20, 2026 02:13
…d runtime, the rt slot joins lane links

The runtime bundle is a `.wo` in shape and none of its store
(docs/proposals/d30-implementation-plan.md §10, ruling 2026-10-20):

- `--bundle-corpus rt` names the embedded runtime tree `<embedded-rt>/rt`
  (`bundle_corpus_base`), and `use rt.<module>` resolves there in Resolve
  and the Frontend, as `use std.x` resolves to the embedded stdlib; the
  bundle root is one `use` per runtime module.
- A module's own foreign seam — `extern var` and `c facade` — is the
  object's, not interface material: the emitter omits it instead of
  refusing the module.
- The interface declares with_sysinfo_os/arch bodiless; comptime keeps
  answering them from the build's target (D91), as it did the extern.
- Link: an embedded bundle named `rt` joins the link only under the lane
  and only when the embedded runtime is this compiler's generation (D132,
  #761); its symbols are the flat with_*/rt_* names, so the module-prefix
  predicate does not apply.

test/internals/bundle_corpus_rt_test.w fails on main (the corpus is not
known) and passes here.
…unit; rt-bundle-fixpoint proves stage1 == stage2 byte for byte

build/rt_bundle.w: `rt-bundle-root` writes out/gen/rt_bundle.w (one `use
rt.<module>` per module of this host's runtime), and the two bundle
targets compile it under WITH_RT_IN_UNIT=1 with --emit-obj
--bundle-corpus rt into out/bootstrap/lib (stage1) and out/lib (stage2),
check the emitted interface against the source fingerprint, and the
stage compilers embed the blobs (`wo_rt_{o,wi,manifest}`, slot `rt`).
`rt-bundle-fixpoint` (in :fixpoint) compares the two bundles' sha256.

Two things made the bytes differ before they agreed: the root's path
enters the debug info, so there is one generated root and the compile
runs under WITH_FILE_PREFIX_MAP (D50); and stage1's .wo slots are empty,
so without the stage compiles' --link-bundle pairs the prelude's
std.regex compiled pcre2 into the unit — its functions were pruned, the
string-literal counter was not, and the objects differed in nothing but
`l_str.N` (and the build took 15.9 s instead of 3.6 s).

Hello world under the lane with the release: 0.20 s (0.19 s in the object
world); it was 1.52 s compiling the runtime in-unit per program.
The bundle is the whole runtime, fiber core included, and its own call
to the assembly with_fiber_switch is not among the program's undefined
symbols: a --prelude=core program (test/behavior/prelude_core_mode.w)
linked the bundle and the link refused with_fiber_switch as undefined.
behav_d30_rt_in_unit_prelude_core.w fails on the previous commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant