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

dylink: Share dynamicLibraries array across workers #19496

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/runtime_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
Expand Down
10 changes: 7 additions & 3 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '''
Expand Down
Loading