Replies: 1 comment 5 replies
-
|
I don't believe its possible today to link libc++ into the side module like that. At least we for sure don't have any tests for that. The easiest way to using When you see symbols that are both in impots and exports section that normally means those symbols are weak, and I think C++ and templates make a lot of usage of weak symbols. Even vtables themselves I believe are defined as weak, and end up coming from whichever shared library is loaded first. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Our wasm module size is an issue for us and we are trying to break it down into smaller modules. We are trying to move forward with -sMAIN_MODULE=2 and -sSIDE_MODULE=2, for a tighter control and also because MAIN_MODULE=1 bloats the main module significantly.
Our side module has C++ standard library usages, which by default remain unresolved in side module and should be resolved by exports provided by main module. Since we link main module with mode 2, it is unrealistic to specify all necessary standard library functions one by one in the main module's exports, and undesirable. So we decided to create self sufficient side module(s) instead by linking libc++ with side modules.
The problem is that when we link with "-sSIDE_MODULE=2 -lc++" flags the same symbols which were unresolved are still appear in the imports section, and additionaly those appear in the exports section as well.
Beside being seemingly wrong it also bloats the executable (output from bloaty):
It seems that emscripten treats libc++ symbols as special, and I am not sure if this is a bug or a feature :)
If it is a bug, and someone points to me where the boilerplate is, I am willing to work on it.
Example:
em++ example.cpp -sSIDE_MODULE=2 -lc++ -fwasm-exceptions -o example.wasmFunction "_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKc" appears in both sections along with many others
Beta Was this translation helpful? Give feedback.
All reactions