emscripten-core / emscripten-core/emscripten
Linking missing system libraries for side module
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Reading section [System Libraries](https://github.com/emscripten-core/emscripten/wiki/Linking#system-libraries) it is written that in order to link system library calls needed by the side module one can either build the main module with `EMCC_FORCE_STDLIBS=1` set as environment variable and link all, or build the side module with `-v` to see which libraries are actually needed.
The function in the side module:
```
double* new_double(int size)
{
double* d = new double(size);
for (int i = 0; i shared:INFO: (Emscripten: Running sanity checks)
> "E:/emsdk-master/clang/e1.38.28_64bit\opt.exe" C:\Users\pgl\AppData\Local\Temp\emscripten_temp_4frnb_\module.bc -strip-debug -disable-verify -globaldce -disable-loop-vectorization -disable-slp-vectorization -vectorize-loops=false -vectorize-slp=false -o C:\Users\pgl\AppData\Local\Temp\emscripten_temp_4frnb_\module.bc
* `EMCC_FORCE_STDLIBS=1` also doesn't work
The error I get is:
> Assertion failed: missing linked function __Znwm. perhaps a side module was not linked in? if this function was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment
If I export `__Znwm` manually with `-s EXPORTED_FUNCTIONS="['__Znwm']"` in the main module, then it works. The other option is to use `-s EXPORT_ALL=1` in the main module, but this results in a massive main module (1.8mb js file and 1mb wasm).
Am I missing something?
Contributor guide
Assessment
This issue has not been assessed yet.