Skip to content

Commit 2f90f73

Browse files
committed
Add missing direct __deps entries across JS libraries. NFC
Add missing direct `__deps` declarations for JS library symbols that previously relied on other callers pulling in their dependencies later in the dependency graph. With `__ps` sorted alphabetically (emscripten-core#28059), adding these missing direct edges ensures that automatically computing JS-to-JS dependencies (emscripten-core#27995) produces identical declaration ordering and zero diffs across `test/codesize/`. See: emscripten-core#19098
1 parent 1978fec commit 2f90f73

13 files changed

Lines changed: 47 additions & 19 deletions

‎src/lib/libaddfunction.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ addToLibrary({
114114
#endif
115115
},
116116

117-
$updateTableMap__deps: ['$getWasmTableEntry'],
117+
$updateTableMap__deps: ['$getWasmTableEntry', '$functionsInTableMap'],
118118
$updateTableMap: (offset, count) => {
119119
if (functionsInTableMap) {
120120
for (var i = offset; i < offset + count; i++) {

‎src/lib/libcore.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ addToLibrary({
14081408
$timers: {},
14091409

14101410
$clearTimers__internal: true,
1411+
$clearTimers__deps: ['$timers'],
14111412
$clearTimers: () => {
14121413
for (var t of Object.values(timers)) {
14131414
clearTimeout(t.id);
@@ -2079,9 +2080,12 @@ addToLibrary({
20792080
emscripten_throw_string: (str) => { throw UTF8ToString(str); },
20802081

20812082
#if !MINIMAL_RUNTIME
2083+
$handleException__deps: [
2084+
'$ExitStatus',
20822085
#if STACK_OVERFLOW_CHECK
2083-
$handleException__deps: ['emscripten_stack_get_current'],
2086+
'emscripten_stack_get_current',
20842087
#endif
2088+
],
20852089
$handleException: (e) => {
20862090
// Certain exception types we do not treat as errors since they are used for
20872091
// internal control flow.

‎src/lib/libdylink.js‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const UNDEFINED_ADDR = to64(-1);
1616

1717
var LibraryDylink = {
1818
#if FILESYSTEM
19-
$registerWasmPlugin__deps: ['$preloadPlugins'],
19+
$registerWasmPlugin__deps: ['$preloadPlugins', '$loadWebAssemblyModule', '$preloadedWasm'],
2020
$registerWasmPlugin: () => {
2121
// Use string keys here for public methods to avoid minification since the
2222
// plugin consumer also uses string keys.
@@ -310,7 +310,7 @@ var LibraryDylink = {
310310
},
311311

312312
$reportUndefinedSymbols__internal: true,
313-
$reportUndefinedSymbols__deps: ['$GOT', '$resolveGlobalSymbol'],
313+
$reportUndefinedSymbols__deps: ['$GOT', '$resolveGlobalSymbol', '$addFunction'],
314314
$reportUndefinedSymbols: () => {
315315
#if DYLINK_DEBUG
316316
dbg('reportUndefinedSymbols');
@@ -393,7 +393,11 @@ var LibraryDylink = {
393393
// Allocate memory even if malloc isn't ready yet. The allocated memory here
394394
// must be zero initialized since its used for all static data, including bss.
395395
$getMemory__noleakcheck: true,
396-
$getMemory__deps: ['emscripten_get_sbrk_ptr', '__heap_base', '$alignMemory', 'calloc'],
396+
// `__heap_base` is also used below, but is added via `REQUIRED_EXPORTS` in
397+
// `link.py` rather than `__deps` because `wasm-ld` processes stub library
398+
// dependencies before synthesizing optional symbols like `__heap_base`.
399+
// See https://github.com/llvm/llvm-project/issues/180632
400+
$getMemory__deps: ['emscripten_get_sbrk_ptr', '$alignMemory', 'calloc'],
397401
$getMemory: (size) => {
398402
// After the runtime is initialized, we must only use sbrk() normally.
399403
#if DYLINK_DEBUG
@@ -684,6 +688,9 @@ var LibraryDylink = {
684688
'$loadDynamicLibrary',
685689
'$getDylinkMetadata',
686690
'$instantiateModule',
691+
#if FILESYSTEM
692+
'$findLibraryFS',
693+
#endif
687694
],
688695
$loadWebAssemblyModule: (binary, flags, libName, localScope, handle) => {
689696
#if DYLINK_DEBUG
@@ -722,6 +729,7 @@ var LibraryDylink = {
722729
$instantiateModule__deps: [
723730
'$getMemory', '$updateGOT',
724731
'$relocateExports', '$resolveGlobalSymbol', '$GOTHandler',
732+
'$reportUndefinedSymbols',
725733
'$alignMemory', '$updateTableMap',
726734
'$wasmTable', '$addOnPostCtor',
727735
'$addEmAsm', '$addEmJs',
@@ -996,6 +1004,7 @@ var LibraryDylink = {
9961004
},
9971005
#endif
9981006

1007+
$newDSO__deps: ['$LDSO'],
9991008
$newDSO: (name, handle, syms) => {
10001009
var dso = {
10011010
refcount: Infinity,
@@ -1082,6 +1091,7 @@ var LibraryDylink = {
10821091
'$mergeLibSymbols', '$newDSO',
10831092
'$asyncLoad',
10841093
#if FILESYSTEM
1094+
'$FS',
10851095
'$preloadedWasm',
10861096
'$findLibraryFS',
10871097
#endif

‎src/lib/libfs_shared.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ addToLibrary({
107107
return mode;
108108
},
109109

110+
$FS_fileDataToTypedArray__deps: ['$intArrayFromString'],
110111
$FS_fileDataToTypedArray: (data) => {
111112
if (typeof data === 'string') {
112113
data = intArrayFromString(data, true);

‎src/lib/libopenal.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,6 +3274,7 @@ var LibraryOpenAL = {
32743274
// alDopplerVelocity() sets a multiplier for the speed of sound.
32753275
// It's deprecated since it's equivalent to directly calling
32763276
// alSpeedOfSound() with an appropriately premultiplied value.
3277+
alDopplerVelocity__deps: ['$warnOnce'],
32773278
alDopplerVelocity__proxy: 'sync',
32783279
alDopplerVelocity: (value) => {
32793280
warnOnce('alDopplerVelocity() is deprecated, and only kept for compatibility with OpenAL 1.0. Use alSpeedOfSound() instead.');

‎src/lib/libpthread.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,20 @@ const pthreadWorkerOptions = `{
8181
var LibraryPThread = {
8282
$PThread__postset: 'PThread.init();',
8383
$PThread__deps: ['_emscripten_thread_init',
84+
'$callUserCallback',
85+
'$checkMailbox',
8486
'$terminateWorker',
8587
'$cleanupThread',
86-
#if !MINIMAL_RUNTIME && PTHREAD_POOL_SIZE
88+
#if !MINIMAL_RUNTIME
89+
'$wasmMemory',
90+
#if PTHREAD_POOL_SIZE
8791
'$addOnPreRun',
8892
#if !PTHREAD_POOL_DELAY_LOAD
8993
'$addRunDependency',
9094
'$removeRunDependency',
9195
#endif
9296
#endif
97+
#endif
9398
#if MAIN_MODULE
9499
'$markAsFinished',
95100
#endif

‎src/lib/libwasm_worker.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ addToLibrary({
7474
// which these postponed function calls can be dispatched.
7575
$_wasmWorkerDelayedMessageQueue: [],
7676

77+
$_wasmWorkerAppendToQueue__deps: ['$_wasmWorkerDelayedMessageQueue'],
7778
$_wasmWorkerAppendToQueue: (e) => {
7879
_wasmWorkerDelayedMessageQueue.push(e);
7980
},

‎src/lib/libwebaudio.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ var LibraryWebAudio = {
161161
// etc., but the created worklet does.
162162
_emscripten_create_audio_worklet__deps: [
163163
'$_emAudioDispatchProcessorCallback',
164+
'$emAudio',
164165
'$stackAlloc', '$stackRestore', '$stackSave', '$HEAP32', '$HEAPU32', '$HEAPF32',
165166
#if WASM_BIGINT || MEMORY64
166167
'$HEAP64', '$HEAPU64',

‎test/codesize/audio_worklet_wasm.expected.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ var L = [], M = a => {
114114
a = a.data;
115115
var b = a._wsc;
116116
b && A.get(b)(...a.D);
117-
}, ca = (a, b, c, k, d, g, f) => {
117+
}, Q = {}, ca = (a, b, c, k, d, g, f) => {
118118
var l = Q[b], n = l.audioWorklet;
119119
d = () => {
120120
A.get(g)(b, 0, f);
@@ -144,7 +144,7 @@ var L = [], M = a => {
144144
}, da = (a, b, c, k) => {
145145
b = Q[b];
146146
Q[a].connect(b.destination || b, c, k);
147-
}, Q = {}, R = 0, S = globalThis.TextDecoder && new TextDecoder, T = (a = 0) => {
147+
}, R = 0, S = globalThis.TextDecoder && new TextDecoder, T = (a = 0) => {
148148
for (var b = J, c = a, k = c + NaN; b[c] && !(c >= k); ) ++c;
149149
if (c - a > 16 && b.buffer && S) return S.decode(b.slice(a, c));
150150
for (k = ""; a < c; ) {

‎test/codesize/test_codesize_hello_dylink.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"a.out.js": 26228,
3-
"a.out.js.gz": 11153,
2+
"a.out.js": 26229,
3+
"a.out.js.gz": 11148,
44
"a.out.nodebug.wasm": 16986,
55
"a.out.nodebug.wasm.gz": 8667,
6-
"total": 43214,
7-
"total_gz": 19820,
6+
"total": 43215,
7+
"total_gz": 19815,
88
"sent": [
99
"__syscall_stat64",
1010
"emscripten_resize_heap",

0 commit comments

Comments
 (0)