Fix WebAssembly global exports with DECLARE_ASM_MODULE_EXPORTS=0(issue #25556)
Root Cause
The exportWasmSymbols function had conditional logic that prevented proper global export:
// before :
if (typeof exportedSymbol.value === 'undefined') {
// Export functions
}
Solution
Removed the if condition and simplified to export all symbols unconditionally:
// After (fixed):
// Export all symbols (both functions and globals) to the global scope
// when DECLARE_ASM_MODULE_EXPORTS=0
globalThis[name] = exportedSymbol;
Changes
- Modified:
src/lib/libcore.js- SimplifiedexportWasmSymbolsfunction - Enabled:
test/test_core.py- Removed@no_omit_asm_module_exportsdecorator
@sbc100 please review it
This is expected to be addressed by PR #25568.
@devalgupta404 are you using DECLARE_ASM_MODULE_EXPORTS=0 yourself? Can I ask why you are using it?
This a fix for https://github.com/emscripten-core/emscripten/issues/25556 right?
I don't think this is the right fix though since it would change the way immutable globls are currently exported.. right now they are plain numbers, after this change they would be Wasm globals.