Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thread local storage support for dynamic libraries #13447

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Initialize tls for each side module
  • Loading branch information
jprendes committed Jan 31, 2021
commit 18f49ef3c3af838068d5a44b6c6314eb1fa35a6b
7 changes: 7 additions & 0 deletions src/worker.js
Original file line number Diff line number Diff line change
@@ -184,6 +184,13 @@ this.onmessage = function(e) {
// Also call inside JS module to set up the stack frame for this pthread in JS module scope
Module['establishStackSpace'](top, max);
Module['_emscripten_tls_init']();
#if MAIN_MODULE >= 1
Object.values(Module['LDSO'].loadedLibs).forEach(function (lib) {
if ("emscripten_tls_init" in lib.module) {
lib.module.emscripten_tls_init();
}
});
#endif

Module['PThread'].receiveObjectTransfer(e.data);
Module['PThread'].setThreadStatus(Module['_pthread_self'](), 1/*EM_THREAD_STATUS_RUNNING*/);
2 changes: 1 addition & 1 deletion tests/test_other.py
Original file line number Diff line number Diff line change
@@ -1502,7 +1502,7 @@ def test_dynamic_link_pthread_tls(self):
int main(void) {
get_value() = 123;
std::thread([]{
printf("%d\n", get_value());
printf("%d\n", get_value());
}).join();
return 0;
}