diff options
-rwxr-xr-x | emcc | 18 | ||||
-rw-r--r-- | src/library.js | 22 | ||||
-rw-r--r-- | system/lib/libcxxabi/Makefile | 41 | ||||
-rwxr-xr-x | tests/runner.py | 2 |
4 files changed, 39 insertions, 44 deletions
@@ -533,10 +533,24 @@ try: libcxx_symbols = filter(lambda symbol: symbol not in dlmalloc_symbols, libcxx_symbols) libcxx_symbols = set(libcxx_symbols) + # libcxxabi - just for dynamic_cast for now + def create_libcxxabi(): + if DEBUG: print >> sys.stderr, 'emcc: building libcxxabi for cache' + shared.Building.build_library('libcxxabi', shared.EMSCRIPTEN_TEMP_DIR, shared.EMSCRIPTEN_TEMP_DIR, ['libcxxabi.bc'], configure=None, copy_project=True, source_dir=shared.path_from_root('system', 'lib', 'libcxxabi')) + return os.path.join(shared.EMSCRIPTEN_TEMP_DIR, 'libcxxabi', 'libcxxabi.bc') + def fix_libcxxabi(): + assert shared.Settings.QUANTUM_SIZE == 4, 'We do not support libc++abi with QUANTUM_SIZE == 1' + print >> sys.stderr, 'emcc: warning: using libcxxabi, this may need CORRECT_* options' + #shared.Settings.CORRECT_SIGNS = shared.Settings.CORRECT_OVERFLOWS = shared.Settings.CORRECT_ROUNDINGS = 1 + libcxxabi_symbols = map(lambda line: line.strip().split(' ')[1], open(shared.path_from_root('system', 'lib', 'libcxxabi', 'symbols')).readlines()) + libcxxabi_symbols = filter(lambda symbol: symbol not in dlmalloc_symbols, libcxxabi_symbols) + libcxxabi_symbols = set(libcxxabi_symbols) + force = False # If we have libcxx, we must force inclusion of dlmalloc, since libcxx uses new internally. Note: this is kind of hacky - for name, create, fix, library_symbols in [('libcxx', create_libcxx, fix_libcxx, libcxx_symbols), - ('dlmalloc', create_dlmalloc, fix_dlmalloc, dlmalloc_symbols)]: + for name, create, fix, library_symbols in [('libcxx', create_libcxx, fix_libcxx, libcxx_symbols), + ('libcxxabi', create_libcxxabi, fix_libcxxabi, libcxxabi_symbols), + ('dlmalloc', create_dlmalloc, fix_dlmalloc, dlmalloc_symbols)]: need = [] has = [] for temp_file in temp_files: diff --git a/src/library.js b/src/library.js index cda318d7..56370b79 100644 --- a/src/library.js +++ b/src/library.js @@ -4374,28 +4374,6 @@ LibraryManager.library = { __cxa_guard_release: function() {}, __cxa_guard_abort: function() {}, - _ZTVN10__cxxabiv119__pointer_type_infoE: [0], // is a pointer - _ZTVN10__cxxabiv117__class_type_infoE: [1], // no inherited classes - _ZTVN10__cxxabiv120__si_class_type_infoE: [2], // yes inherited classes - - __dynamic_cast: function(ptr, knownTI, attemptedTI, idunno) { - var ptrTV = {{{ makeGetValue('ptr', '0', '*') }}}; - var count = {{{ makeGetValue('ptrTV', '0', '*') }}}; - ptrTV -= {{{ Runtime.QUANTUM_SIZE }}}; - var TI = {{{ makeGetValue('ptrTV', '0', '*') }}}; - do { - if (TI == attemptedTI) return ptr; - // Go to parent class - var type_infoAddr = {{{ makeGetValue('TI', '0', '*') }}} - {{{ Runtime.QUANTUM_SIZE*2 }}}; - var type_info = {{{ makeGetValue('type_infoAddr', '0', '*') }}}; - if (type_info == 1) return 0; // no parent class - var TIAddr = TI + {{{ Runtime.QUANTUM_SIZE*2 }}}; - var TI = {{{ makeGetValue('TIAddr', '0', '*') }}}; - } while (1); - - return 0; - }, - // Exceptions __cxa_allocate_exception: function(size) { return _malloc(size); diff --git a/system/lib/libcxxabi/Makefile b/system/lib/libcxxabi/Makefile index 86d88976..62654ef2 100644 --- a/system/lib/libcxxabi/Makefile +++ b/system/lib/libcxxabi/Makefile @@ -1,27 +1,28 @@ OBJECTS = \ - cxa_vector.bc \ - private_typeinfo.bc \ - cxa_virtual.bc \ - temporary.bc \ - cxa_guard.bc \ - cxa_unexpected.bc \ - cxa_exception.bc \ - cxa_aux_runtime.bc \ - exception.bc \ - stdexcept.bc \ - abort_message.bc \ - cxa_personality.bc \ - cxa_new_delete.bc \ - cxa_handlers.bc \ - cxa_exception_storage.bc \ - typeinfo.bc \ - cxa_demangle.bc + src/private_typeinfo.bc \ + $(NULL) + #src/cxa_vector.bc \ + #src/cxa_virtual.bc \ + #src/temporary.bc \ + #src/cxa_guard.bc \ + #src/cxa_unexpected.bc \ + #src/cxa_exception.bc \ + #src/cxa_aux_runtime.bc \ + #src/exception.bc \ + #src/stdexcept.bc \ + #src/abort_message.bc \ + #src/cxa_personality.bc \ + #src/cxa_new_delete.bc \ + #src/cxa_handlers.bc \ + #src/cxa_exception_storage.bc \ + #src/typeinfo.bc \ + #src/cxa_demangle.bc -all: libcxx.bc +all: libcxxabi.bc %.bc: %.cpp - $(CXX) $< -o $@ + $(CXX) -I./include $< -o $@ -libcxx.bc: $(OBJECTS) +libcxxabi.bc: $(OBJECTS) $(CXX) $(OBJECTS) -o libcxxabi.bc diff --git a/tests/runner.py b/tests/runner.py index 92ca7f48..428c1e98 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -1674,6 +1674,8 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv): self.do_run(src, '*11,74,32,1012*\n*11*\n*22*') def test_dynamic_cast(self): + if self.emcc_args is None: return self.skip('need libcxxabi') + src = r''' #include <stdio.h> |