commit 9008d4a610dccb5ec47f9c1e506492b8615a36fd Author: Torvald Riegel Date: Sun Jan 17 19:21:13 2016 +0100 libstdc++: Fix usage of weak symbols in TM TS support. diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc index e2d7e76..8ccc7f5 100644 --- a/libstdc++-v3/src/c++11/cow-stdexcept.cc +++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc @@ -179,6 +179,13 @@ _GLIBCXX_END_NAMESPACE_VERSION // Furthermore, _Rep will always have been allocated or deallocated via // global new or delete, so nontransactional writes we do to _Rep cannot // interfere with transactional accesses. + +// We require support for weak symbols because we need to call libitm but must +// not depend on it. The exception classes will not be declared +// transaction-safe if there is no such support, so do not create +// transactional clones in that case at all. +#ifdef __GXX_WEAK__ + extern "C" { #ifndef _GLIBCXX_MANGLE_SIZE_T @@ -195,7 +202,6 @@ extern "C" { # define ITM_REGPARM #endif -#if __GXX_WEAK__ // Declare all libitm symbols we rely on, but make them weak so that we do // not depend on libitm. extern void* _ZGTtnaX (size_t sz) __attribute__((weak)); @@ -213,9 +219,10 @@ extern void _ITM_memcpyRnWt(void *, const void *, size_t) extern void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) ITM_REGPARM __attribute__((weak)); -#else -// If there is no support for weak symbols, create dummies. The exceptions -// will not be declared transaction_safe in this case. +// Also create stubs because some targets (e.g., AIX) do not support weak +// symbols that do not have a definition. These stubs will not be used +// (unless users call the transactional clones directly or run transactions +// without using libitm as well) void* _ZGTtnaX (size_t) { return NULL; } void _ZGTtdlPv (void*) { } uint8_t _ITM_RU1(const uint8_t *) { return 0; } @@ -224,7 +231,6 @@ uint64_t _ITM_RU8(const uint64_t *) { return 0; } void _ITM_memcpyRtWn(void *, const void *, size_t) { } void _ITM_memcpyRnWt(void *, const void *, size_t) { } void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) { }; -#endif } @@ -440,3 +446,5 @@ CTORDTOR(14overflow_error, std::overflow_error, runtime_error) CTORDTOR(15underflow_error, std::underflow_error, runtime_error) } + +#endif // __GXX_WEAK__