diff options
-rw-r--r-- | emscripten-version.txt | 2 | ||||
-rw-r--r-- | src/library.js | 6 | ||||
-rw-r--r-- | system/lib/libcxxabi/src/exception.cpp | 2 | ||||
-rw-r--r-- | system/lib/libcxxabi/symbols | 1 | ||||
-rw-r--r-- | tests/test_core.py | 41 | ||||
-rw-r--r-- | tools/system_libs.py | 3 |
6 files changed, 47 insertions, 8 deletions
diff --git a/emscripten-version.txt b/emscripten-version.txt index 1825e0c3..6318f232 100644 --- a/emscripten-version.txt +++ b/emscripten-version.txt @@ -1,2 +1,2 @@ -1.21.2 +1.21.3 diff --git a/src/library.js b/src/library.js index 5a420cc3..1efc936c 100644 --- a/src/library.js +++ b/src/library.js @@ -4092,12 +4092,6 @@ LibraryManager.library = { } }, - // Destructors for std::exception since we don't have them implemented in libcxx as we aren't using libcxxabi. - // These are also needed for the dlmalloc tests. - _ZNSt9exceptionD0Ev: function() {}, - _ZNSt9exceptionD1Ev: function() {}, - _ZNSt9exceptionD2Ev: function() {}, - _ZNKSt9exception4whatEv__deps: ['malloc'], _ZNKSt9exception4whatEv: function() { if (!__ZNKSt9exception4whatEv.buffer) { diff --git a/system/lib/libcxxabi/src/exception.cpp b/system/lib/libcxxabi/src/exception.cpp index c47a9b76..c69db02d 100644 --- a/system/lib/libcxxabi/src/exception.cpp +++ b/system/lib/libcxxabi/src/exception.cpp @@ -25,6 +25,7 @@ const char* exception::what() const _NOEXCEPT return "std::exception"; } +#ifndef __EMSCRIPTEN__ // bad_exception bad_exception::~bad_exception() _NOEXCEPT @@ -35,6 +36,7 @@ const char* bad_exception::what() const _NOEXCEPT { return "std::bad_exception"; } +#endif } // std diff --git a/system/lib/libcxxabi/symbols b/system/lib/libcxxabi/symbols index f2925e4c..13d79901 100644 --- a/system/lib/libcxxabi/symbols +++ b/system/lib/libcxxabi/symbols @@ -235,3 +235,4 @@ D _ZTVSt8bad_cast D _ZTVSt9type_info T __dynamic_cast + T _ZNSt9exceptionD1Ev diff --git a/tests/test_core.py b/tests/test_core.py index af26472a..a4017660 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1321,6 +1321,47 @@ too many setjmps in a function call, build with a higher value for MAX_SETJMPS'' src, output = (test_path + s for s in ('.in', '.out')) self.do_run_from_file(src, output) + def test_exceptions_3(self): + if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly') + if self.run_name == 'asm2x86': return self.skip('TODO') + + Settings.DISABLE_EXCEPTION_CATCHING = 0 + + src = r''' +#include <iostream> +#include <stdexcept> + +int main(int argc, char **argv) +{ + if (argc != 2) { + std::cout << "need an arg" << std::endl; + return 1; + } + + int arg = argv[1][0] - '0'; + try { + if (arg == 0) throw "a c string"; + if (arg == 1) throw std::exception(); + if (arg == 2) throw std::runtime_error("Hello"); + } catch(const char * ex) { + std::cout << "Caught C string: " << ex << std::endl; + } catch(const std::exception &ex) { + std::cout << "Caught exception: " << ex.what() << std::endl; + } catch(...) { + std::cout << "Caught something else" << std::endl; + } + + std::cout << "Done.\n"; +} +''' + + print '0' + self.do_run(src, 'Caught C string: a c string\nDone.', ['0']) + print '1' + self.do_run(src, 'Caught exception: std::exception\nDone.', ['1'], no_build=True) + print '2' + self.do_run(src, 'Caught exception: Hello\nDone.', ['2'], no_build=True) + def test_exceptions_white_list(self): Settings.DISABLE_EXCEPTION_CATCHING = 2 Settings.EXCEPTION_CATCHING_WHITELIST = ["__Z12somefunctionv"] diff --git a/tools/system_libs.py b/tools/system_libs.py index 8c149a64..9e904b80 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -420,8 +420,9 @@ def calculate(temp_files, in_temp, stdout_, stderr_): def create_libcxxabi(): logging.debug('building libcxxabi for cache') libcxxabi_files = [ + 'exception.cpp', 'typeinfo.cpp', - 'private_typeinfo.cpp' + 'private_typeinfo.cpp', ] return build_libcxx(os.path.join('system', 'lib', 'libcxxabi', 'src'), 'libcxxabi.bc', libcxxabi_files) |