Repository navigation
Merged
Conversation
added 14 commits
October 20, 2026 12:14
…me seams by role; the runtime is internal to the standard library A standard-library module that imports the runtime (step 3 replaces its `extern fn with_*` declarations with `use rt.<module>`) cannot spell the host's file — with_net_* live in darwin_aarch64.w here and linux_x86_64.w there, with_fiber_* in fiber_core_darwin.w or fiber_core_windows.w — so `rt/platform.w` and `rt/fiber_core.w` resolve to the active target's modules. EmbeddedRuntime owns that mapping (embedded_rt_platform_file, embedded_rt_fiber_core_file); the in-unit parse reads the same two functions instead of its own copy. `use rt.*` from anything but the standard library or the runtime's own tree is refused — "a program reaches it through std" — in the §18.3 internal-import pass (plan §9 open question 3, answered as predicted: `with_*` was never user-facing). Resolve owns the runtime-path judgment (resolve_path_is_runtime); Sema's sema_path_is_runtime_implementation reads it. The runtime bundle's own interface root lives in the runtime's tree, so its `.wi` check still imports its sections. Fixtures: err_d30_user_use_rt (refused), embedded_rt_role_alias_test (the aliases resolve to the host's modules).
…time module with no interface is refused A `:dev` stage1 builds the runtime bundle itself, so its own slot is empty and every lane compile parsed the runtime's bodies into the program (#2485: a c_import program crashed at run under it, and a --prelude=core program had no fiber core to link). A compiler whose slot is empty now registers `<runtime root>/rt.wi` (the manifest's interface-sha checked) and its lane links `<runtime root>/rt.o`, the bundle the build left beside the objects it links — the root is this generation's by link_stage_resolve_runtime_root. On stage1 the lane's behavior fixtures pass as they do on the release. Outside the lane a runtime module reaches a unit only as its interface: without one (a cross target with no rt bundle, a stage1 before `:dev`) `use rt.<module>` is refused by name, since the bodies would join a program that links the runtime objects — every symbol twice, which is how the duplicate-symbol flood read before.
…tep 3)
cross_rt_bundle_targets: the release compiler compiles the tag's runtime
module set (its platform module, its fiber core — fiber_core_darwin for
every POSIX target — and the shared modules) under the lane for the
tag's triple into <cross dir>/rt.{o,wi,manifest}, linked against the
tag's corpus bundles, and the cross embedding carries it in the `rt`
slot that was empty (linux_x86_64, linux_aarch64, windows_x86_64,
windows_aarch64). build/rt_bundle.w takes `target=<triple>` for both the
object compile and the interface check. A standard-library module's `use
rt.*` then resolves to an interface on every cross target the object
world builds for, never to the runtime's bodies.
linux_x86_64 built here: an ELF object exporting the flat with_* names,
an interface of the seven modules, source and twin fingerprints equal.
…mbol's interface declaration is never displaced; comptime judges it as the extern it is Three facts the standard library's `use rt.*` brought out: - The runtime's modules each declare rt_libc_exit (and mmap, munmap, raise, write); once std imports them they sit in the prelude tier, whose same-named externs yield to a higher tier's, so the interface twin kept one declaration where the source pass kept four and the fingerprints disagreed by tier placement. An extern's contract is its symbol's: one row per name, no module column, every duplicate held to the same row (one symbol, one contract, #761); the interface text still carries each module's own declaration. - A runtime ABI symbol's interface declaration beside an `extern fn with_*` of the same name (the compiler's own modules keep theirs until step 4) is the same symbol twice, not a #1362 collision: it is not displaced to `name$in$<module>`, and the tier verdict drops it where a higher tier declares the symbol — with_sysinfo_os kept its name and the comptime target read. - To compile time a runtime ABI function reached through the interface is the extern it always was: D104's wording, not D39's.
…n fn with_*` declarations go (D30 step 3) Every lib/std module that declared the runtime's functions now imports them — `use rt.rt_core`, and by role `use rt.platform` (std.net), `use rt.fiber_core` (std.task, std.sync, std.time), `use rt.fiber_runtime`, `use rt.channel_runtime` (std.channel), `use rt.compat_runtime` (std.process, std.os, std.build), `use rt.panic_runtime` (std.testing, builtins). The three `@[effect]` pins went with the externs they sat on: the definitions carry them (step 2). 36 files, 230 lines fewer; the sweep (a With script over the interface's sections) reported no name without a definition.
…es.md, plan §10, AGENTS.md/CLAUDE.md)
…efused at the parse; the root's bundle is found by its manifest's generation - The no-interface refusal moves from the §18.3 use-walk to the two places an imported module is parsed (merge_resolved_modules_frontend, parse_imported_file_frontend): a `--no-prelude --bundle-corpus` build reaches the standard library's `use rt.*` without walking its use decls, and compiled the runtime's bodies into the pcre2 object (38 of rt_core's symbols, one of them referencing a private helper the link then could not find). Said once per module. - rt.manifest carries `generation <compiler generation>`, and link_stage_runtime_root_bundle_dir finds this generation's bundle for this target by that line across the root candidates: the bundle precedes the root's objects (they compile against its interface), so the root's .producer cannot vouch for it. - A carried declaration (the runtime's interface in a corpus bundle build) keeps external linkage: an internal declaration without a body is invalid LLVM, and its definition is the runtime's object. - The emitter prints a displaced fn (`str_data$in$…`, two runtime modules each define str_data) by its own name: the identity is the merge's, the interface is the module's.
…s stage; the stage's runtime objects and corpus bundles follow it With the standard library importing the runtime, stage1's runtime objects and corpus bundles need the runtime's interface before they can compile: the bundle — the one unit that reads the runtime's source — moves ahead of them (stage1-rt-core-object & co. and the stage1 corpus builds depend on stage1-rt-bundle). The bundle compiles with --no-prelude and no --link-bundle: the runtime does not use the prelude, and with it the prelude's std.regex pulled pcre2 in (from source on stage1, from the bundle on stage2, the objects differing in `l_str.N` numbering alone); without it the bundle depends on nothing but the compiler, 1.4 s instead of 3.6 s. The cross bundles likewise.
…t newlines after it A facade fn or resource item took its end from prev_end() after parse_facade_clauses, which skips the newlines following the last clause; a newline token that follows a comment ends past the comment, so the item's span covered it. SemaFacade.facade_item_words compares two blocks' items by their source words to accept a word-for-word restatement (§16.2b), and an item followed by a comment then differed from its twin by the comment's text: fiber_stubs.w and fiber_runtime.w both describe rt_libc_abort identically, and the wasm32 runtime bundle, which compiles them in one unit, was refused with "described by two facade blocks with different clauses". The item now ends at its last clause's end (its head's without one); facade_item_end owns the rule for both item kinds. behav_c_facade_fn_restated_comment.w fails before the fix and passes after (installed compiler vs out/bootstrap/bin/with-stage1).
…aring with_* externs (D30 step 3) The preamble of a migrated corpus declared the 19 runtime functions the generated code reaches (with_alloc, with_memcpy, with_clz, …) as extern fns. Under D30 step 3 the standard library reaches the runtime through its interface (`use rt.<module>`), and a corpus is standard-library code: the preamble now carries `use rt.rt_core` in the defs header beside std.option's import (ci_migrate_insert_rt_use) and declares no runtime extern. The compiler accepts the promoted corpora as they are (an extern that agrees with the interface declaration is one contract); they re-promote under D112's third reason when the migrator generation moves.
…s it imports, never by the compiler that built it; the wasm32 runtime bundle Ruling (Eric, 2026-10-20): a bundle is rebuilt when its pinned source or the .wo contract changes, never because the compiler did; the build system is shaped for fifty thousand of them. The store's slot key had hashed all of src/ since ab30b32, so every commit recompiled every bundle for every target (43 generations of one unchanged zlib object in the store). The contract. A corpus bundle's manifest records every symbol its object references and does not define — `import\t<symbol>\t<rt|foreign>\t<contract>` — and the runtime bundle's records every runtime symbol it defines — `provides\t<symbol>\t<contract>`. The contract is the declaration's parameter types and DECLARED effects (the pin, else the type's), variadicity and return type (BundleInterfaceEmit.bundle_symbol_contract): a definition's body-inferred READ and its extern twin's nothing are one contract. The manifest also lists the non-corpus modules the object carries copies of (`carried <module>`, from Codegen.bundle_carried_paths). Who checks. The compiler: --emit-bundle-manifest reads the object's undefined symbols (the in-process readers; an nm fallback's `U name` line is taken by its last field), refuses a module-link-named one (the carried-copy class behind the superseded key), records a declared symbol the runtime provides as `rt` after checking the corpus declared it under the runtime's contract (#761), and the rest as `foreign` (libc, compiler-rt, LLVM's own libcalls such as bzero, the wasm linker's tables). Every link — an embedded bundle, --link-bundle — refuses a bundle whose `rt` imports this compiler's runtime no longer provides as declared (Link.link_stage_bundle_import_drift, naming the symbol and both contracts); the runtime bundle itself stays generation-keyed (D132). A bundle or a runtime from before the rows is judged by generation as before. build/wo.w applies the same rule before reusing a slot (corpus-sha, carried-sha, target, abi-sha, import rows against the target's rt.manifest, which wo_bundle_targets now takes), so a compiler never embeds a bundle it would refuse; compiler-src-sha is gone. Verified: after a src/ edit and a stage1 rebuild (a new generation), the zlib host and wasm32 slots are reused ("compiled nothing"); the eight corpus bundles build with import rows (zlib: 20 rt, 14 foreign, 6 carried std modules); the bundle-interface suite gains the drift case (a rewritten import contract is refused at --link-bundle with the fix named). The wasm32 runtime bundle. The wasm32 corpus bundles need a wasm32 runtime manifest to record their contracts against: stage1 builds out/bootstrap/lib/cross/wasm32/rt.* and stage2 out/lib/cross/wasm32/rt.* (`stage1-rt-bundle-wasm32`, `rt-bundle-wasm32`, root rt_bundle_wasm32.w), the next stage embeds it as the `rt@wasm32` slot (empty in the bootstrap and cross embeddings), and rt-bundle-wasm32-fixpoint joins :fixpoint. The wasm32 module set is the object world's — rt_core, wasm, panic_runtime, fiber_stubs, compat_runtime — owned by EmbeddedRuntime.embedded_rt_unit_files (the in-unit parse reads it too): fiber_runtime and channel_runtime have no core on WebAssembly, so `use rt.fiber_runtime` / `use rt.channel_runtime` resolve to fiber_stubs there, which gains the four names std.task, std.sync and std.channel reach (with_fiber_is_cancelled; the channel retain/release trio stops the program loudly, as the coroutine stubs do). A wasm link joins no fiber_asm.o. The runtime root bundle lookup probes <root>/cross/<target> for a cross target. Docs: docs/meetings/2026-10-20-D138-a-wo-bundle-is-durable.md (the ruling, Eric's words), wo_bundles.md "Key", "Durability", "Imports".
…30 step 3 migrator (D112 reason 3) The migrator generation moved (9e03980): the shared defs import the runtime interface (`use rt.rt_core`) and declare no with_* extern. Each corpus is what the migrator writes again: 19 runtime externs gone from every defs.w (the c_algorithms test programs too), one import added, corpus.stamp re-recorded. No other module changed.
…ded as `rt@<tag>`; the gate's findings every-target-check failed for the four cross targets: a `--target <tag>` check of a unit compiled against the runtime interface needs that target's rt.wi, and the release embedded only the host's (and wasm32's). The wasm32 shape generalizes: stage1 builds out/bootstrap/lib/cross/<tag>/rt.* and stage2 out/lib/cross/<tag>/rt.* for every tag (stage_rt_bundle_tags), the next stage embeds each as its `rt@<tag>` slot, each pair joins :fixpoint, and the bootstrap and cross embeddings carry the slots empty. The release-built cross runtime bundle (cross_rt_bundle_targets) is gone: a cross compiler embeds stage2's bundle of its target, the same bytes, and the cross corpus bundles take their contracts from it. A stage's wasm32 runtime objects depend on that stage's wasm32 runtime bundle (they compile with the prelude, whose std imports rt.*). unit-return-review: the stand-in stubs and the with_ewrite extern spell no Unit. ceremony-census: the new build lines no longer `move` a Build or Target into a consuming parameter, the new calls no longer write `&` at a `&T` parameter; `let-underscore rt` and `lit-ptr-len rt` are granted — D30 step 3 puts the runtime modules into the unit `with check src/main.w --ceremony-census` reports, so their existing sites land under rt/, an area the published bar predates (the bar records them at the next reseed).
…ion is a prototype, never a definition
The battery's emit-C targets (emit-c-smoke, the edge selfhost case, behav_2073, validate-all-async, the native compile-error lane) went red: std now imports `rt.*` (D30 step 3), and the emit-C lane registered no embedded interface at all, so every runtime module was refused ("has no interface in this compiler"). The lane now registers the runtime's interface and still no corpus bundle (--emit-c links none, so a corpus interface would leave its modules declared-only).
With the runtime known through interface-body declarations rather than externs, the C backend then (a) counted them as the unit DEFINING with_alloc, with_free, with_memcpy… (module_exports_c_name) and skipped their fixed prototypes, and (b) walked only NK_EXTERN_FN for prototypes. An interface-body declaration defines nothing: it is excluded from module_exports_c_name and included in the prototype walk under the same filters an extern gets. Verified: the prelude_runtime smoke case's C compiles; emit-c-smoke, cli-selfhost-edge-tests, validate-all-async and native-compile-error-tests green.
Contributor
Author
|
Battery GREEN on b44998d (329 s, this Mac, seed nightly-20261020-local-2): gate, uat (12 pass, 1 skip), battery-checks. Lane sweeps (WITH_RT_IN_UNIT=1, release binary): plain behavior 1703/1703, compile_errors 1791/1791, spec+internals 284/284. Slot reuse proven: after a src/ edit and a stage1 rebuild, zlib host and wasm32 slots copied ("compiled nothing"). |
ehartford
marked this pull request as ready for review
October 20, 2026 22:04
ehartford
pushed a commit
that referenced
this pull request
Oct 21, 2026
…function, not at a with_clz extern `:release-checks` on main after #2498 was red in c-migrator-core-tests: builtin_overflow delimited the shim's 128-bit helper region by the `extern fn with_clz` that followed it, and the shim imports the runtime now (D30 step 3) instead of declaring it. The region runs from the i128 helper to the first migrated function of the program (the shim's own helpers are `__with_`- or `u128_`-named). c-migrator-core-tests green (295 s).
ehartford
added a commit
that referenced
this pull request
Oct 21, 2026
…function, not at a with_clz extern (#2502) `:release-checks` on main after #2498 was red in c-migrator-core-tests: builtin_overflow delimited the shim's 128-bit helper region by the `extern fn with_clz` that followed it, and the shim imports the runtime now (D30 step 3) instead of declaring it. The region runs from the i128 helper to the first migrated function of the program (the shim's own helpers are `__with_`- or `u128_`-named). c-migrator-core-tests green (295 s). Co-authored-by: Eric Hartford <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
D30 step 3: std imports the runtime interface; D138: a .wo bundle is durable; the wasm32 and cross runtime bundles
D30 step 3 (plan §10): the standard library reaches the runtime through its interface (
use rt.<module>, 36 files, 227 externs gone); a useruse rt.*is refused; the migrator preamble importsrt.rt_coreand the four corpora are re-promoted (D112 reason 3); a:devstage1 links the runtime root's bundle (#2485).D138 (ruled by Eric, 2026-10-20): a .wo is durable. Never rebuilt because the compiler changed: the slot key is corpus|target|abi; a slot is reused while its corpus, its carried std modules (
carried-sha), the ABI and the contracts of the runtime symbols it imports (import/providesrows,BundleInterfaceEmit.bundle_symbol_contract) are unchanged. The compiler owns the rule at every link (Link.link_stage_bundle_import_drift); build/wo.w applies it before reusing a slot. Verified: a src/ edit plus a stage1 rebuild reuses every slot ("compiled nothing"). Supersedes thecompiler-src-shakey (ab30b32). Decision record: docs/meetings/2026-10-20-D138-a-wo-bundle-is-durable.md.Runtime bundles for every target: each stage builds
rt.*for wasm32 and the four cross tags (rt@<tag>slots, fixpoint pairs); on WebAssembly fiber_stubs stands in for the fiber and channel runtimes.Also: a c facade item's span no longer swallows the comment after it (two blocks restating one contract were refused); ceremony grants for the rt area (the published bar predates the runtime joining the checked unit) — see the last commit.
Gate: green (
src/main build :gate, 241 s). Lane sweeps and the battery: posted below.