diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-02-27 19:33:07 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-02-27 19:43:16 +0300 |
commit | 7963851a89d1f2f2a561f7f622e420eec415a7a8 (patch) | |
tree | 2084da676cd56badf501dde8dac3675963f03506 /contrib/libs | |
parent | 940b52dd26fb783e71cf0fb395151405b7c7213b (diff) | |
download | ydb-7963851a89d1f2f2a561f7f622e420eec415a7a8.tar.gz |
Intermediate changes
commit_hash:e649af5b15a4c6462b4682d86c36fc91cf1065db
Diffstat (limited to 'contrib/libs')
12 files changed, 657 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxxrt/.yandex_meta/__init__.py b/contrib/libs/cxxsupp/libcxxrt/.yandex_meta/__init__.py new file mode 100644 index 0000000000..52e24af9ef --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/.yandex_meta/__init__.py @@ -0,0 +1,39 @@ +import os + +from devtools.yamaker.modules import Switch, Linkable +from devtools.yamaker.project import CMakeNinjaNixProject + + +def post_install(self): + os.unlink(self.dstdir + "/unwind-itanium.h") + os.unlink(self.dstdir + "/libelftc_dem_gnu3.c") + with self.yamakes["."] as libcxxrt: + # Do not create peerdir loop from libcxx and libcxxrt + libcxxrt.NO_RUNTIME = True + libcxxrt.SRCS.remove("libelftc_dem_gnu3.c") + libcxxrt.before( + "SRCS", + Switch({"SANITIZER_TYPE == undefined OR FUZZING": Linkable(NO_SANITIZE=True, NO_SANITIZE_COVERAGE=True)}), + ) + libcxxrt.CXXFLAGS = ["-nostdinc++"] + libcxxrt.PEERDIR |= { + "contrib/libs/libunwind", + "library/cpp/sanitizer/include", + } + + +libcxxrt = CMakeNinjaNixProject( + arcdir="contrib/libs/cxxsupp/libcxxrt", + nixattr="libcxxrt", + owners=["g:cpp-committee", "g:cpp-contrib"], + install_subdir="src", + inclink={"include": {"cxxabi.h"}}, + keep_paths=[ + "unwind.h", + ], + post_install=post_install, +) + +libcxxrt.copy_top_sources_except |= { + "INTERFACE_LINK_LIBRARIES.txt", +} diff --git a/contrib/libs/cxxsupp/libcxxrt/.yandex_meta/override.nix b/contrib/libs/cxxsupp/libcxxrt/.yandex_meta/override.nix new file mode 100644 index 0000000000..d80f39e895 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/.yandex_meta/override.nix @@ -0,0 +1,13 @@ +pkgs: attrs: with pkgs; rec { + version = "2024-10-14"; + revision = "76435c4451aeb5e04e9500b090293347a38cef8d"; + + src = fetchFromGitHub { + owner = "libcxxrt"; + repo = "libcxxrt"; + rev = "${revision}"; + hash = "sha256-U7mq79/0xbyRr2+KUMKgEvyd2lfr3Q5GrByt/8J9sC8="; + }; + + nativeBuildInputs = [ cmake ]; +} diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/backtrace_recording.patch b/contrib/libs/cxxsupp/libcxxrt/patches/backtrace_recording.patch new file mode 100644 index 0000000000..81baccd6fc --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/backtrace_recording.patch @@ -0,0 +1,144 @@ +diff --git a/cxxabi.h b/cxxabi.h +index e021f85..acf9974 100644 +--- a/cxxabi.h ++++ b/cxxabi.h +@@ -249,6 +249,10 @@ char* __cxa_demangle(const char* mangled_name, + char* buf, + size_t* n, + int* status); ++ ++#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE ++size_t __cxa_collect_current_exception_backtrace(void** dest, size_t size); ++#endif + #ifdef __cplusplus + } // extern "C" + } // namespace +diff --git a/exception.cc b/exception.cc +index 15f93ae..c4b15ae 100644 +--- a/exception.cc ++++ b/exception.cc +@@ -255,12 +255,20 @@ namespace std + * various checks may test for equality of the class, which is incorrect. + */ + static const uint64_t exception_class = ++#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE ++ _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_PRIMARY_CLASS; ++#else + EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\0'); ++#endif + /** + * Class used for dependent exceptions. + */ + static const uint64_t dependent_exception_class = ++#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE ++ _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_DEPENDENT_CLASS; ++#else + EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\x01'); ++#endif + /** + * The low four bytes of the exception class, indicating that we conform to the + * Itanium C++ ABI. This is currently unused, but should be used in the future +@@ -605,6 +613,27 @@ static void free_exception(char *e) + } + #endif + ++static constexpr size_t align_to(size_t size, size_t alignment) noexcept { ++ return (size + alignment - 1) / alignment * alignment; ++} ++ ++static_assert(align_to(15, 16) == 16); ++static_assert(align_to(16, 16) == 16); ++static_assert(align_to(17, 16) == 32); ++ ++static constexpr size_t exception_size = align_to(sizeof(__cxa_exception), 16); ++static constexpr size_t dependent_exception_size = align_to(sizeof(__cxa_dependent_exception), 16); ++#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE ++static constexpr size_t backtrace_buffer_size = align_to(sizeof(_Unwind_Backtrace_Buffer), 16); ++ ++static_assert( ++ _YNDX_LIBUNWIND_EXCEPTION_BACKTRACE_MAGIC_OFFSET == ++ offsetof(__cxa_exception, unwindHeader) + backtrace_buffer_size - sizeof(_Unwind_Backtrace_Buffer)); ++#else ++static constexpr size_t backtrace_buffer_size = 0; ++#endif ++ ++ + /** + * Allocates an exception structure. Returns a pointer to the space that can + * be used to store an object of thrown_size bytes. This function will use an +@@ -613,16 +642,19 @@ static void free_exception(char *e) + */ + extern "C" void *__cxa_allocate_exception(size_t thrown_size) _LIBCXXRT_NOEXCEPT + { +- size_t size = thrown_size + sizeof(__cxa_exception); ++ size_t size = thrown_size + exception_size + backtrace_buffer_size; + char *buffer = alloc_or_die(size); +- return buffer+sizeof(__cxa_exception); ++#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE ++ ((_Unwind_Backtrace_Buffer *)buffer)->size = 0; ++#endif ++ return buffer + exception_size + backtrace_buffer_size; + } + + extern "C" void *__cxa_allocate_dependent_exception(void) + { +- size_t size = sizeof(__cxa_dependent_exception); ++ size_t size = dependent_exception_size + backtrace_buffer_size; + char *buffer = alloc_or_die(size); +- return buffer+sizeof(__cxa_dependent_exception); ++ return buffer + dependent_exception_size + backtrace_buffer_size; + } + + /** +@@ -650,7 +682,8 @@ extern "C" void __cxa_free_exception(void *thrown_exception) _LIBCXXRT_NOEXCEPT + } + } + +- free_exception(reinterpret_cast<char*>(ex)); ++ free_exception( ++ reinterpret_cast<char*>(thrown_exception) - exception_size - backtrace_buffer_size); + } + + static void releaseException(__cxa_exception *exception) +@@ -677,7 +710,7 @@ void __cxa_free_dependent_exception(void *thrown_exception) + { + releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex))); + } +- free_exception(reinterpret_cast<char*>(ex)); ++ free_exception(reinterpret_cast<char*>(thrown_exception) - dependent_exception_size - backtrace_buffer_size); + } + + /** +@@ -864,6 +897,32 @@ extern "C" void __cxa_decrement_exception_refcount(void* thrown_exception) + releaseException(ex); + } + ++#ifdef _YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE ++static size_t __cxa_collect_backtrace(__cxa_exception* ex, void** dest, size_t size) { ++ if (!ex) { ++ return 0; ++ } ++ if (!isCXXException(ex->unwindHeader.exception_class)) { ++ return 0; ++ } ++ size_t i = 0; ++ if (isDependentException(ex->unwindHeader.exception_class)) { ++ i = __cxa_collect_backtrace( ++ (__cxa_exception *)((__cxa_dependent_exception *)ex)->primaryException - 1, dest, size); ++ } ++ _Unwind_Backtrace_Buffer* backtraceBuffer = (_Unwind_Backtrace_Buffer*)( ++ (char *)(ex + 1) - exception_size - backtrace_buffer_size); ++ for (size_t j = 0; i != size && j != backtraceBuffer->size; ++i, ++j) { ++ dest[i] = backtraceBuffer->backtrace[j]; ++ } ++ return i; ++} ++ ++extern "C" size_t __cxa_collect_current_exception_backtrace(void** dest, size_t size) { ++ return __cxa_collect_backtrace(__cxa_get_globals()->caughtExceptions, dest, size); ++} ++#endif ++ + /** + * ABI function. Rethrows the current exception. Does not remove the + * exception from the stack or decrement its handler count - the compiler is diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/cxa_eh_globals_completion_var.patch b/contrib/libs/cxxsupp/libcxxrt/patches/cxa_eh_globals_completion_var.patch new file mode 100644 index 0000000000..3a1f27243e --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/cxa_eh_globals_completion_var.patch @@ -0,0 +1,12 @@ +--- /cxxabi.h (index) ++++ /cxxabi.h (working tree) +@@ -183,6 +183,9 @@ struct __cxa_eh_globals + */ + unsigned int uncaughtExceptions; + }; ++ ++#define Y_CXA_EH_GLOBALS_COMPLETE ++ + /** + * ABI function returning the __cxa_eh_globals structure. + */ diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/cxa_throw_hook.patch b/contrib/libs/cxxsupp/libcxxrt/patches/cxa_throw_hook.patch new file mode 100644 index 0000000000..f2333ccba5 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/cxa_throw_hook.patch @@ -0,0 +1,26 @@ +diff --git a/exception.cc b/exception.cc +index 15f93ae..2f1947f 100644 +--- a/exception.cc ++++ b/exception.cc +@@ -806,6 +806,9 @@ extern "C" __cxa_exception *__cxa_init_primary_exception( + return ex; + } + ++typedef void (*cxa_throw_hook_t)(void*, std::type_info*, void(*)(void*)) noexcept; ++ ++__attribute__((weak)) cxa_throw_hook_t cxa_throw_hook = nullptr; + + /** + * ABI function for throwing an exception. Takes the object to be thrown (the +@@ -816,6 +819,11 @@ extern "C" void __cxa_throw(void *thrown_exception, + std::type_info *tinfo, + void(*dest)(void*)) + { ++ if (cxa_throw_hook) ++ { ++ cxa_throw_hook(thrown_exception, tinfo, dest); ++ } ++ + __cxa_exception *ex = __cxa_init_primary_exception(thrown_exception, tinfo, dest); + ex->referenceCount = 1; + diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/fix_msan_exception_handling.patch b/contrib/libs/cxxsupp/libcxxrt/patches/fix_msan_exception_handling.patch new file mode 100644 index 0000000000..38aaa99006 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/fix_msan_exception_handling.patch @@ -0,0 +1,26 @@ +diff --git a/exception.cc b/exception.cc +index bad7530..007b29c 100644 +--- a/exception.cc ++++ b/exception.cc +@@ -34,6 +34,7 @@ + #include "dwarf_eh.h" + #include "atomic.h" + #include "cxxabi.h" ++#include <sanitizer/msan_interface.h> + + #pragma weak pthread_key_create + #pragma weak pthread_setspecific +@@ -1062,6 +1063,13 @@ static void pushCleanupException(_Unwind_Exception *exceptionObject, + */ + extern "C" + BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) ++#if defined(__SANITIZE_MEMORY__) ++ __msan_unpoison(&version, sizeof(version)); ++ __msan_unpoison(&actions, sizeof(actions)); ++ __msan_unpoison(&exceptionClass, sizeof(exceptionClass)); ++ __msan_unpoison(&exceptionObject, sizeof(exceptionObject)); ++ __msan_unpoison(&context, sizeof(context)); ++#endif + // This personality function is for version 1 of the ABI. If you use it + // with a future version of the ABI, it won't know what to do, so it + // reports a fatal error and give up before it breaks anything. diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/pr41.1-move-trace.patch b/contrib/libs/cxxsupp/libcxxrt/patches/pr41.1-move-trace.patch new file mode 100644 index 0000000000..b1331c9445 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/pr41.1-move-trace.patch @@ -0,0 +1,74 @@ +commit 690915810d43430667f8d7b84fc7f88784f68fdf (HEAD -> update-libcxxrt) +author: thegeorg +date: 2025-02-26T13:56:00+03:00 + + Revert "Simplify libcxxrt patches" + + This reverts commit 4358151e7723e37a39cf6f5478bfa336aa687fd4, reversing + changes made to ad7618a2219d22bcd89a67fe082f290b4a9656ef. + +--- contrib/libs/cxxsupp/libcxxrt/exception.cc (27ffe99a31d7fb0dd8a933c936f70853dac6041a) ++++ contrib/libs/cxxsupp/libcxxrt/exception.cc (690915810d43430667f8d7b84fc7f88784f68fdf) +@@ -287,6 +287,30 @@ namespace std + + using namespace ABI_NAMESPACE; + ++/** ++ * Callback function used with _Unwind_Backtrace(). ++ * ++ * Prints a stack trace. Used only for debugging help. ++ * ++ * Note: As of FreeBSD 8.1, dladd() still doesn't work properly, so this only ++ * correctly prints function names from public, relocatable, symbols. ++ */ ++static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) ++{ ++ Dl_info myinfo; ++ int mylookup = ++ dladdr(reinterpret_cast<void *>(__cxa_current_exception_type), &myinfo); ++ void *ip = reinterpret_cast<void*>(_Unwind_GetIP(context)); ++ Dl_info info; ++ if (dladdr(ip, &info) != 0) ++ { ++ if (mylookup == 0 || strcmp(info.dli_fname, myinfo.dli_fname) != 0) ++ { ++ printf("%p:%s() in %s\n", ip, info.dli_sname, info.dli_fname); ++ } ++ } ++ return _URC_CONTINUE_UNWIND; ++} + + + /** The global termination handler. */ +@@ -760,31 +785,6 @@ void __cxa_free_dependent_exception(void *thrown_exception) + } + + /** +- * Callback function used with _Unwind_Backtrace(). +- * +- * Prints a stack trace. Used only for debugging help. +- * +- * Note: As of FreeBSD 8.1, dladd() still doesn't work properly, so this only +- * correctly prints function names from public, relocatable, symbols. +- */ +-static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) +-{ +- Dl_info myinfo; +- int mylookup = +- dladdr(reinterpret_cast<void *>(__cxa_current_exception_type), &myinfo); +- void *ip = reinterpret_cast<void*>(_Unwind_GetIP(context)); +- Dl_info info; +- if (dladdr(ip, &info) != 0) +- { +- if (mylookup == 0 || strcmp(info.dli_fname, myinfo.dli_fname) != 0) +- { +- printf("%p:%s() in %s\n", ip, info.dli_sname, info.dli_fname); +- } +- } +- return _URC_CONTINUE_UNWIND; +-} +- +-/** + * Report a failure that occurred when attempting to throw an exception. + * + * If the failure happened by falling off the end of the stack without finding diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch b/contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch new file mode 100644 index 0000000000..626d736e8b --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch @@ -0,0 +1,46 @@ +--- contrib/libs/cxxsupp/libcxxrt/exception.cc (index) ++++ contrib/libs/cxxsupp/libcxxrt/exception.cc (working tree) +@@ -312,9 +312,42 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) + return _URC_CONTINUE_UNWIND; + } + ++static void bt_terminate_handler() { ++ __cxa_eh_globals* globals = __cxa_get_globals(); ++ __cxa_exception* thrown_exception = globals->caughtExceptions; ++ ++ if (thrown_exception) { ++ fprintf(stderr, "uncaught exception:\n address -> %p\n", (void*)thrown_exception); ++ thrown_exception = realExceptionFromException(thrown_exception); ++ ++ const __class_type_info *e_ti = static_cast<const __class_type_info*>(&typeid(std::exception)); ++ const __class_type_info *throw_ti = dynamic_cast<const __class_type_info*>(thrown_exception->exceptionType); ++ ++ if (throw_ti) { ++ void* ptr = thrown_exception + 1; ++ ++ if (throw_ti->__do_upcast(e_ti, &ptr)) { ++ std::exception* e = static_cast<std::exception*>(ptr); ++ ++ if (e) { ++ fprintf(stderr, " what() -> \"%s\"\n", e->what()); ++ } ++ } ++ } ++ ++ size_t bufferSize = 128; ++ char *demangled = static_cast<char*>(malloc(bufferSize)); ++ const char *mangled = thrown_exception->exceptionType->name(); ++ int status; ++ demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status); ++ fprintf(stderr, " type -> %s\n", status == 0 ? demangled : mangled); ++ if (status == 0) { free(demangled); } ++ } ++ abort(); ++} + + /** The global termination handler. */ +-static atomic<terminate_handler> terminateHandler = abort; ++static atomic<terminate_handler> terminateHandler = bt_terminate_handler; + /** The global unexpected exception handler. */ + static atomic<unexpected_handler> unexpectedHandler = std::terminate; + diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/preallocated_thread_info.patch b/contrib/libs/cxxsupp/libcxxrt/patches/preallocated_thread_info.patch new file mode 100644 index 0000000000..208413ecb2 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/preallocated_thread_info.patch @@ -0,0 +1,107 @@ +--- /exception.cc (index) ++++ /exception.cc (working tree) +@@ -331,6 +373,44 @@ static void free_exception_list(__cxa_exception *ex) + __cxa_free_exception(ex+1); + } + ++#define fast_ti_size 100 ++ ++static long fast_ti_index; ++static __cxa_thread_info fast_ti[fast_ti_size]; ++ ++static inline __cxa_thread_info* alloc_thread_info() { ++ { ++ long cur_index; ++ ++ __atomic_load(&fast_ti_index, &cur_index, __ATOMIC_SEQ_CST); ++ ++ // exausted long time ago ++ if (cur_index >= fast_ti_size) { ++ return static_cast<__cxa_thread_info*>(calloc(1, sizeof(__cxa_thread_info))); ++ } ++ } ++ ++ auto my_index = __sync_fetch_and_add(&fast_ti_index, 1); ++ ++ // exausted ++ if (my_index >= fast_ti_size) { ++ return static_cast<__cxa_thread_info*>(calloc(1, sizeof(__cxa_thread_info))); ++ } ++ ++ // fast path ++ auto& ret = fast_ti[my_index]; ++ ++ memset(&ret, 0, sizeof(ret)); ++ ++ return &ret; ++} ++ ++static inline void free_thread_info(__cxa_thread_info* ti) { ++ if ((ti < fast_ti) || (ti >= (fast_ti + fast_ti_size))) { ++ free(ti); ++ } ++} ++ + /** + * Cleanup function called when a thread exists to make certain that all of the + * per-thread data is deleted. +@@ -352,10 +352,9 @@ static void thread_cleanup(void* thread_info) + free_exception_list(info->globals.caughtExceptions); + } + } +- free(thread_info); ++ free_thread_info(info); + } + +- + /** + * Once control used to protect the key creation. + */ +@@ -389,11 +388,16 @@ static void init_key(void) + pthread_setspecific(eh_key, 0); + } + ++static __thread __cxa_thread_info* THR_INFO = nullptr; ++ + /** + * Returns the thread info structure, creating it if it is not already created. + */ + static __cxa_thread_info *thread_info() + { ++ if (THR_INFO) { ++ return THR_INFO; ++ } + if ((0 == pthread_once) || pthread_once(&once_control, init_key)) + { + fakeTLS = true; +@@ -402,17 +406,29 @@ static __cxa_thread_info *thread_info() + __cxa_thread_info *info = static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key)); + if (0 == info) + { +- info = static_cast<__cxa_thread_info*>(calloc(1, sizeof(__cxa_thread_info))); ++ info = alloc_thread_info(); + pthread_setspecific(eh_key, info); + } ++ THR_INFO = info; + return info; + } ++ ++// ensure main thread will allocate preallocated tls ++static struct InitMainTls { ++ inline InitMainTls() { ++ thread_info(); ++ } ++} init_main_tls; ++ + /** + * Fast version of thread_info(). May fail if thread_info() is not called on + * this thread at least once already. + */ + static __cxa_thread_info *thread_info_fast() + { ++ if (THR_INFO) { ++ return THR_INFO; ++ } + if (fakeTLS) { return &singleThreadInfo; } + return static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key)); + } diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/remove_unused_code.patch b/contrib/libs/cxxsupp/libcxxrt/patches/remove_unused_code.patch new file mode 100644 index 0000000000..9a2002511a --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/remove_unused_code.patch @@ -0,0 +1,90 @@ +diff --git a/exception.cc b/exception.cc +index 1a6a487..2e84ce8 100644 +--- /exception.cc ++++ /exception.cc +@@ -36,29 +36,6 @@ + #include "cxxabi.h" + #include <sanitizer/msan_interface.h> + +-#pragma weak pthread_key_create +-#pragma weak pthread_setspecific +-#pragma weak pthread_getspecific +-#pragma weak pthread_once +-#ifdef LIBCXXRT_WEAK_LOCKS +-#pragma weak pthread_mutex_lock +-#define pthread_mutex_lock(mtx) do {\ +- if (pthread_mutex_lock) pthread_mutex_lock(mtx);\ +- } while(0) +-#pragma weak pthread_mutex_unlock +-#define pthread_mutex_unlock(mtx) do {\ +- if (pthread_mutex_unlock) pthread_mutex_unlock(mtx);\ +- } while(0) +-#pragma weak pthread_cond_signal +-#define pthread_cond_signal(cv) do {\ +- if (pthread_cond_signal) pthread_cond_signal(cv);\ +- } while(0) +-#pragma weak pthread_cond_wait +-#define pthread_cond_wait(cv, mtx) do {\ +- if (pthread_cond_wait) pthread_cond_wait(cv, mtx);\ +- } while(0) +-#endif +- + using namespace ABI_NAMESPACE; + + /** +@@ -467,31 +444,16 @@ static void thread_cleanup(void* thread_info) + */ + static pthread_once_t once_control = PTHREAD_ONCE_INIT; + +-/** +- * We may not be linked against a full pthread implementation. If we're not, +- * then we need to fake the thread-local storage by storing 'thread-local' +- * things in a global. +- */ +-static bool fakeTLS; +-/** +- * Thread-local storage for a single-threaded program. +- */ +-static __cxa_thread_info singleThreadInfo; + /** + * Initialise eh_key. + */ + static void init_key(void) + { +- if ((0 == pthread_key_create) || +- (0 == pthread_setspecific) || +- (0 == pthread_getspecific)) +- { +- fakeTLS = true; +- return; +- } + pthread_key_create(&eh_key, thread_cleanup); + pthread_setspecific(eh_key, reinterpret_cast<void *>(0x42)); +- fakeTLS = (pthread_getspecific(eh_key) != reinterpret_cast<void *>(0x42)); ++ if (pthread_getspecific(eh_key) != reinterpret_cast<void *>(0x42)) { ++ abort(); ++ } + pthread_setspecific(eh_key, 0); + } + +@@ -505,11 +467,7 @@ static __cxa_thread_info *thread_info() + if (THR_INFO) { + return THR_INFO; + } +- if ((0 == pthread_once) || pthread_once(&once_control, init_key)) +- { +- fakeTLS = true; +- } +- if (fakeTLS) { return &singleThreadInfo; } ++ pthread_once(&once_control, init_key); + __cxa_thread_info *info = static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key)); + if (0 == info) + { +@@ -536,7 +494,6 @@ static __cxa_thread_info *thread_info_fast() + if (THR_INFO) { + return THR_INFO; + } +- if (fakeTLS) { return &singleThreadInfo; } + return static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key)); + } + /** diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/throw_specs.patch b/contrib/libs/cxxsupp/libcxxrt/patches/throw_specs.patch new file mode 100644 index 0000000000..a1c0e5abe9 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/throw_specs.patch @@ -0,0 +1,20 @@ +diff --git a/memory.cc b/memory.cc +index 7beb048..bb6cc74 100644 +--- a/memory.cc ++++ b/memory.cc +@@ -59,13 +59,13 @@ namespace std + * Sets a function to be called when there is a failure in new. + */ + __attribute__((weak)) +- new_handler set_new_handler(new_handler handler) ++ new_handler set_new_handler(new_handler handler) noexcept + { + return new_handl.exchange(handler); + } + + __attribute__((weak)) +- new_handler get_new_handler(void) ++ new_handler get_new_handler(void) noexcept + { + return new_handl.load(); + } diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/typeinfo.patch b/contrib/libs/cxxsupp/libcxxrt/patches/typeinfo.patch new file mode 100644 index 0000000000..413938e3e0 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxxrt/patches/typeinfo.patch @@ -0,0 +1,60 @@ +--- /typeinfo.cc ++++ /typeinfo.cc +@@ -68,57 +68,3 @@ ABI_NAMESPACE::__vmi_class_type_info::~__vmi_class_type_info() {} + ABI_NAMESPACE::__pbase_type_info::~__pbase_type_info() {} + ABI_NAMESPACE::__pointer_type_info::~__pointer_type_info() {} + ABI_NAMESPACE::__pointer_to_member_type_info::~__pointer_to_member_type_info() {} +- +-// From libelftc +-extern "C" char *__cxa_demangle_gnu3(const char *); +- +-extern "C" char* __cxa_demangle(const char* mangled_name, +- char* buf, +- size_t* n, +- int* status) +-{ +- // TODO: We should probably just be linking against libelf-tc, rather than +- // copying their code. This requires them to do an actual release, +- // however, and for our changes to be pushed upstream. We also need to +- // call a different demangling function here depending on the ABI (e.g. +- // ARM). +- char *demangled = __cxa_demangle_gnu3(mangled_name); +- if (NULL != demangled) +- { +- size_t len = strlen(demangled); +- if (!buf || (*n < len+1)) +- { +- buf = static_cast<char*>(realloc(buf, len+1)); +- } +- if (0 != buf) +- { +- memcpy(buf, demangled, len); +- buf[len] = 0; +- if (n) +- { +- *n = len; +- } +- if (status) +- { +- *status = 0; +- } +- } +- else +- { +- if (status) +- { +- *status = -1; +- } +- } +- free(demangled); +- } +- else +- { +- if (status) +- { +- *status = -2; +- } +- return NULL; +- } +- return buf; +-} |