wasm-ld --export-all
does not work with wasm-bindgen
#4494
Labels
--export-all
does not work with wasm-bindgen
#4494
Describe the Bug
I've implemented WASM hot patching for Rust.
DioxusLabs/dioxus#3797 (comment)
432065352-b81f1a60-b6b2-422d-a536-d9e0bcd75221.mp4
Part of this working properly requires every symbol from the dependency rlibs to make it into the final executable. All other platforms (mac/win/linux/android/ios) have facilities to force all symbols (--no-gc-sections, --whole-archive). Unfortunately,
wasm-bindgen
is the one tool that always runs GC and doesn't give an option to not run GC.This means I need to prevent symbols from being dissolved by the wasm-bindgen GC pass, but relying on markers is fraught with issues and will likely break in the future. I hacked together something that barely works today but I can't expect it to work tomorrow:
If I force the wasm-bindgen intrinsics into an export, then the wasm-bindgen pass deletes them. If I put them in the ifunc table, the generated JS is invalid.
These imports:
Will end up leaving the
__wbindgen_externref_xform__
import in the generated JS bindings:If I hoist every symbol (ie with --export-all) then the describe functions stick around and aren't valid JS.
Ideally, I can pass
--export-all
, get every interface properly wasm-bindgen-ed, and then load subsequent patches that don't require any bindgen at all. Currently it's not clear if I can even load the patches without running wasm-bindgen on them (due to the transform passes), and if I have to, then I can't use dynamic linking because of #4493.Steps to Reproduce
Running rustc with the export-all flag will trigger the issues:
cargo rustc --package app --target wasm32-unknown-unknown -Clinker-arg=-Wl,--export-all
Expected Behavior
You can export all symbols from a wasm module.
Actual Behavior
The generated JS is invalid.
Additional Context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: