diff options
author | dtorilov <dtorilov@yandex-team.com> | 2023-05-24 16:49:46 +0300 |
---|---|---|
committer | dtorilov <dtorilov@yandex-team.com> | 2023-05-24 16:49:46 +0300 |
commit | b7adcd4bdb1fcd9a79dc74c411e9812ebca574e4 (patch) | |
tree | ba95aa8c9cc988009baa060076db6c17488fc035 | |
parent | 5284e74c027f3cf50fc29ceb5fd3d43b4729921b (diff) | |
download | ydb-b7adcd4bdb1fcd9a79dc74c411e9812ebca574e4.tar.gz |
YT-19142: Add emscripten patches to libcxx
4 files changed, 23 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config index dd3640f079..83c45fbe43 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config +++ b/contrib/libs/cxxsupp/libcxx/include/__config @@ -117,7 +117,12 @@ // Previously libc++ used "unsigned int" exclusively. # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION // Unstable attempt to provide a more optimized std::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 // Use raw pointers, not wrapped ones, for std::span's iterator type. diff --git a/contrib/libs/cxxsupp/libcxx/include/typeinfo b/contrib/libs/cxxsupp/libcxx/include/typeinfo index 39680bb8e4..7efe626da6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/typeinfo +++ b/contrib/libs/cxxsupp/libcxx/include/typeinfo @@ -106,6 +106,11 @@ public: size_t hash_code() const _NOEXCEPT; +#ifdef __EMSCRIPTEN__ + // XXX Emscripten: adding `always_inline` fixes + // https://github.com/emscripten-core/emscripten/issues/13330 + __attribute__((always_inline)) +#endif _LIBCPP_INLINE_VISIBILITY bool operator==(const type_info& __arg) const _NOEXCEPT { return __compare(__arg) == 0; diff --git a/contrib/libs/cxxsupp/libcxx/src/new.cpp b/contrib/libs/cxxsupp/libcxx/src/new.cpp index b7e2828158..136084809d 100644 --- a/contrib/libs/cxxsupp/libcxx/src/new.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/new.cpp @@ -73,8 +73,17 @@ operator new(std::size_t size) _THROW_BAD_ALLOC #ifndef _LIBCPP_NO_EXCEPTIONS throw std::bad_alloc(); #else +#ifdef __EMSCRIPTEN__ + // Abort here so that when exceptions are disabled, we do not just + // return 0 when malloc returns 0. + // We could also do this with set_new_handler, but that adds a + // global constructor and a table entry, overhead that we can avoid + // by doing it this way. + abort(); +#else break; #endif +#endif } return p; } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp index a45f11eb9f..ebdca7e5ee 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp @@ -48,6 +48,7 @@ get_terminate() noexcept return __libcpp_atomic_load(&__terminate_handler); } +#ifndef __EMSCRIPTEN__ // We provide this in JS _LIBCPP_NORETURN void terminate() noexcept @@ -70,7 +71,9 @@ terminate() noexcept } #endif // _LIBCPP_NO_EXCEPTIONS } +#endif // !__EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } int uncaught_exceptions() noexcept @@ -79,6 +82,7 @@ int uncaught_exceptions() noexcept fprintf(stderr, "uncaught_exceptions not yet implemented\n"); ::abort(); } +#endif // !__EMSCRIPTEN__ exception::~exception() noexcept |