diff --git a/src/postamble.js b/src/postamble.js index 3785f3f29da66..06728478ec55e 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -132,12 +132,6 @@ function stackCheckInit() { } #endif -#if MAIN_MODULE && PTHREADS -// Map of modules to be shared with new threads. This gets populated by the -// main thread and shared with all new workers via the initial `load` message. -var sharedModules = {}; -#endif - #if MAIN_READS_PARAMS function run(args = arguments_) { #else diff --git a/src/runtime_pthread.js b/src/runtime_pthread.js index 15eb085d71f40..86aed2a1be28e 100644 --- a/src/runtime_pthread.js +++ b/src/runtime_pthread.js @@ -14,6 +14,12 @@ var workerID = 0; #endif +#if MAIN_MODULE +// Map of modules to be shared with new threads. This gets populated by the +// main thread and shared with all new workers via the initial `load` message. +var sharedModules = {}; +#endif + if (ENVIRONMENT_IS_PTHREAD) { #if !MINIMAL_RUNTIME var wasmModuleReceived; diff --git a/test/test_other.py b/test/test_other.py index 7bdd4ef0c4d99..604feafb9457e 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2176,6 +2176,7 @@ def test(link_flags, lib_suffix): test(['libdir/libfile.so.3.1.4.1.5.9'], '.3.1.4.1.5.9') # handle libX.so.1.2.3 as well @node_pthreads + @also_with_modularize def test_dylink_pthread_static_data(self): # Test that a side module uses the same static data region for global objects across all threads @@ -15272,7 +15273,7 @@ def test_preload_module(self, args): // Check that it was preloaded. // The preloading actually only happens on the main thread where the filesystem - // lives. On worker threads the module object is shared via preloadedModules. + // lives. On worker threads the module object is shared via sharedModules. if (emscripten_is_main_runtime_thread()) { int found = EM_ASM_INT( return preloadedWasm['/library.so'] !== undefined;