emscripten-core / emscripten-core/emscripten

`load_secondary_module_status` not recognized as a global object with emscripten's MAIN_MODULE flag

Open
#22,487 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

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 ](https://github.com/emscripten-core/emscripten/blob/ce52783735235574811aa438e888fcab8a99e8f7/test/test_other.py#L12780) in emscripten by adding a `-sMAIN_MODULE=2`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.