Page MenuHomePhabricator

[WIP][libc++] Link c++experimental.a into libc++.dylib when enabled
AbandonedPublic

Authored by ldionne on Apr 14 2020, 1:52 PM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

When libc++ is built with experimental features enabled, we link the
c++experimental.a static library directly into libc++.dylib, which
allows users to avoid using -lc++experimental in order to use
experimental features.

It makes sense to me that when libc++ is configured with experimental
features enabled, it should just work. Of course, vendors are free to
follow a different course of action, since they may not want to ship
experimental features in their dylib (in which case they can simply
turn off the experimental library in their build).

Diff Detail

Event Timeline

ldionne created this revision.Apr 14 2020, 1:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2020, 1:52 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

This isn't a complete patch, but mostly a RFC to see what folks would think about including libc++experimental.a into the static/shared library when it is enabled. My view of things is that -lc++ should always be sufficient to link against libc++, and on Darwin it is (libc++abi symbols are re-exported, so -lc++abi isn't required). With that view of things, it makes sense to include c++experimental.a in the dylib when it is enabled.

Note that vendors are free not to enable c++experimental.a in the dylib they ship because they need to ensure ABI compatibility and some amount of stability.

@jwakely , how does libstdc++ ship experimental features? Does it ship them in its shared library?

jwakely added a comment.EditedApr 14 2020, 3:48 PM

@jwakely , how does libstdc++ ship experimental features? Does it ship them in its shared library?

No. Everything is header-only, except the Filesystem TS stuff which is in a separate static lib (libstdc++fs.a) and not in the shared library. Generally we try to avoid adding things to the shared library until they are non-experimental (that wasn't the case in the past, and we have been burned by adding immature C++0x features to the shared library too soon).

ldionne abandoned this revision.May 20 2020, 1:49 PM

@jwakely , how does libstdc++ ship experimental features? Does it ship them in its shared library?

No. Everything is header-only, except the Filesystem TS stuff which is in a separate static lib (libstdc++fs.a) and not in the shared library. Generally we try to avoid adding things to the shared library until they are non-experimental (that wasn't the case in the past, and we have been burned by adding immature C++0x features to the shared library too soon).

Thanks for the input.

Revisiting this, I think it makes sense to have at least some explicit switch for enabling experimental features. I think the best would be a compiler flag that does whatever's required -- something like -fexperimental, which would automatically add -lc++experimental (and possibly other necessary things). Abandoning this.