From a3d9a79a5c5355951d14b1e2044d2ceda56e46dc Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 22 Oct 2026 14:33:38 -0700 Subject: [PATCH] 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 #27995. --- src/jsifier.mjs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/jsifier.mjs b/src/jsifier.mjs index a74ed0189cdc9..713ec42bb1d92 100644 --- a/src/jsifier.mjs +++ b/src/jsifier.mjs @@ -415,7 +415,6 @@ const PROXY_SYNC_ASYNC = 2; export async function runJSify(outputFile, symbolsOnly) { const libraryItems = []; const libraryAliases = []; - const symbolDeps = {}; const asyncFuncs = []; let postSets = []; @@ -629,13 +628,6 @@ function(${args}) { } if (symbolsOnly) { - if (LibraryManager.library.hasOwnProperty(symbol)) { - // Resolve aliases before looking up deps - var transitiveDeps = getTransitiveDeps(symbol); - symbolDeps[symbol] = transitiveDeps.filter( - (d) => !isJsOnlySymbol(d) && !(d in LibraryManager.library), - ); - } return; } @@ -1008,6 +1000,15 @@ var proxiedFunctionTable = [ timer.stop('symbolHandler'); if (symbolsOnly) { + const symbolDeps = {}; + for (const sym of Object.keys(LibraryManager.library)) { + if (!isDecorator(sym)) { + const transitiveDeps = getTransitiveDeps(sym); + symbolDeps[sym] = transitiveDeps.filter( + (d) => !isJsOnlySymbol(d) && !(d in LibraryManager.library), + ); + } + } writeOutput( JSON.stringify({ deps: symbolDeps,