This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Use C++14 when building libc++ with musl
ClosedPublic

Authored by phosek on Oct 11 2016, 3:40 PM.

Details

Summary

musl's pthread implementations use volatile types in their structs which is not being constexpr in C++11 but is in C++14.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek updated this revision to Diff 74305.Oct 11 2016, 3:40 PM
phosek retitled this revision from to [libcxx] Use C++14 when building libc++ with musl.
phosek updated this object.
phosek added reviewers: EricWF, mclow.lists.
phosek set the repository for this revision to rL LLVM.
phosek added a subscriber: cfe-commits.

libc++ was already building with musl after D21637 was commited, but this broke recently as a consequence of r282640 which introduced the use of _LIBCPP_SAFE_STATIC for libc++ internal globals. I'm not sure if this is the best solution, but it's the only one I could come up with, apart from removing the use of _LIBCPP_SAFE_STATIC, which is undesirable, or removing the use of volatile from musl pthread structs, which is unlikely.

EricWF edited edge metadata.Oct 11 2016, 7:20 PM

musl's pthread implementations use volatile types in their structs which is not being constexpr in C++11 but is in C++14.

This means that libc++'s std::mutex is unsafe to use during dynamic initialization in C++11 with MUSL, which would really suck except that Clang emits always emits the initialization as a constant expression, ever if it's not guaranteed by the core language.

@mclow.lists Do you have any issue bumping the std version while building for MUSL only?

CMakeLists.txt
327 ↗(On Diff #74305)

Why not just set LIBCXX_STANDARD_VER differently instead of replacing it after the fact?

phosek added inline comments.Oct 11 2016, 8:38 PM
CMakeLists.txt
327 ↗(On Diff #74305)

I totally missed it; this change was a part of a downstream patch we were using for building Fuchsia toolchain and it predates this option. Using this option, I can override the dialect only for our build, which is perfectly fine for Fuchsia since we default to C++14. I'd be happy to abandon this patch unless you want to persist that setting for musl?

EricWF added inline comments.Oct 11 2016, 9:41 PM
CMakeLists.txt
327 ↗(On Diff #74305)

Since we support MUSL it would be nice if libc++ built out of the box. Making the option persistent for MUSL makes the most sense to me.

phosek updated this revision to Diff 74402.Oct 12 2016, 10:57 AM
phosek edited edge metadata.
phosek marked an inline comment as done.
hfinkel added inline comments.
CMakeLists.txt
327 ↗(On Diff #74305)

We should add a comment here, or where ever this logic ends up going, to explain why this is needed.

phosek updated this revision to Diff 74439.Oct 12 2016, 1:57 PM
phosek marked an inline comment as done.

Ping, do you have any other comments?

Ping, do you have any other comments?

Fine by me. Please wait for an okay by @EricWF .

@EricWF is this fine with you?

EricWF accepted this revision.Oct 21 2016, 6:52 PM
EricWF edited edge metadata.

LGTM.

CMakeLists.txt
331 ↗(On Diff #74439)

This should probably overwrite the cache entry.

This revision is now accepted and ready to land.Oct 21 2016, 6:52 PM
phosek updated this revision to Diff 75540.Oct 22 2016, 6:38 PM
phosek edited edge metadata.
phosek marked an inline comment as done.
phosek updated this revision to Diff 75553.Oct 23 2016, 2:52 PM
This revision was automatically updated to reflect the committed changes.