Skip to content

Commit 2781c34

Browse files
committed
Error out on missing EXPORTED_RUNTIME_METHODS.
1 parent 5b5497f commit 2781c34

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

ChangeLog.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ See docs/process.md for more on how version tagging works.
4343
example, `-sEXPORTED_RUNTIME_METHODS=HEAP8,HEAPU32` (if you need `HEAP8` and
4444
`HEAPU32`). (#24079)
4545
- libjpeg port updated from 9c to 9f. (#24085)
46+
- Missing exports in EXPORTED_RUNTIME_METHODS will now error instead of warn.
4647

4748
4.0.6 - 03/26/25
4849
----------------

src/modules.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
isJsOnlySymbol,
1414
error,
1515
readFile,
16-
warn,
1716
pushCurrentFile,
1817
popCurrentFile,
1918
printErr,
@@ -512,11 +511,11 @@ function exportRuntimeSymbols() {
512511
}
513512
}
514513

515-
// check all exported things exist, warn about typos
514+
// check all exported things exist, error when missing
516515
runtimeElementsSet = new Set(runtimeElements);
517516
for (const name of EXPORTED_RUNTIME_METHODS) {
518517
if (!runtimeElementsSet.has(name)) {
519-
warn(`invalid item in EXPORTED_RUNTIME_METHODS: ${name}`);
518+
error(`undefined exported symbol: "${name}" in EXPORTED_RUNTIME_METHODS`);
520519
}
521520
}
522521

test/test_other.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2698,6 +2698,11 @@ def test_undefined_exported_function(self, outfile):
26982698
cmd += ['-Wno-undefined']
26992699
self.run_process(cmd)
27002700

2701+
def test_undefined_exported_runtime_method(self):
2702+
# Adding a missing symbol to EXPORTED_RUNTIME_METHODS should cause a failure
2703+
err = self.expect_fail([EMCC, '-sEXPORTED_RUNTIME_METHODS=foobar', test_file('hello_world.c')])
2704+
self.assertContained('undefined exported symbol: "foobar" in EXPORTED_RUNTIME_METHODS', err)
2705+
27012706
@parameterized({
27022707
'': ('out.js',),
27032708
'standalone': ('out.wasm',)
@@ -14528,7 +14533,7 @@ def test_legacy_runtime(self):
1452814533
self.clear_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE')
1452914534
for opt in ('-O0', '-O3'):
1453014535
err = self.expect_fail([EMCC, test_file('other/test_legacy_runtime.c'), opt] + self.get_emcc_args())
14531-
self.assertContained('invalid item in EXPORTED_RUNTIME_METHODS: allocate', err)
14536+
self.assertContained('undefined exported symbol: "allocate" in EXPORTED_RUNTIME_METHODS', err)
1453214537

1453314538
def test_fetch_settings(self):
1453414539
create_file('pre.js', '''

0 commit comments

Comments
 (0)