Skip to content

Commit 5b95aa7

Browse files
authored
Fix unresolved symbol in standalone debug build. (#24680)
Ensure WASM binaries, produced in standalone debug mode, does not require `__throw_exception_with_stack_trace` function. In non-standalone mode it implemented in JS.
1 parent 4182f94 commit 5b95aa7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

system/lib/standalone/standalone.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "lock.h"
2727
#include "emscripten_internal.h"
28+
#include "unwind.h"
2829

2930
/*
3031
* WASI support code. These are compiled with the program, and call out
@@ -308,3 +309,7 @@ weak void _emscripten_get_progname(char* buf, int length) {
308309
}
309310

310311
weak void _emscripten_runtime_keepalive_clear() {}
312+
313+
void __throw_exception_with_stack_trace(_Unwind_Exception* exception_object) {
314+
_Unwind_RaiseException(exception_object);
315+
}

test/test_other.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15182,6 +15182,15 @@ def test_standalone_settings(self):
1518215182
err = self.expect_fail(base_cmd + ['-sMEMORY_GROWTH_LINEAR_STEP=1mb'])
1518315183
self.assertContained('error: MEMORY_GROWTH_LINEAR_STEP is not compatible with STANDALONE_WASM', err)
1518415184

15185+
def test_standalone_imports(self):
15186+
# Ensure standalone binary will not have __throw_exception_with_stack_trace
15187+
# debug helper dependency, caused by exception-related code.
15188+
src_path = test_file('core/test_exceptions.cpp')
15189+
self.run_process([EMXX, '-O0', '-fwasm-exceptions', '-sSTANDALONE_WASM', src_path])
15190+
imports = self.parse_wasm('a.out.wasm')[0]
15191+
for name in imports:
15192+
self.assertTrue(name.startswith('wasi_'), 'Unexpected import %s' % name)
15193+
1518515194
@is_slow_test
1518615195
def test_googletest(self):
1518715196
# TODO(sbc): Should we package gtest as an emscripten "port"? I guess we should if

0 commit comments

Comments
 (0)