emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Fix WebAssembly global exports with DECLARE_ASM_MODULE_EXPORTS=0(issue #25556)

Open devalgupta404 opened this issue 2 months ago • 4 comments

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 - Simplified exportWasmSymbols function
  • Enabled: test/test_core.py - Removed @no_omit_asm_module_exports decorator

devalgupta404 avatar Oct 21 '25 08:10 devalgupta404

@sbc100 please review it

devalgupta404 avatar Oct 21 '25 08:10 devalgupta404

This is expected to be addressed by PR #25568.

kleisauke avatar Oct 21 '25 08:10 kleisauke

@devalgupta404 are you using DECLARE_ASM_MODULE_EXPORTS=0 yourself? Can I ask why you are using it?

sbc100 avatar Oct 21 '25 15:10 sbc100

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.

sbc100 avatar Oct 21 '25 15:10 sbc100