Support importing memory in the main module in wit-component - #2599
Merged
alexcrichton merged 1 commit intoAug 13, 2026
Merged
Conversation
alexcrichton
force-pushed
the
wit-component-imported-memory
branch
from
August 12, 2026 22:40
b45f1f0 to
b34be4c
Compare
This commit updates the `wit-component` componentization process to support inputs where memory is imported as opposed to requiring memory to be exported. When this is the case it avoids the need for many shims in the "shim module" generated by wit-component which means that lowered functions can be directly imported into the main module. This in turn can lead to possible speedups since less indirection is necessary when going out to the host. This support is on-by-default and activated by detecting when memory is imported into the module. Actually generating a module that imports memory requires custom compiler flags, such as `-Clink-arg=--import-memory` in Rust, and this behavior continues to be off-by-default. In the meantime though my intention here is that this can provide a low-overhead opportunity to manually generate components with fewer shims when doing performance analysis. Internal refactorings as part of this commit revealed a preexisting issue with tests related to the `link` command where a library expected to be able to import another library's WIT functions. This only worked in some situations however, such as when strings weren't present, so the tests were updated to have the right WIT available at all times.
alexcrichton
force-pushed
the
wit-component-imported-memory
branch
from
August 12, 2026 23:34
b34be4c to
78f0bc5
Compare
pchickey
approved these changes
Aug 13, 2026
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.
This commit updates the
wit-componentcomponentization process tosupport inputs where memory is imported as opposed to requiring memory
to be exported. When this is the case it avoids the need for many shims
in the "shim module" generated by wit-component which means that lowered
functions can be directly imported into the main module. This in turn
can lead to possible speedups since less indirection is necessary when
going out to the host.
This support is on-by-default and activated by detecting when memory is
imported into the module. Actually generating a module that imports
memory requires custom compiler flags, such as
-Clink-arg=--import-memoryin Rust, and this behavior continues to beoff-by-default. In the meantime though my intention here is that this
can provide a low-overhead opportunity to manually generate components
with fewer shims when doing performance analysis.
Internal refactorings as part of this commit revealed a preexisting
issue with tests related to the
linkcommand where a library expectedto be able to import another library's WIT functions. This only worked
in some situations however, such as when strings weren't present, so the
tests were updated to have the right WIT available at all times.