Skip to content

Commit 2886b50

Browse files
committed
Fix non-MINIMAL_RUNTIME asmjs name mangling when building with DECLARE_ASM_MODULE_EXPORTS=0
1 parent 2cd8f93 commit 2886b50

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

emscripten.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,9 +2671,15 @@ def create_receiving_wasm(exports):
26712671
if shared.Settings.MINIMAL_RUNTIME:
26722672
module_assign = ''
26732673
else:
2674-
module_assign = 'Module[__exportedFunc] = '
2674+
module_assign = 'Module[asmjs_mangle(__exportedFunc)] = '
26752675

2676-
receiving.append('for(var __exportedFunc in asm) ' + global_object + '[__exportedFunc] = ' + module_assign + 'asm[__exportedFunc];')
2676+
receiving.append('''
2677+
function asmjs_mangle(x) {
2678+
var unmangledSymbols = ['setTempRet0', 'getTempRet0', 'stackAlloc', 'stackSave', 'stackRestore', 'establishStackSpace', '__growWasmMemory', '__heap_base', '__data_end'];
2679+
return x.indexOf('dynCall_') == 0 || unmangledSymbols.indexOf(x) != -1 ? x : '_' + x;
2680+
}
2681+
''')
2682+
receiving.append('for(var __exportedFunc in asm) ' + global_object + '[asmjs_mangle(__exportedFunc)] = ' + module_assign + 'asm[__exportedFunc];')
26772683
else:
26782684
receiving.append('Module["asm"] = asm;')
26792685
for e in exports:

0 commit comments

Comments
 (0)