feat: pack compose — static composition into one self-contained .wasm#39
Merged
Conversation
…tained .wasm `packr compose <manifest.toml>` merges compiled packages (allocator + providers + consumers) into a single ZERO-IMPORT .wasm that runs on any stock runtime, with cross-package imports internalized to direct calls (validates under wasm-tools). Pipeline: binaryen `wasm-merge` fuses modules + wires cross-imports; a `walrus` pass unifies the several env.memory imports into one internal memory, bakes the allocator's __memory_base/__heap_base/__heap_end into constants, and exports the memory. Requires wasm-merge (binaryen), added to the dev shell. Rips two superseded composers this replaces: - compose::StaticComposer (bump-allocator merger, wrong model since 0.8.0) - runtime::CompositionBuilder (pre-PIC runtime composer, red since PIC migration) both superseded by PicCompositionBuilder (runtime) + pack compose (static). Packaging win, not perf: the ABI marshalling stays fossilized in the packages. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
packr compose <manifest.toml>— statically composes compiled packages (allocator + providers + consumers) into a single self-contained.wasmwith zero imports that runs on any stock runtime. Cross-package imports become direct internal calls;wasm-tools validateclean.Proven end-to-end:
adder.process(5) == 11callingdoubler.doubleinternally, on a bare wasmtime with no harness (tests/compose.rs).How
Pipeline (
src/compose/static_compose.rs):wasm-mergefuses the modules + internalizes cross-imports (math.double→ doubler,pack:alloc→ the merged-in allocator). Each package is named by the import module-name its consumers use.walruspass unifies the severalenv.memoryimports into one internal memory, bakes the allocator's__memory_base/__heap_base/__heap_endinto constants, and exports the memory.Requires
wasm-merge(binaryen) — added to the flake dev shell.Cleanup
Rips two superseded composers this replaces (net −2350 lines):
compose::StaticComposer— Apr-27 bump-allocator merger, wrong model since the 0.8.0 allocator decoupling.runtime::CompositionBuilder— pre-PIC runtime composer, red since the PIC migration.Both superseded by
PicCompositionBuilder(runtime, #38) +pack compose(static).ParsedModule(used byinspect) is kept.Note
Packaging win, not performance. The merge internalizes the call, but the packr ABI marshalling is fossilized into the compiled packages, so it stays. A by-reference shared-memory ABI would be the separate perf lever.
Test / CI
tests/compose.rs— full pipeline + bare-run assert (skips cleanly if binaryen absent).🤖 Generated with Claude Code