constexpr is not available on musl
Details
Diff Detail
Event Timeline
I'm adding a few library folks to make sure this is the correct behaviour. I honestly don't know.
cheers,
--renato
include/__config | ||
---|---|---|
397 ↗ | (On Diff #50692) | Unnecessary whitespace change |
If I understand it correctly, GLIBC is defined in features.h, so this won't work.
I suspect that the build isn't broken. You likely just need to define LIBCXX_HAS_MUSL_LIBC on your cmake line. That will cause __config_site.in to #define _LIBCPP_HAS_MUSL_LIBC for you.
@bcraig, right, check for GLIBC can be moved after including features.h.
https://chromium.googlesource.com/native_client/pnacl-libcxx/+/master%5E!/
seems to add needed tweaks which can be enabled by passing -Dmusl in CFLAGS
may be it can be backported to 3.8 branch
3.8 has it in there. So may be this is just not required. I will add
-DLIBCXX_HAS_MUSL_LIBC=ON to Cmake and see what comes out
The trouble is that features.h doesn't exist in musl (as far as I know). That's the biggest reason why _LIBCPP_HAS_MUSL_LIBC is needed.
I think my problem was that while compiling libcxxabi, it wants to peek into libcxx headers but then libcxxabi cmake infra doesnt have the musl support like libcxx. So Now I solved it by adding -D_LIBCPP_HAS_MUSL_LIBC to CXXFLAGS.
libcxx still has problem compiling on musl/aarch64 though. I fixed it with this patch
does this make sense ?
That patch looks hugely dangerous because you've now changed when your static mutex's get initialized. Please file a bug against libc++.
When cross-compiling, I have found it to be best to build libcxx and libcxxabi as sub-projects of LLVM (i.e. I place libcxx under llvm/projects/libcxx). I can then configure libcxxabi and libcxx at once. When I get around to building, I specifically dodge building LLVM and/or clang by running "make cxxabi cxx".
If you go with that approach, I think all of the _LIBCPP_HAS_MUSL_LIBC stuff gets worked out, because libcxxabi looks at the __ config header that #includes __config_site.
The method @bcraig is describing is documented here: http://libcxx.llvm.org/docs/BuildingLibcxx.html#id4
This patch is not OK, since it affects way more that just MUSL libc.
Also can you please provide a reduced reproducer as two why pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER is not a constant expression with MUSL?
include/__mutex_base | ||
---|---|---|
51 | 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. |
include/__mutex_base | ||
---|---|---|
51 | 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. |
@EricWF you are right. I have made the changes accordingly. This patch can be ignored.
include/__mutex_base | ||
---|---|---|
51 | 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. |
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.