Consolidate generated modules in wit-component into one - #2600
Merged
alexcrichton merged 5 commits intoAug 13, 2026
Conversation
alexcrichton
force-pushed
the
consolidate-modules
branch
2 times, most recently
from
August 12, 2026 23:35
20b09f7 to
827fbb2
Compare
This commit moves some logic of generating a "fixup" module into a separate file and starts to lay the foundation for merging various small bits and pieces of modules into just one fixup module instead of multiple. The goal of this work is to enable a future addition where the task intrinsics are becoming more invasive and need to handle more cases, and it seemed prudent to take this opportunity to go ahead and optimize the various modules that wit-component generates.
No need for this to be separate any more.
This commit merges the `__init` module previously generated by `wasm-tools component link` into the "fixup" module that's growing to encompass all other smaller modules that are generated. This is done with refactoring in a few places and additionally helps generate debug names for items and deduplicate type information.
This adjust the location of task hook creation to primarily happen in the main fixup module now. This avoids another "extra" module of sorts and helps to minimize the number of core modules in components created for wasip3. This additionally handles one more case than was previously handled with this new refactoring -- resource destructors. Destructors for resources happen on new tasks and need hooks around them and the version that's filled in to the shim module now properly has hooks in place.
alexcrichton
force-pushed
the
consolidate-modules
branch
from
August 13, 2026 02:46
827fbb2 to
12210bd
Compare
Member
Author
|
I'm going to switch this over to @dicej since I'd like to get your eyes in particular on the dynamic library changes here |
dicej
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.
To fully address some upcoming refactorings for wasip3 intrinsics this commit refactors the output of
wit-componentto ensure that all the little helper modules generated are glommed into one instead of lots of separate ones. The main purpose of this is to address the use case now addressed here where task intrinsics need to hook resource destructors which previously wasn't handled, nor was it easily possible.This is mostly a lot of refactoring and attempting to move some complexity of
encoding.rsto a separate file. The end result is that these modules are now all folded into one module:startfunction for the_initializehook is now folded into the fixup module.__initmodule used bywasm-tools component linkis now located in the main fixup module.This is all intended to be refactoring such that the next commit, adding more task lifetime hooks to get added, will be much easier to do.