Skip to content

Commit eda083a

Browse files
authored
Use JS library dependency system for warnOnce. NFC (#24702)
Both `warnOnce` and these string functions are now part of the JS library and so they can use the normal JS dependency system.
1 parent b490c44 commit eda083a

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

src/lib/libstrings.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ addToLibrary({
3939
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
4040
* @return {string}
4141
*/`,
42-
$UTF8ArrayToString__deps: ['$UTF8Decoder', '$findStringEnd'],
42+
$UTF8ArrayToString__deps: [
43+
'$UTF8Decoder', '$findStringEnd',
44+
#if ASSERTIONS
45+
'$warnOnce',
46+
#endif
47+
],
4348
$UTF8ArrayToString: (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
4449
#if CAN_ADDRESS_2GB
4550
idx >>>= 0;
@@ -142,6 +147,9 @@ addToLibrary({
142147
* terminator.
143148
* @return {number} The number of bytes written, EXCLUDING the null terminator.
144149
*/
150+
#if ASSERTIONS
151+
$stringToUTF8Array__deps: ['$warnOnce'],
152+
#endif
145153
$stringToUTF8Array: (str, heap, outIdx, maxBytesToWrite) => {
146154
#if CAN_ADDRESS_2GB
147155
outIdx >>>= 0;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
53970
1+
53973
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
52020
1+
52023

tools/link.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,15 +1512,6 @@ def limit_incoming_module_api():
15121512
settings.MINIFY_WASM_IMPORTS_AND_EXPORTS = 1
15131513
settings.MINIFY_WASM_IMPORTED_MODULES = 1
15141514

1515-
if settings.MINIMAL_RUNTIME and settings.ASSERTIONS:
1516-
# In ASSERTIONS-builds, functions UTF8ArrayToString() and stringToUTF8Array()
1517-
# (which are not JS library functions), both use warnOnce(), which in
1518-
# MINIMAL_RUNTIME is a JS library function, so explicitly have to mark
1519-
# dependency to warnOnce() in that case. If string functions are turned to
1520-
# library functions in the future, then JS dependency tracking can be
1521-
# used and this special directive can be dropped.
1522-
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$warnOnce']
1523-
15241515
if settings.MODULARIZE and not (settings.EXPORT_ES6 and not settings.SINGLE_FILE) and \
15251516
settings.EXPORT_NAME == 'Module' and options.oformat == OFormat.HTML and \
15261517
(options.shell_path == DEFAULT_SHELL_HTML or options.shell_path == utils.path_from_root('src/shell_minimal.html')):

0 commit comments

Comments
 (0)