Skip to content

The compiler's modules are a bundle: a test that imports one links it (internals-tests 260 s -> 16 s) (#3351) - #3393

Merged
ehartford merged 14 commits into
mainfrom
compiler-bundle
Nov 17, 2026
Merged

ehartford merged 14 commits into
mainfrom
compiler-bundle

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Eric said go on #3351 (2026-11-16): the compiler's own modules become a bundle, so a test that imports one stops checking, lowering and generating the whole compiler.

Measured (darwin-aarch64, release compiler)

before after
comptime_value_share_test.w (31 lines, use ComptimeValue): Sema 33.8 s 1.1 s
same: MIR lowering 2.6 s 0.06 s
internals-tests (123 files) 260 s 16 s
internals-compiler-tests (3 files) one at a time, after every other lane 10 s
compiler-bundle (new, once per tree) – about 80 s alone

All 126 files of the two lanes pass against the bundle.

What it is

A tree bundle: --bundle-corpus tree:<dir>[,<dir>], the modules of one checkout's directories compiled once for that checkout's tests. build/compiler_bundle.w builds the compiler's (src/, out/gen/) into out/compiler-bundle/compiler.{o,wi,manifest}; the two internals lanes run with test --link-bundle out/compiler-bundle/compiler. It is a build artifact, never stored, embedded, published or chosen on demand, and read only by the compiler that wrote it. wo_bundles.md has the section ("Tree bundles").

What a tree bundle carries that a stored .wo does not:

  • an initializer for globals whose initializer does not fold (HashMap.new()): the object defines <prefix>bundle_init, the manifest names it, the linking program's main wrapper calls it before its own initializers;
  • every function, type and constant of its modules, pub or not (its importers are tests of the same package, D100);
  • declarations as written: parameter and field defaults, @[callconv], mut parameters, ephemeral types, types with Drop, every import of a module;
  • private copies of the globals of the std modules it carries (it already carried their functions);
  • references to modules an embedded bundle provides (the link selects that bundle on demand).

The interface is checked like every bundle's: the .wi pass must reproduce the source pass's fingerprint or the target fails. That check found two real defects on the way, both fixed here: mut parameters were printed without their mode (a calling-convention difference), and an interface function that a second interface module also declares was dropped rather than module-qualified when an interface is read whole.

For Eric

  1. One limit of the write contract. A tree bundle's interface states a function's writes of the tree's own exported globals. It does not carry writes of another bundle's exported global reached through that bundle's functions: the compiler's regex use writes one pcre2 default-context global, transitively from 761 functions. A test can observe that only by importing the pcre2 engine raw and holding a view of that global across a call into the compiler.
  2. Carried state is separate. The bundle's copy of a std module's state (for example std.tls's trace memo) is not the importing test's copy.
  3. Deleted: src/Parse.w and src/tools/generate_embedded_stdlib.w. Nothing imports either, and neither compiles any more (the build has its own generator).
  4. Source edits the bundle needed: nine pub var globals in CImport/CiMigrate are plain var (a pub global's writes are a declared contract; nothing outside the package reads them); extend Codegen in Codegen.w is impl Codegen; the legacy fn Span.len(self: &Self) functions of compiler.foundation.Span/Source are methods.
  5. Link names: a module's link names no longer carry Sema's $m$<hash> owner identity (the module prefix is the identity). No stored bundle has such a name (40 store objects scanned), so no .wo is re-keyed; FnAbi.w is untouched.

Evidence

  • Battery GREEN on 94e9f5c; :release-checks green (fixpoint, Sema invariance, corpora tests, wo-drift).
  • src/main build :internals-tests and :internals-compiler-tests under the pinned seed: 123 and 3 files ok.
  • Fingerprints equal for the compiler's bundle (source pass and .wi pass).
  • Ceremony census: nothing rose.

Not measured: the bundle build's memory on a small runner. Its peak here was 4.8 GB when it ran beside stage builds; the four test compiles it replaces each loaded the whole compiler. If the Windows nightly shows it, that is #3364's lane.

Part of #3351 (the issue's remaining item, user-program package bundles, is a separate design).

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