From 570ff62ffbe8d145a6386517e16ef6ed3bab5e8f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 28 Jan 2026 17:28:19 -0800 Subject: [PATCH] Remove logReadFiles from default INCOMING_MODULE_JS_API --- ChangeLog.md | 3 +++ site/source/docs/porting/files/packaging_files.rst | 12 +++++++++--- src/settings.js | 2 +- test/codesize/test_codesize_cxx_ctors1.json | 8 ++++---- test/codesize/test_codesize_cxx_ctors2.json | 8 ++++---- test/codesize/test_codesize_cxx_except.json | 8 ++++---- test/codesize/test_codesize_cxx_except_wasm.json | 8 ++++---- .../test_codesize_cxx_except_wasm_legacy.json | 8 ++++---- test/codesize/test_codesize_cxx_lto.json | 8 ++++---- test/codesize/test_codesize_cxx_mangle.json | 8 ++++---- test/codesize/test_codesize_cxx_noexcept.json | 8 ++++---- test/codesize/test_codesize_files_js_fs.json | 8 ++++---- test/codesize/test_codesize_hello_O0.json | 8 ++++---- test/codesize/test_codesize_hello_dylink.json | 8 ++++---- test/codesize/test_codesize_hello_dylink_all.json | 4 ++-- test/codesize/test_codesize_minimal_O0.expected.js | 2 +- test/codesize/test_unoptimized_code_size.json | 10 +++++----- test/test_other.py | 2 +- tools/cmdline.py | 1 + 19 files changed, 67 insertions(+), 57 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cf34b1b84a065..1a72c26e45a87 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works. 5.0.1 (in development) ---------------------- +- `logReadFiles` was removed from the default `INCOMING_MODULE_JS_API` list. + To use this feature you now need to explictly add `logReadFiles` to + `INCOMING_MODULE_JS_API`. (#26190); 5.0.0 - 01/24/26 ---------------- diff --git a/site/source/docs/porting/files/packaging_files.rst b/site/source/docs/porting/files/packaging_files.rst index 5520d955c3a3a..047e5b0de5bdb 100644 --- a/site/source/docs/porting/files/packaging_files.rst +++ b/site/source/docs/porting/files/packaging_files.rst @@ -113,9 +113,15 @@ Monitoring file usage .. important:: Only package the files your app actually needs, in order to reduce download size and improve startup speed. -There is an option to log which files are actually used at runtime. To use it, define the :js:attr:`Module.logReadFiles` object. Each file that is read will be logged to stderr. - -An alternative approach is to look at :js:func:`FS.readFiles` in your compiled JavaScript. This is an object with keys for all the files that were read from. You may find it easier to use than logging as it records files rather than potentially multiple file accesses. +There is an option to log which files are actually used at runtime. To use it, +define the :js:attr:`Module.logReadFiles` object. Each file that is read will be +logged to stderr. To use this feautre you need to add ``logReadFiles`` to +:ref:`INCOMING_MODULE_JS_API`. + +An alternative approach is to look at :js:func:`FS.readFiles` in your compiled +JavaScript. This is an object with keys for all the files that were read from. +You may find it easier to use than logging as it records files rather than +potentially multiple file accesses. .. note:: You can also modify the :js:func:`FS.readFiles` object or remove it entirely. This can be useful, say, in order to see which files are read between two points in time in your app. diff --git a/src/settings.js b/src/settings.js index ae8831335e619..01ecf6e6247de 100644 --- a/src/settings.js +++ b/src/settings.js @@ -996,7 +996,7 @@ var INCOMING_MODULE_JS_API = [ 'buffer', 'canvas', 'doNotCaptureKeyboard', 'dynamicLibraries', 'elementPointerLock', 'extraStackTrace', 'forcedAspectRatio', 'instantiateWasm', 'keyboardListeningElement', 'freePreloadedMediaOnUse', - 'loadSplitModule', 'locateFile', 'logReadFiles', 'mainScriptUrlOrBlob', 'mem', + 'loadSplitModule', 'locateFile', 'mainScriptUrlOrBlob', 'mem', 'monitorRunDependencies', 'noExitRuntime', 'noInitialRun', 'onAbort', 'onExit', 'onFree', 'onFullScreen', 'onMalloc', 'onRealloc', 'onRuntimeInitialized', 'postMainLoop', 'postRun', 'preInit', diff --git a/test/codesize/test_codesize_cxx_ctors1.json b/test/codesize/test_codesize_cxx_ctors1.json index b44423b3f1bc8..b3e770937beba 100644 --- a/test/codesize/test_codesize_cxx_ctors1.json +++ b/test/codesize/test_codesize_cxx_ctors1.json @@ -1,10 +1,10 @@ { - "a.out.js": 19623, - "a.out.js.gz": 8144, + "a.out.js": 19555, + "a.out.js.gz": 8102, "a.out.nodebug.wasm": 132844, "a.out.nodebug.wasm.gz": 49884, - "total": 152467, - "total_gz": 58028, + "total": 152399, + "total_gz": 57986, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_ctors2.json b/test/codesize/test_codesize_cxx_ctors2.json index e03fdd6f6a754..db6c9e9aaf196 100644 --- a/test/codesize/test_codesize_cxx_ctors2.json +++ b/test/codesize/test_codesize_cxx_ctors2.json @@ -1,10 +1,10 @@ { - "a.out.js": 19600, - "a.out.js.gz": 8131, + "a.out.js": 19532, + "a.out.js.gz": 8087, "a.out.nodebug.wasm": 132264, "a.out.nodebug.wasm.gz": 49542, - "total": 151864, - "total_gz": 57673, + "total": 151796, + "total_gz": 57629, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_except.json b/test/codesize/test_codesize_cxx_except.json index db61ed9ebe4b6..2bca0cc06beda 100644 --- a/test/codesize/test_codesize_cxx_except.json +++ b/test/codesize/test_codesize_cxx_except.json @@ -1,10 +1,10 @@ { - "a.out.js": 23284, - "a.out.js.gz": 9122, + "a.out.js": 23216, + "a.out.js.gz": 9081, "a.out.nodebug.wasm": 172774, "a.out.nodebug.wasm.gz": 57405, - "total": 196058, - "total_gz": 66527, + "total": 195990, + "total_gz": 66486, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_except_wasm.json b/test/codesize/test_codesize_cxx_except_wasm.json index 1e2e36760cf93..95f60c9fefb97 100644 --- a/test/codesize/test_codesize_cxx_except_wasm.json +++ b/test/codesize/test_codesize_cxx_except_wasm.json @@ -1,10 +1,10 @@ { - "a.out.js": 19434, - "a.out.js.gz": 8068, + "a.out.js": 19366, + "a.out.js.gz": 8022, "a.out.nodebug.wasm": 148169, "a.out.nodebug.wasm.gz": 55285, - "total": 167603, - "total_gz": 63353, + "total": 167535, + "total_gz": 63307, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_except_wasm_legacy.json b/test/codesize/test_codesize_cxx_except_wasm_legacy.json index 5eb4a7cd30254..e60528b99e551 100644 --- a/test/codesize/test_codesize_cxx_except_wasm_legacy.json +++ b/test/codesize/test_codesize_cxx_except_wasm_legacy.json @@ -1,10 +1,10 @@ { - "a.out.js": 19508, - "a.out.js.gz": 8088, + "a.out.js": 19440, + "a.out.js.gz": 8042, "a.out.nodebug.wasm": 145975, "a.out.nodebug.wasm.gz": 54915, - "total": 165483, - "total_gz": 63003, + "total": 165415, + "total_gz": 62957, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_lto.json b/test/codesize/test_codesize_cxx_lto.json index 046b5526a0ac5..a633493a572a0 100644 --- a/test/codesize/test_codesize_cxx_lto.json +++ b/test/codesize/test_codesize_cxx_lto.json @@ -1,10 +1,10 @@ { - "a.out.js": 18970, - "a.out.js.gz": 7824, + "a.out.js": 18902, + "a.out.js.gz": 7782, "a.out.nodebug.wasm": 102076, "a.out.nodebug.wasm.gz": 39428, - "total": 121046, - "total_gz": 47252, + "total": 120978, + "total_gz": 47210, "sent": [ "a (emscripten_resize_heap)", "b (_setitimer_js)", diff --git a/test/codesize/test_codesize_cxx_mangle.json b/test/codesize/test_codesize_cxx_mangle.json index 804388291bc61..a8d46d650f1fc 100644 --- a/test/codesize/test_codesize_cxx_mangle.json +++ b/test/codesize/test_codesize_cxx_mangle.json @@ -1,10 +1,10 @@ { - "a.out.js": 23334, - "a.out.js.gz": 9141, + "a.out.js": 23266, + "a.out.js.gz": 9101, "a.out.nodebug.wasm": 239224, "a.out.nodebug.wasm.gz": 79795, - "total": 262558, - "total_gz": 88936, + "total": 262490, + "total_gz": 88896, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_noexcept.json b/test/codesize/test_codesize_cxx_noexcept.json index 7f5a19164e806..fcf3604bafcaf 100644 --- a/test/codesize/test_codesize_cxx_noexcept.json +++ b/test/codesize/test_codesize_cxx_noexcept.json @@ -1,10 +1,10 @@ { - "a.out.js": 19623, - "a.out.js.gz": 8144, + "a.out.js": 19555, + "a.out.js.gz": 8102, "a.out.nodebug.wasm": 134851, "a.out.nodebug.wasm.gz": 50712, - "total": 154474, - "total_gz": 58856, + "total": 154406, + "total_gz": 58814, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_files_js_fs.json b/test/codesize/test_codesize_files_js_fs.json index 310edda20ab31..5f456e69a275d 100644 --- a/test/codesize/test_codesize_files_js_fs.json +++ b/test/codesize/test_codesize_files_js_fs.json @@ -1,10 +1,10 @@ { - "a.out.js": 18241, - "a.out.js.gz": 7465, + "a.out.js": 18174, + "a.out.js.gz": 7430, "a.out.nodebug.wasm": 381, "a.out.nodebug.wasm.gz": 260, - "total": 18622, - "total_gz": 7725, + "total": 18555, + "total_gz": 7690, "sent": [ "a (fd_write)", "b (fd_read)", diff --git a/test/codesize/test_codesize_hello_O0.json b/test/codesize/test_codesize_hello_O0.json index ae1c3e5fc6f88..573d0c170e801 100644 --- a/test/codesize/test_codesize_hello_O0.json +++ b/test/codesize/test_codesize_hello_O0.json @@ -1,10 +1,10 @@ { - "a.out.js": 24225, - "a.out.js.gz": 8703, + "a.out.js": 24246, + "a.out.js.gz": 8709, "a.out.nodebug.wasm": 15138, "a.out.nodebug.wasm.gz": 7455, - "total": 39363, - "total_gz": 16158, + "total": 39384, + "total_gz": 16164, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_dylink.json b/test/codesize/test_codesize_hello_dylink.json index f63f7bf1e8f8f..cbd43f6d97db7 100644 --- a/test/codesize/test_codesize_hello_dylink.json +++ b/test/codesize/test_codesize_hello_dylink.json @@ -1,10 +1,10 @@ { - "a.out.js": 26663, - "a.out.js.gz": 11392, + "a.out.js": 26596, + "a.out.js.gz": 11356, "a.out.nodebug.wasm": 17730, "a.out.nodebug.wasm.gz": 8957, - "total": 44393, - "total_gz": 20349, + "total": 44326, + "total_gz": 20313, "sent": [ "__syscall_stat64", "emscripten_resize_heap", diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index 3ac0b6c464ebd..991888ecb51af 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 244840, + "a.out.js": 244769, "a.out.nodebug.wasm": 577863, - "total": 822703, + "total": 822632, "sent": [ "IMG_Init", "IMG_Load", diff --git a/test/codesize/test_codesize_minimal_O0.expected.js b/test/codesize/test_codesize_minimal_O0.expected.js index a836e1a0420a9..a8b7b2498254f 100644 --- a/test/codesize/test_codesize_minimal_O0.expected.js +++ b/test/codesize/test_codesize_minimal_O0.expected.js @@ -1277,7 +1277,6 @@ function checkIncomingModuleAPI() { ignoredModuleProp('freePreloadedMediaOnUse'); ignoredModuleProp('loadSplitModule'); ignoredModuleProp('locateFile'); - ignoredModuleProp('logReadFiles'); ignoredModuleProp('mainScriptUrlOrBlob'); ignoredModuleProp('mem'); ignoredModuleProp('monitorRunDependencies'); @@ -1309,6 +1308,7 @@ function checkIncomingModuleAPI() { ignoredModuleProp('wasmBinary'); ignoredModuleProp('websocket'); ignoredModuleProp('fetchSettings'); + ignoredModuleProp('logReadFiles'); } // Imports from the Wasm binary. diff --git a/test/codesize/test_unoptimized_code_size.json b/test/codesize/test_unoptimized_code_size.json index a4009eca4b79a..2d87875eef2fd 100644 --- a/test/codesize/test_unoptimized_code_size.json +++ b/test/codesize/test_unoptimized_code_size.json @@ -1,6 +1,6 @@ { - "hello_world.js": 56906, - "hello_world.js.gz": 17709, + "hello_world.js": 56925, + "hello_world.js.gz": 17717, "hello_world.wasm": 15138, "hello_world.wasm.gz": 7455, "no_asserts.js": 26576, @@ -8,9 +8,9 @@ "no_asserts.wasm": 12187, "no_asserts.wasm.gz": 5984, "strict.js": 54881, - "strict.js.gz": 17045, + "strict.js.gz": 17046, "strict.wasm": 15138, "strict.wasm.gz": 7450, - "total": 180826, - "total_gz": 64524 + "total": 180845, + "total_gz": 64533 } diff --git a/test/test_other.py b/test/test_other.py index 4be195f4f9d4f..4af97a04cd925 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -15341,7 +15341,7 @@ def test_executable_requires_node(self): def test_logReadFiles(self): create_file('test.txt', 'hello') - self.cflags += ['--preload-file=test.txt'] + self.cflags += ['--preload-file=test.txt', '-sINCOMING_MODULE_JS_API=logReadFiles'] output = self.do_runf('checksummer.c', args=['test.txt']) self.assertNotContained('read file:', output) diff --git a/tools/cmdline.py b/tools/cmdline.py index 722867546ac50..d3c674861f272 100644 --- a/tools/cmdline.py +++ b/tools/cmdline.py @@ -41,6 +41,7 @@ # default set. EXTRA_INCOMING_JS_API = [ 'fetchSettings', + 'logReadFiles', ] logger = logging.getLogger('args')