Skip to content

Commit 92f653e

Browse files
committed
build enough of libcxxabi to support bad_typeid without undefined symbols; 1.21.5; fixes #2547
1 parent 7bb5b82 commit 92f653e

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

emscripten-version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.21.4
1+
1.21.5
22

tests/test_core.py

+28
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,34 @@ def test_exceptions_alias(self):
14771477
src, output = (test_path + s for s in ('.c', '.out'))
14781478
self.do_run_from_file(src, output)
14791479

1480+
def test_bad_typeid(self):
1481+
if self.emcc_args is None: return self.skip('requires emcc')
1482+
1483+
Settings.ERROR_ON_UNDEFINED_SYMBOLS = 1
1484+
Settings.DISABLE_EXCEPTION_CATCHING = 0
1485+
1486+
self.do_run(r'''
1487+
// exception example
1488+
#include <iostream> // std::cerr
1489+
#include <typeinfo> // operator typeid
1490+
#include <exception> // std::exception
1491+
1492+
class Polymorphic {virtual void member(){}};
1493+
1494+
int main () {
1495+
try
1496+
{
1497+
Polymorphic * pb = 0;
1498+
typeid(*pb); // throws a bad_typeid exception
1499+
}
1500+
catch (std::exception& e)
1501+
{
1502+
std::cerr << "exception caught: " << e.what() << '\n';
1503+
}
1504+
return 0;
1505+
}
1506+
''', 'exception caught: std::bad_typeid')
1507+
14801508
def test_exit_stack(self):
14811509
if self.emcc_args is None: return self.skip('requires emcc')
14821510
if Settings.ASM_JS: return self.skip('uses report_stack without exporting')

tools/system_libs.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def read_symbols(path, exclude=None):
2727
symbols = filter(lambda symbol: symbol not in exclude, symbols)
2828
return set(symbols)
2929

30-
lib_opts = ['-O2']
30+
lib_opts = ['-O2', '-I' + shared.path_from_root('system', 'lib', 'libcxxabi', 'include')]
3131

3232
# XXX We also need to add libc symbols that use malloc, for example strdup. It's very rare to use just them and not
3333
# a normal malloc symbol (like free, after calling strdup), so we haven't hit this yet, but it is possible.
@@ -421,7 +421,15 @@ def apply_libcxx(need):
421421
def create_libcxxabi():
422422
logging.debug('building libcxxabi for cache')
423423
libcxxabi_files = [
424+
'abort_message.cpp',
425+
'cxa_aux_runtime.cpp',
426+
'cxa_default_handlers.cpp',
427+
'cxa_demangle.cpp',
428+
'cxa_exception_storage.cpp',
429+
'cxa_new_delete.cpp',
430+
'cxa_handlers.cpp',
424431
'exception.cpp',
432+
'stdexcept.cpp',
425433
'typeinfo.cpp',
426434
'private_typeinfo.cpp',
427435
]

0 commit comments

Comments
 (0)