Migrate wasm-bindgen
to using walrus
#1237
Merged
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 moves
wasm-bindgen
the CLI tool from internally usingparity-wasm
for wasm parsing/serialization to instead usewalrus
.The
walrus
crate is something we've been working on recently with anaim to replace the usage of
parity-wasm
inwasm-bindgen
to make thecurrent CLI tool more maintainable as well as more future-proof.
The
walrus
crate provides a much nicer AST to work with as well as astructured
Module
, whereasparity-wasm
provides a very raw interfaceto the wasm module which isn't really appropriate for our use case. The
many transformations and tweaks that wasm-bindgen does have a huge
amount of ad-hoc index management to carefully craft a final wasm
binary, but this is all entirely taken care for us with the
walrus
crate.
Additionally,
wasm-bindgen
will ingest and rewrite the wasm file,often changing the binary offsets of functions. Eventually with DWARF
debug information we'll need to be sure to preserve the debug
information throughout the transformations that
wasm-bindgen
doestoday. This is practically impossible to do with the
parity-wasm
architecture, but
walrus
was designed from the get-go to solve thisproblem transparently in the
walrus
crate itself. (it doesn't today,but this is planned work)
It is the intention that this does not end up regressing any
wasm-bindgen
use cases, neither in functionality or in speed. As alarge change and refactoring, however, it's likely that at least
something will arise! We'll want to continue to remain vigilant to any
issues that come up with this commit.
Note that the
gc
crate has been deleted as part of this change, as thegc
crate is no longer necessary sincewalrus
does it automatically.Additionally the
gc
crate was one of the main problems with preservingdebug information as it often deletes wasm items!
Finally, this also starts moving crates to the 2018 edition where
necessary since
walrus
requires the 2018 edition, and in general it'smore pleasant to work within the 2018 edition!