Skip to content

Commit 5aa5816

Browse files
committed
[emscripten] libscript: Must dlopen() even the default module.
`RTLD_DEFAULT` doesn't work as an argument to `dlsym()` on Emscripten. The default module must always be opened explicitly.
1 parent e4ca4f0 commit 5aa5816

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libscript/src/script-module.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,10 @@ bool MCScriptEnsureModuleIsUsable(MCScriptModuleRef self)
742742
void *t_symbol;
743743
#ifdef _WIN32
744744
t_symbol = GetProcAddress(GetModuleHandle(NULL), MCStringGetCString(t_type -> binding));
745+
#elif defined(__EMSCRIPTEN__)
746+
void *t_handle = dlopen(NULL, RTLD_LAZY);
747+
t_symbol = dlsym(t_handle, MCStringGetCString(t_type->binding));
748+
dlclose(t_handle);
745749
#else
746750
t_symbol = dlsym(RTLD_DEFAULT, MCStringGetCString(t_type -> binding));
747751
#endif

0 commit comments

Comments
 (0)