Add EMSCRIPTEN_EXPORT option by kripken · Pull Request #4977 · emscripten-core/emscripten
And what I know is only that append
-sEXPORTED_FUNCTIONStoPlayerSettings.WebGL.emscriptenArgsmake it work. While puttingEMSCRIPTEN_KEEPALIVEon the C function did not work
Well this I think we can assume that unity is building .a archive under the hood since that is the only way that EMSCRIPTEN_KEEPALIVE wouldn't have the same effect as -sEXPORTED_FUNCTIONS. @juj would know for sure.
Sadly, for symbols that live inside of archive files, when the linker skips the entire object file all the information in it is completely skipped, including any symbol attributes. Making EMSCRIPTEN_KEEPALIVE for symbol in archive files which are skipped would be highly non trivial. The solutions we have today are:
- Make sure the object file in question is references by some other symbol which is included (this triggers the object file to be included)
- Force the include of all objects using
--whole-archive - Force the include of the symbol using
-ufoo(where foo is the name of the sybmol).
Sadly both (2) and (3 ) require custom command line flags. (1) might be an option is you have at least one object file that you know will be included than you can include dummy references to symbols in question. For example:
Include that line in a file that you know will be included at link time will cause the linker to include the object file that contains myfunc.