-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] esm: basic wasm module env #27815
Conversation
We would be against shipping that, as it's emscripten specific. It's a well known issue, I filed an issue (on the wrong repo) here: WebAssembly/esm-integration#5. In order to make it work I used to run a transformation the binary to point to an actual ESM file: https://github.com/wasm-tool/emscripten/blob/master/loader.js#L69-L71. It would make sense to me to do something similar for testing. I'm happy to help if you need. |
agreed with xtuc. it would also cause confusion for wasms built from rust which uses |
Agreed with xtuc as well. Moreover, if you use a pure upstream clang + wasi-sysroot compiler, iiuc, there is no |
I think ESM wasm is flawed for this reason. Lots of wasm modules have very complicated setups. IMO, There's so much wrong with wasm module instantiation that it's practically unfixable at this point. I spent a few days trying to write an emscripten wrapper that provided consistent behavior between the browser and node -- it's impossible because of Chrome's arbitrary 4kb limit for sync instantiation. Surely ESM wasm would be the answer? Nope, that's broken too. =/ |
FYI, this doesn't seem to be the case just yet.. wasi-sdk-5.0 still ends up emitting
|
Oops, sorry to give you incorrect information; I had thought that was the goal. Maybe @sunfishcode can shed some light on what the plan is? |
@ofrobots Statically-linked WASI executables don't have |
Indeed, there was confusion on my part about to link a wasm library without a main. |
Feels like there has been good discussion.. closing in lieu of #27850 |
The current tests for Wasm modules is only testing modules that were compiled from Wast to Wasm.
When trying to get some basic functions working that were compiled via emscripten I quickly found that those modules were expecting a gloabal
env
that is generated for the .js wrapper.Here's a link to the upstream source--> https://github.com/emscripten-core/emscripten/blob/incoming/src/preamble.js#L1117-L1158
This is a really naive PR tracking my work trying to get off the shelf wasm working as modules, it seems like there are lots of edge cases. I'm not 100% we want to ship this specific, and arguably internal, details of emscripten in core... hope to use this PR for a discussion in figuring out what makes the most sense.
@nodejs/modules