Skip to content
Snippets Groups Projects
Commit cb8d428f authored by Cheng Shao's avatar Cheng Shao
Browse files

wasm: fix dyld downsweep filepath handling in browser

The wasm dyld downsweep logic used to rely on nodejs path module to
handle filepaths. That's not available in browsers, so this commit
implements poor man's filepath handling in js, which is not elegant
for sure but works for both nodejs and the browser.

(cherry picked from commit d9b71e82)
parent 5f261dcd
No related branches found
No related tags found
No related merge requests found
...@@ -423,7 +423,9 @@ class DyLD { ...@@ -423,7 +423,9 @@ class DyLD {
// WebAssembly.Module in loadDLL logic. This way we can harness some // WebAssembly.Module in loadDLL logic. This way we can harness some
// background parallelism. // background parallelism.
async #downsweep(p) { async #downsweep(p) {
const soname = path.basename(p); const toks = p.split("/");
const soname = toks[toks.length - 1];
if (this.#loadedSos.has(soname)) { if (this.#loadedSos.has(soname)) {
return []; return [];
...@@ -432,11 +434,12 @@ class DyLD { ...@@ -432,11 +434,12 @@ class DyLD {
// Do this before loading dependencies to break potential cycles. // Do this before loading dependencies to break potential cycles.
this.#loadedSos.add(soname); this.#loadedSos.add(soname);
if (path.isAbsolute(p)) { if (p.startsWith("/")) {
// GHC may attempt to load libghc_tmp_2.so that needs // GHC may attempt to load libghc_tmp_2.so that needs
// libghc_tmp_1.so in a temporary directory without adding that // libghc_tmp_1.so in a temporary directory without adding that
// directory via addLibrarySearchPath // directory via addLibrarySearchPath
this.addLibrarySearchPath(path.dirname(p)); toks.pop();
this.addLibrarySearchPath(toks.join("/"));
} else { } else {
p = await this.findSystemLibrary(p); p = await this.findSystemLibrary(p);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment