Skip to content

Commit ffd5abc

Browse files
committed
Calculate transitive JS library deps after symbolHandler in --symbols-only mode. NFC
Previously, `getTransitiveDeps` was called inside `addFromLibrary` while `symbolHandler` was still iterating through `symbolsNeeded` and mutating `__deps` (such as adding `setTempRet0` for i64-returning functions without `WASM_BIGINT`). Compute `symbolDeps` in the `if (symbolsOnly)` block after `symbolHandler` completes so that all direct `__deps` are populated before traversing the dependency graph. Split out from emscripten-core#27995.
1 parent da779b5 commit ffd5abc

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎src/jsifier.mjs‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ const PROXY_SYNC_ASYNC = 2;
415415
export async function runJSify(outputFile, symbolsOnly) {
416416
const libraryItems = [];
417417
const libraryAliases = [];
418-
const symbolDeps = {};
419418
const asyncFuncs = [];
420419
let postSets = [];
421420

@@ -629,13 +628,6 @@ function(${args}) {
629628
}
630629

631630
if (symbolsOnly) {
632-
if (LibraryManager.library.hasOwnProperty(symbol)) {
633-
// Resolve aliases before looking up deps
634-
var transitiveDeps = getTransitiveDeps(symbol);
635-
symbolDeps[symbol] = transitiveDeps.filter(
636-
(d) => !isJsOnlySymbol(d) && !(d in LibraryManager.library),
637-
);
638-
}
639631
return;
640632
}
641633

@@ -1003,6 +995,15 @@ var proxiedFunctionTable = [
1003995
timer.stop('symbolHandler');
1004996

1005997
if (symbolsOnly) {
998+
const symbolDeps = {};
999+
for (const sym of Object.keys(LibraryManager.library)) {
1000+
if (!isDecorator(sym)) {
1001+
const transitiveDeps = getTransitiveDeps(sym);
1002+
symbolDeps[sym] = transitiveDeps.filter(
1003+
(d) => !isJsOnlySymbol(d) && !(d in LibraryManager.library),
1004+
);
1005+
}
1006+
}
10061007
writeOutput(
10071008
JSON.stringify({
10081009
deps: symbolDeps,

0 commit comments

Comments
 (0)