diff --git a/include/__config b/include/__config index 3a438e8..6a7bda1 100644 --- a/include/__config +++ b/include/__config @@ -138,7 +138,12 @@ // Previously libc++ used "unsigned int" exclusively. # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION // Unstable attempt to provide a more optimized std::function -# define _LIBCPP_ABI_OPTIMIZED_FUNCTION +# ifdef __EMSCRIPTEN__ +// XXX EMSCRIPTEN https://github.com/emscripten-core/emscripten/issues/11022 +// # define _LIBCPP_ABI_OPTIMIZED_FUNCTION +# else +# define _LIBCPP_ABI_OPTIMIZED_FUNCTION +# endif // All the regex constants must be distinct and nonzero. # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO // Re-worked external template instantiations for std::string with a focus on diff --git a/include/typeinfo b/include/typeinfo index dafc7b8..d4e5e4e 100644 --- a/include/typeinfo +++ b/include/typeinfo @@ -97,7 +97,13 @@ public: size_t hash_code() const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT { +# ifdef __EMSCRIPTEN__ + // XXX Emscripten: adding `always_inline` fixes + // https://github.com/emscripten-core/emscripten/issues/13330 + __attribute__((always_inline)) +# endif + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool + operator==(const type_info& __arg) const _NOEXCEPT { // When evaluated in a constant expression, both type infos simply can't come // from different translation units, so it is sufficient to compare their addresses. if (__libcpp_is_constant_evaluated()) { diff --git a/src/filesystem/operations.cpp b/src/filesystem/operations.cpp index 62bb248..fa31f05 100644 --- a/src/filesystem/operations.cpp +++ b/src/filesystem/operations.cpp @@ -37,7 +37,7 @@ #include /* values for fchmodat */ #include -#if __has_include() +#if __has_include() && !defined(__EMSCRIPTEN__) # include # define _LIBCPP_FILESYSTEM_USE_SENDFILE #elif defined(__APPLE__) || __has_include() diff --git a/src/new.cpp b/src/new.cpp index b0c7316..7f1cc67 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -18,7 +18,13 @@ // The code below is copied as-is into libc++abi's libcxxabi/src/stdlib_new_delete.cpp // file. The version in this file is the canonical one. -inline void __throw_bad_alloc_shim() { std::__throw_bad_alloc(); } +inline void __throw_bad_alloc_shim() { +# ifdef __EMSCRIPTEN__ + abort(); +#else + std::__throw_bad_alloc(); +#endif +} # define _LIBCPP_ASSERT_SHIM(expr, str) _LIBCPP_ASSERT(expr, str) diff --git a/src/support/runtime/exception_fallback.ipp b/src/support/runtime/exception_fallback.ipp index 18ff4b8..d54a9a5 100644 --- a/src/support/runtime/exception_fallback.ipp +++ b/src/support/runtime/exception_fallback.ipp @@ -33,6 +33,7 @@ terminate_handler set_terminate(terminate_handler func) noexcept { terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); } +#ifndef __EMSCRIPTEN__ // We provide this in JS _LIBCPP_NORETURN void terminate() noexcept { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { @@ -49,7 +50,9 @@ _LIBCPP_NORETURN void terminate() noexcept { } #endif // _LIBCPP_HAS_NO_EXCEPTIONS } +#endif // !__EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } int uncaught_exceptions() noexcept { @@ -57,6 +60,7 @@ int uncaught_exceptions() noexcept { fprintf(stderr, "uncaught_exceptions not yet implemented\n"); ::abort(); } +#endif // !__EMSCRIPTEN__ exception::~exception() noexcept {}