Skip to content

Commit ca17fa4

Browse files
committed
Fix unused and overly-broad __deps entries in JS libraries
- In `src/lib/libpthread.js`, guard `'$addOnPreRun'` in `$PThread__deps` with `#if !MINIMAL_RUNTIME && PTHREAD_POOL_SIZE`. - Guard or remove other unused and overly-broad `__deps` entries across `src/lib/*.js` (`libasync.js`, `libbrowser.js`, `libdylink.js`, `libemval.js`, `libfetch.js`, `libfs.js`, `libglew.js`, `libglut.js`, `libhtml5.js`, `libnoderawfs.js`, `libsdl.js`, `libsockfs_node.js`, `libwasmfs.js`). Split out from #27995
1 parent b106347 commit ca17fa4

17 files changed

Lines changed: 62 additions & 41 deletions

‎src/lib/libasync.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ addToLibrary({
2121

2222
#if ASYNCIFY
2323
$Asyncify__force: true,
24-
$Asyncify__deps: ['$runAndAbortIfError', '$callUserCallback',
25-
#if ASSERTIONS
26-
'$createNamedFunction',
27-
#endif
28-
#if !MINIMAL_RUNTIME
24+
$Asyncify__deps: [
25+
#if useRuntimeKeepaliveStack()
2926
'$runtimeKeepalivePush', '$runtimeKeepalivePop',
3027
#endif
3128
#if ASYNCIFY == 1
29+
'$runAndAbortIfError', '$callUserCallback',
30+
#if ASSERTIONS
31+
'$createNamedFunction',
32+
#endif
3233
// Needed by allocateData and handleSleep respectively
3334
'malloc', 'free',
3435
#endif

‎src/lib/libbrowser.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,14 @@ var LibraryBrowser = {
577577
},
578578

579579
// TODO: currently not callable from a pthread, but immediately calls onerror() if not on main thread.
580-
emscripten_async_load_script__deps: ['$UTF8ToString', '$runDependencies', '$resolveRunDependencies', '$callUserCallback'],
580+
emscripten_async_load_script__deps: [
581+
'$UTF8ToString',
582+
#if ASSERTIONS
583+
'$runDependencies',
584+
#endif
585+
'$resolveRunDependencies',
586+
'$callUserCallback',
587+
],
581588
emscripten_async_load_script: async (url, onload, onerror) => {
582589
url = UTF8ToString(url);
583590
#if PTHREADS

‎src/lib/libdylink.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ var LibraryDylink = {
108108
// the canonical name of the symbol (in some cases modifying the symbol as
109109
// part of the loop process, so that actual symbol looked up has a different
110110
// name).
111-
$resolveGlobalSymbol__deps: ['$isSymbolDefined', '$createNamedFunction',
111+
$resolveGlobalSymbol__deps: ['$isSymbolDefined',
112112
#if !DISABLE_EXCEPTION_CATCHING || SUPPORT_LONGJMP == 'emscripten'
113+
'$createNamedFunction',
113114
'$createInvokeFunction',
114115
#endif
115116
],
@@ -392,7 +393,7 @@ var LibraryDylink = {
392393
// Allocate memory even if malloc isn't ready yet. The allocated memory here
393394
// must be zero initialized since its used for all static data, including bss.
394395
$getMemory__noleakcheck: true,
395-
$getMemory__deps: ['$GOT', 'emscripten_get_sbrk_ptr', '__heap_base', '$alignMemory', 'calloc'],
396+
$getMemory__deps: ['emscripten_get_sbrk_ptr', '__heap_base', '$alignMemory', 'calloc'],
396397
$getMemory: (size) => {
397398
// After the runtime is initialized, we must only use sbrk() normally.
398399
#if DYLINK_DEBUG
@@ -1015,9 +1016,7 @@ var LibraryDylink = {
10151016
'_emscripten_find_dylib',
10161017
'$withStackSave',
10171018
'$stackAlloc',
1018-
'$lengthBytesUTF8',
10191019
'$stringToUTF8OnStack',
1020-
'$stringToUTF8',
10211020
'$FS',
10221021
'$PATH',
10231022
#if WASMFS

‎src/lib/libemval.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ ${functionBody}
361361
return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction));
362362
},
363363

364-
_emval_invoke__deps: ['$getStringOrSymbol', '$emval_methodCallers', '$Emval'],
364+
_emval_invoke__deps: ['$emval_methodCallers'],
365365
_emval_invoke: (caller, handle, methodName, destructorsRef, args) => {
366366
return emval_methodCallers[caller](handle, methodName, destructorsRef, args);
367367
},
@@ -410,7 +410,6 @@ ${functionBody}
410410
},
411411

412412
#if !DISABLE_EXCEPTION_CATCHING || WASM_EXCEPTIONS
413-
$isCppExceptionObject__deps: ['$Emval'],
414413
$isCppExceptionObject: (object) => {
415414
#if !DISABLE_EXCEPTION_CATCHING
416415
return object instanceof CppException;
@@ -420,12 +419,12 @@ ${functionBody}
420419
},
421420
#endif
422421

422+
#if !DISABLE_EXCEPTION_CATCHING || WASM_EXCEPTIONS
423423
_emval_is_catchable_cpp_exception_object__deps: [
424424
'$Emval',
425-
#if !DISABLE_EXCEPTION_CATCHING || WASM_EXCEPTIONS
426425
'$isCppExceptionObject',
427-
#endif
428426
],
427+
#endif
429428
_emval_is_catchable_cpp_exception_object: (object) => {
430429
#if !DISABLE_EXCEPTION_CATCHING || WASM_EXCEPTIONS
431430
return isCppExceptionObject(Emval.toValue(object));

‎src/lib/libfetch.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var LibraryFetch = {
1818
$Fetch: Fetch,
1919
_emscripten_fetch_get_response_headers_length__deps: ['$lengthBytesUTF8'],
2020
_emscripten_fetch_get_response_headers_length: fetchGetResponseHeadersLength,
21-
_emscripten_fetch_get_response_headers__deps: ['$lengthBytesUTF8', '$stringToUTF8'],
21+
_emscripten_fetch_get_response_headers__deps: ['$stringToUTF8'],
2222
_emscripten_fetch_get_response_headers: fetchGetResponseHeaders,
2323
emscripten_fetch_free: fetchFree,
2424

‎src/lib/libfs.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ var LibraryFS = {
3030
'$PROXYFS',
3131
#endif
3232
#if ASSERTIONS
33-
'$strError', '$ERRNO_CODES', '$warnOnce',
33+
'$strError', '$ERRNO_CODES',
34+
#if !STRICT
35+
'$warnOnce',
36+
#endif
3437
#endif
3538
#if !MINIMAL_RUNTIME
3639
'$FS_createPreloadedFile',

‎src/lib/libglew.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121

2222
var LibraryGLEW = {
23-
$GLEW__deps: ['glGetString', '$stringToNewUTF8', '$UTF8ToString', '$webglGetExtensions'],
23+
$GLEW__deps: ['glGetString', '$stringToNewUTF8', '$webglGetExtensions'],
2424
$GLEW: {
2525
isLinaroFork: 1,
2626
extensions: null,

‎src/lib/libglut.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ var LibraryGLUT = {
582582
},
583583

584584
glutDestroyWindow__proxy: 'sync',
585-
glutDestroyWindow__deps: ['$Browser'],
586585
glutDestroyWindow: (name) => {
587586
delete Module['ctx'];
588587
return 1;
@@ -601,7 +600,7 @@ var LibraryGLUT = {
601600
},
602601

603602
glutPositionWindow__proxy: 'sync',
604-
glutPositionWindow__deps: ['$GLUT', 'glutPostRedisplay'],
603+
glutPositionWindow__deps: ['$Browser', 'glutPostRedisplay'],
605604
glutPositionWindow: (x, y) => {
606605
Browser.exitFullscreen();
607606
/* TODO */

‎src/lib/libhtml5.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ var LibraryHTML5 = {
99
#if PTHREADS
1010
'_emscripten_run_callback_on_thread',
1111
#endif
12+
#if EXIT_RUNTIME
1213
'$addOnExit',
14+
#endif
1315
],
1416
$JSEvents: {
1517

@@ -1418,7 +1420,11 @@ var LibraryHTML5 = {
14181420
return doRequestFullscreen(target, strategy);
14191421
},
14201422

1421-
emscripten_enter_soft_fullscreen__deps: ['$JSEvents', '$hideEverythingExceptGivenElement', '$restoreOldWindowedStyle', '$restoreHiddenElements', '$currentFullscreenStrategy', '$softFullscreenResizeWebGLRenderTarget', '$JSEvents_resizeCanvasForFullscreen', '$findEventTarget', '$callCanvasResizedCallback'],
1423+
emscripten_enter_soft_fullscreen__deps: [
1424+
#if PTHREADS
1425+
'$JSEvents',
1426+
#endif
1427+
'$hideEverythingExceptGivenElement', '$restoreOldWindowedStyle', '$restoreHiddenElements', '$currentFullscreenStrategy', '$softFullscreenResizeWebGLRenderTarget', '$JSEvents_resizeCanvasForFullscreen', '$findEventTarget', '$callCanvasResizedCallback'],
14221428
emscripten_enter_soft_fullscreen__proxy: 'sync',
14231429
emscripten_enter_soft_fullscreen: (target, fullscreenStrategy) => {
14241430
#if !DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR

‎src/lib/libnoderawfs.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
addToLibrary({
8-
$NODERAWFS__deps: ['$ERRNO_CODES', '$FS', '$NODEFS', '$TTY', '$mmapAlloc', '$FS_modeStringToFlags', '$NODERAWFS_stream_funcs'],
8+
$NODERAWFS__deps: ['$ERRNO_CODES', '$FS', '$NODEFS', '$TTY', '$FS_modeStringToFlags', '$NODERAWFS_stream_funcs'],
99
$NODERAWFS__postset: `
1010
if (!ENVIRONMENT_IS_NODE) {
1111
throw new Error('NODERAWFS is currently only supported on Node.js environment.')
@@ -220,6 +220,7 @@ addToLibrary({
220220
* could either be a stream created by NODERAWFS itself, or, for example
221221
* one created by PIPEFS. We wrap all these function in an extra check.
222222
*/
223+
$NODERAWFS_stream_funcs__deps: ['$mmapAlloc'],
223224
$NODERAWFS_stream_funcs: {
224225
close(stream) {
225226
VFS.closeStream(stream.fd);

0 commit comments

Comments
 (0)