Skip to content

Commit fdb1656

Browse files
authored
Improve error message for including missing library symbols (#17856)
Fixes #17839
1 parent c5110bf commit fdb1656

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/runtime_debug.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ function missingLibrarySymbol(sym) {
4545
// Can't `abort()` here because it would break code that does runtime
4646
// checks. e.g. `if (typeof SDL === 'undefined')`.
4747
var msg = '`' + sym + '` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line';
48+
// DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
49+
// library.js, which means $name for a JS name with no prefix, or name
50+
// for a JS name like _name.
51+
var librarySymbol = sym;
52+
if (!librarySymbol.startsWith('_')) {
53+
librarySymbol = '$' + sym;
54+
}
55+
msg += " (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=" + librarySymbol + ")";
4856
if (isExportedByForceFilesystem(sym)) {
4957
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
5058
}

test/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7145,7 +7145,7 @@ def test(expected, args=None, assert_returncode=0):
71457145

71467146
# When assertions are enabled direct and indirect usage both abort with a useful error message.
71477147
not_exported = "Aborted('ALLOC_STACK' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ))"
7148-
not_included = "`ALLOC_STACK` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line"
7148+
not_included = "`ALLOC_STACK` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$ALLOC_STACK)"
71497149
self.set_setting('ASSERTIONS')
71507150
test(not_exported, assert_returncode=NON_ZERO)
71517151
test(not_included, args=['-DDIRECT'])

0 commit comments

Comments
 (0)