`load_secondary_module_status` not recognized as a global object with emscripten's MAIN_MODULE flag
Please include the following in your bug report:
Version of emscripten/emsdk:
Please include the output emcc -v here
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.61 (67fa4c16496b157a7fc3377afd69ee0445e8a6e3)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 7cfffe74eeb68fbb3fb9706ac7071f8caeeb6520)
Target: wasm32-unknown-emscripten
Thread model: posix
Issue I'm building an application with JSPI, SPLIT_MODULE and after splitting the wasm module, it's working (with some kinks). However, when I added in the MAIN_MODULE flag, I get an error when trying to load the deferred module.
LinkError: WebAssembly.instantiate(): Import #13 "primary" "load_secondary_module_status": imported mutable global must be a WebAssembly.Global object
I suspect this is because the load_secondary_module_status global variable is not recognized as an export created by wasm-split here, and hence got it's type replaced by a number value. https://github.com/emscripten-core/emscripten/blob/ce52783735235574811aa438e888fcab8a99e8f7/src/library_dylink.js#L265
This issue can be reproduced using the existing tests in emscripten by adding a -sMAIN_MODULE=2.
Hi @brendandahl, I'm tagging you here because I saw that you added load_secondary_module_status in https://github.com/WebAssembly/binaryen/pull/5431.
Should this be fixed by prepending this variable with a '%'?