Skip to content

Error out on missing EXPORTED_RUNTIME_METHODS. #24104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ See docs/process.md for more on how version tagging works.
example, `-sEXPORTED_RUNTIME_METHODS=HEAP8,HEAPU32` (if you need `HEAP8` and
`HEAPU32`). (#24079)
- libjpeg port updated from 9c to 9f. (#24085)
- Missing exports in EXPORTED_RUNTIME_METHODS will now error instead of warn.

4.0.6 - 03/26/25
----------------
Expand Down
5 changes: 2 additions & 3 deletions src/modules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
isJsOnlySymbol,
error,
readFile,
warn,
pushCurrentFile,
popCurrentFile,
printErr,
Expand Down Expand Up @@ -512,11 +511,11 @@ function exportRuntimeSymbols() {
}
}

// check all exported things exist, warn about typos
// check all exported things exist, error when missing
runtimeElementsSet = new Set(runtimeElements);
for (const name of EXPORTED_RUNTIME_METHODS) {
if (!runtimeElementsSet.has(name)) {
warn(`invalid item in EXPORTED_RUNTIME_METHODS: ${name}`);
error(`undefined exported symbol: "${name}" in EXPORTED_RUNTIME_METHODS`);
}
}

Expand Down
7 changes: 6 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,11 @@ def test_undefined_exported_function(self, outfile):
cmd += ['-Wno-undefined']
self.run_process(cmd)

def test_undefined_exported_runtime_method(self):
# Adding a missing symbol to EXPORTED_RUNTIME_METHODS should cause a failure
err = self.expect_fail([EMCC, '-sEXPORTED_RUNTIME_METHODS=foobar', test_file('hello_world.c')])
self.assertContained('undefined exported symbol: "foobar" in EXPORTED_RUNTIME_METHODS', err)

@parameterized({
'': ('out.js',),
'standalone': ('out.wasm',)
Expand Down Expand Up @@ -14528,7 +14533,7 @@ def test_legacy_runtime(self):
self.clear_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE')
for opt in ('-O0', '-O3'):
err = self.expect_fail([EMCC, test_file('other/test_legacy_runtime.c'), opt] + self.get_emcc_args())
self.assertContained('invalid item in EXPORTED_RUNTIME_METHODS: allocate', err)
self.assertContained('undefined exported symbol: "allocate" in EXPORTED_RUNTIME_METHODS', err)

def test_fetch_settings(self):
create_file('pre.js', '''
Expand Down