[FR] libc++ should set _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION for bionic
- Dominant language
- No language data
- Stars
- 2.3k
- Forks
- 310
- PR merge metrics
- No merged PRs in 30d
Description
@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.
Contributor guide
Assessment
This issue has not been assessed yet.