While trying to use dynamic linking to lazy load "less-used" code/libraries in my code, I encountered an issue where the SIDE_MODULE was not able to access a standard library function. I have built a smaller test case for the same where I try to use the standard library function clock from time.h in the SIDE_MODULE.
Here is the code and build files for the same: https://github.com/tapananand/dynLinkPOC You can build it by running command `make all`. Here, the SIDE_MODULE tries to use the clock() function of time.h library but it can't get its implementation from the MAIN_MODULE. On running the dynLink.html file, which loads the generated wasm in a web worker, an error is encountered TypeError: Cannot read property 'apply' of undefined On debugging further this boils down to _clock not being defined on the Module object. On building with MAIN_MODULE=1, it all works fine. So, it seems that _clock is dead code eliminated from the MAIN_MODULE when using MAIN_MODULE=2, although I have added it in the -s EXPORTED_FUNCTIONS list option (as seen in the Makefile) *Is this a known issue or am I doing something wrong here?* Also, I am using loadDynamicLibrary to be able to lazily load the second wasm, but the documentation here <https://github.com/emscripten-core/emscripten/wiki/Linking#hyper-dynamic-linking> mentions, globals might not work fine. I have actually encountered issues when trying to use cout in the side module in this same sample (try uncommenting the cout in doubler.cpp). So, *is there an alternative way to lazily load side module which doesn't have these issues?* Thanks in advance for your help! -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
