Skip to content

Commit

Permalink
Alternative fix for PR emscripten-core#19496
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Oct 23, 2023
1 parent 054bf30 commit 38a001d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,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.
var sharedModules = Module['sharedModules'] || [];
#endif

#if MAIN_READS_PARAMS
function run(args = arguments_) {
#else
Expand Down
11 changes: 11 additions & 0 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,12 @@ function instantiateAsync(binary, binaryFile, imports, callback) {
}
#endif // WASM_ASYNC_COMPILATION

#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.
var sharedModules = Module['sharedModules'] || [];
#endif

// Create the wasm instance.
// Receives the wasm imports, returns the exports.
function createWasm() {
Expand Down Expand Up @@ -961,6 +967,11 @@ function createWasm() {
if (metadata.neededDynlibs) {
dynamicLibraries = metadata.neededDynlibs.concat(dynamicLibraries);
}
#endif
#if PTHREADS
if (ENVIRONMENT_IS_PTHREAD) {
dynamicLibraries = Object.keys(sharedModules);
}
#endif
mergeLibSymbols(wasmExports, 'main')
#if '$LDSO' in addedLibraryItems
Expand Down

0 comments on commit 38a001d

Please sign in to comment.