diff --git a/src/library_pthread.js b/src/library_pthread.js index 21752e14e0b6..e572dc6252ad 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -379,6 +379,7 @@ var LibraryPThread = { 'wasmOffsetConverter': wasmOffsetConverter, #endif #if MAIN_MODULE + 'dynamicLibraries': dynamicLibraries, // Share all modules that have been loaded so far. New workers // won't start running threads until these are all loaded. 'sharedModules': sharedModules, diff --git a/src/runtime_pthread.js b/src/runtime_pthread.js index ca2f6138e61e..00cf3af11c89 100644 --- a/src/runtime_pthread.js +++ b/src/runtime_pthread.js @@ -129,6 +129,7 @@ if (ENVIRONMENT_IS_PTHREAD) { }; #if MAIN_MODULE + dynamicLibraries = msgData['dynamicLibraries']; sharedModules = msgData['sharedModules']; #if RUNTIME_DEBUG dbg(`worker: received ${Object.keys(msgData['sharedModules']).length} shared modules: ${Object.keys(msgData.sharedModules)}`); diff --git a/test/test_core.py b/test/test_core.py index 8d446615c842..c010f9e5faa7 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -9412,13 +9412,17 @@ def test_Module_dynamicLibraries(self, args): self.emcc_args += args self.emcc_args += ['--pre-js', 'pre.js'] self.emcc_args += ['--js-library', 'lib.js'] - # This test is for setting dynamicLibraries at runtime so we don't + # This test is for setting dynamicLibraries at runtime, so we don't # want emscripten loading `liblib.so` automatically (which it would - # do without this setting. + # do without this setting) self.set_setting('NO_AUTOLOAD_DYLIBS') create_file('pre.js', ''' - Module['dynamicLibraries'] = ['liblib.so']; + if (typeof ENVIRONMENT_IS_PTHREAD == 'undefined' || !ENVIRONMENT_IS_PTHREAD) { + // Load liblib.so on the main thread, this would be equivalent to + // defining it outside the module (e.g. in MODULARIZE mode). + Module['dynamicLibraries'] = ['liblib.so']; + } ''') create_file('lib.js', '''