[PATCH] D18174: Fix libcxx build on musl

Ben Craig via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 31 05:58:59 PDT 2017


bcraig added inline comments.


================
Comment at: include/__mutex_base:51
 #ifndef _LIBCPP_CXX03_LANG
-    constexpr mutex() = default;
+#ifdef __GLIBC__
+    constexpr
----------------
smeenai wrote:
> EricWF wrote:
> > Limiting `constexpr` to GLIBC implementations only is incorrect; you want to exclude MUSL.
> > 
> > Also MUSL is wrong for not allowing `pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER` to be a constant expression, and MUSL should fix that.
> I've used `__builtin_constant_p` to wok around a similarly non-conforming `PTHREAD_MUTEX_INITIALIZER` (from pthread-win32, which defines it to be `(void *)-1`): see the last part of https://stackoverflow.com/a/10376574/382079. It's a terrible hack, but it works.
musl's pthread_mutex_t has volatile members if I recall correctly.  It's hard to validate that statement without building musl, because the header that defines pthread_mutex_t is code generated.


https://reviews.llvm.org/D18174





More information about the cfe-commits mailing list