Skip to content

Commit b4b6b8f

Browse files
authored
Always warn at link time on bad EXPORTED_RUNTIME_METHODS (#18567)
I have no idea why this warning was only present when ASSERTIONS were enabled.
1 parent 373b282 commit b4b6b8f

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/modules.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ function exportRuntime() {
421421

422422
// Add JS library elements such as FS, GL, ENV, etc. These are prefixed with
423423
// '$ which indicates they are JS methods.
424-
const runtimeElementsSet = new Set(runtimeElements);
424+
let runtimeElementsSet = new Set(runtimeElements);
425425
for (const ident in LibraryManager.library) {
426426
if (ident[0] === '$' && !isJsLibraryConfigIdentifier(ident) && !isInternalSymbol(ident)) {
427427
const jsname = ident.substr(1);
@@ -430,16 +430,16 @@ function exportRuntime() {
430430
}
431431
}
432432

433-
let unexportedStubs = '';
434-
if (ASSERTIONS) {
435-
// check all exported things exist, warn about typos
436-
const runtimeElementsSet = new Set(runtimeElements);
437-
for (const name of EXPORTED_RUNTIME_METHODS_SET) {
438-
if (!runtimeElementsSet.has(name)) {
439-
warn(`invalid item in EXPORTED_RUNTIME_METHODS: ${name}`);
440-
}
433+
// check all exported things exist, warn about typos
434+
runtimeElementsSet = new Set(runtimeElements);
435+
for (const name of EXPORTED_RUNTIME_METHODS_SET) {
436+
if (!runtimeElementsSet.has(name)) {
437+
warn(`invalid item in EXPORTED_RUNTIME_METHODS: ${name}`);
441438
}
439+
}
442440

441+
let unexportedStubs = '';
442+
if (ASSERTIONS) {
443443
const unexported = [];
444444
for (const name of runtimeElements) {
445445
if (!EXPORTED_RUNTIME_METHODS_SET.has(name)) {

test/test_other.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12414,8 +12414,9 @@ def test_legacy_runtime(self):
1241412414
# In strict mode the library function is not even available, so we get a build time error
1241512415
self.set_setting('STRICT')
1241612416
self.clear_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE')
12417-
err = self.expect_fail([EMCC, test_file('other/test_legacy_runtime.c')] + self.get_emcc_args())
12418-
self.assertContained('warning: invalid item in EXPORTED_RUNTIME_METHODS: allocate', err)
12417+
for opt in ['-O0', '-O3']:
12418+
err = self.expect_fail([EMCC, test_file('other/test_legacy_runtime.c'), opt] + self.get_emcc_args())
12419+
self.assertContained('warning: invalid item in EXPORTED_RUNTIME_METHODS: allocate', err)
1241912420

1242012421
def test_fetch_settings(self):
1242112422
create_file('pre.js', '''

0 commit comments

Comments
 (0)