Description
Just posting as a new issue so it doesn't get forgotten...
Originally posted by @sbc100 in #16003 (comment)
Sorry to raise an error just after you concluded there were no issues stuck_out_tongue But you know, sometimes it takes a while to try updating dependencies.
I tried updating to 3.1.28+ and I now get errors for undefined symbols when an EM_JS function is defined in a library.
wasm-ld: error: libremglk.a(gi_dispa.c.o): undefined symbol: glk_buffer_to_title_case_uni
I think the reason for this is that the EM_JS macro basically expands to a declaration of the EM_JS function as external with an
__attribute__((import_name))
attached to it.However, when you use it outside in other compilation units they don't see that declaration. Actually that sounds odd now that I say its since those attributes should probably attached to the final symbol.
In any case, I think the soltution that others have uses it to only call the EM_JS function within the file where they are defined, and then define small (difined) wrappers for them for use outside the compilation unit.
e.g. declare
glk_buffer_to_title_case_uni_js
as the EM_JS function then define a localglk_buffer_to_title_case_uni
which then just calls it.(I will investigate further to see if we can actually this fix with you having to change any code).
There seems to be two options:
- A way is found so that EM_JS functions can be called from other files without users needing to wrap them.
- The docs are modified to note that this is a limitation and wrapping is needed.