ndk icon indicating copy to clipboard operation
ndk copied to clipboard

[BUG] libc++ should set _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION for bionic

Open enh-google opened this issue 5 years ago • 2 comments

@rprichard said, on an internal bug: it looks like -Werror=exit-time-destructors allows a static std::mutex, but on glibc, not Bionic. I think it does so because the ctor is constexpr and the dtor is trivial:

// The glibc and Bionic implementation of pthreads implements
// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
// mutexes have no destroy mechanism.
//
// This optimization can't be performed on Apple platforms, where
// pthread_mutex_destroy can allow the kernel to release resources.
// See https://llvm.org/D64298 for details.
//
// TODO(EricWF): Enable this optimization on Bionic after speaking to their
//               respective stakeholders.
#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
  || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \
  || defined(_LIBCPP_HAS_THREAD_API_WIN32)
# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
#endif

we should fix that. filing this separate bug so we don't forget.

enh-google avatar May 18 '20 20:05 enh-google

(i was going to try editing this locally just to confirm that nothing breaks, but it seems like we don't have a new enough libc++ in the platform to have this yet.)

enh-google avatar Feb 23 '21 21:02 enh-google

Still there https://github.com/llvm/llvm-project/blob/894c22406f68af6574a62a40ec49e058344c324b/libcxx/include/__config#L1125-L1126 (that's a permalink, so it's always going to say that). @rprichard, could you fix upstream at some point?

DanAlbert avatar Jan 16 '24 23:01 DanAlbert