I just landed a fairly major update to emscripten's dynamic linking support:
https://github.com/emscripten-core/emscripten/pull/25522
Essentially we no longer build the main module as position independent (`-pie`/``-sRELOCATABLE`). This reduces the code size and eliminates most runtime relocations from the main module.
Basically the overhead of using dynamic linking is almost completely eliminated, at least in the main module.
Hopefully we don't find any issues with this in the wild, and we followup with more exciting changes. for example, perhaps turning on `-Bdynamic` by default (i.e. allow shared libraries to be linked by default, without needing the `-sMAIN_MODULE` flag, just like on native platforms.
cheers,
sam