[docs] Document passing side modules on command line with -sMAIN_MODULE=2 - #27592
[docs] Document passing side modules on command line with -sMAIN_MODULE=2#27592sbc100 wants to merge 1 commit into
Conversation
…LE=2 Explain how passing side modules on the command line automatically preserves their required symbols in `-sMAIN_MODULE=2` mode, and how passing them together with `-sAUTOLOAD_DYLIBS=0` avoids startup loading when modules are loaded dynamically via `dlopen()`. See emscripten-core#27588
| symbols and JS library functions) are preserved and exported from the main | ||
| module. | ||
|
|
||
| - **Load-time dynamic linking**: Side modules are passed on the command line, |
There was a problem hiding this comment.
Wait, is this always the case? You must pass side modules on the command line?
There was a problem hiding this comment.
For load-time dynamic linking yes. I suppose its not always true since you might also specify the load time libraries by directly modifying Module.dynamicLibraries? Is that what you were thinking of? I'd like of forgotten one could do that.
There was a problem hiding this comment.
Yes, the Module stuff is what I was thinking of.
| If side modules are not passed on the command line (e.g. loaded later via | ||
| ``dlopen``), you must either keep symbols alive manually (via | ||
| ``EXPORTED_FUNCTIONS`` or ``EMSCRIPTEN_KEEPALIVE``) or pass the side | ||
| modules on the command line along with ``-sAUTOLOAD_DYLIBS=0``. |
There was a problem hiding this comment.
These sentences say this:
- Symbols needed by side modules passed on the command line will be kept alive automatically
- If side modules are not passed, you must either
2.1. keep symbols alive manually
2.2. pass side modules on the command line (with a flag)
Is 2.2 not redundant with 1? Both talk about passing the side modules on the command line.
There was a problem hiding this comment.
Yes, but I want to call out the second cases specificity because one doesn't normally pass dlopen'ed side modules on the command line. I will try to rephrase to avoid the seeming repetition.
| in the same way, with the same flags used to build the main and side modules. | ||
|
|
||
| Side modules loaded dynamically at runtime must be placed in the virtual | ||
| filesystem so that ``dlopen()`` (or ``fopen()``, etc.) can access them (except |
There was a problem hiding this comment.
I thought we also had support for dlopen on URLs?
Explain how passing side modules on the command line automatically preserves their required symbols in
-sMAIN_MODULE=2mode, and how passing them together with-sAUTOLOAD_DYLIBS=0avoids startup loading when modules are loaded dynamically viadlopen().See #27588