This is an archive of the discontinued LLVM Phabricator instance.

[RFC][libc++]] Adds _LIBCPP_HIDE_FROM_ABI_TYPE.
DraftPublic

Authored by Mordante on Feb 7 2023, 6:04 AM.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
ldionne
Summary

As discussed in D136775.

Diff Detail

Event Timeline

Mordante created this revision.Feb 7 2023, 6:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 6:04 AM
Mordante added inline comments.Feb 7 2023, 6:08 AM
libcxx/include/__format/parser_std_format_spec.h
126

I think it would be good to document what should and what should not be hidden from the ABI.
For example should this implementation field use an ABI tag or not.
Then we probably should update https://libcxx.llvm.org/DesignDocs/VisibilityMacros.html too and if possible have some more clang-tidy validations.

I think I like this approach, but we should discuss it in the context of D153658. Also, I think we want to punt this change to LLVM 18, I don't believe we're blocking ourselves from anything if we wait.

libcxx/include/__format/parser_std_format_spec.h
126

I think that whatever we put an ABI tag on would also need to have hidden visibility. Otherwise, it is possible for users to start exporting symbols whose name depends on the libc++ version on their dylib boundaries, which is not good.

ldionne added inline comments.Tue, Nov 28, 8:27 AM
libcxx/include/__config
630

I think it would be useful to add this attribute to a few other internal-only types that are not meant to appear at ABI boundaries, just to make it clear how this attribute is intended to be used. A good candidate would be libcxx/include/__utility/exception_guard.h.

638

This documentation needs to touch on the fact that we don't have a way to enforce that these types are not used at ABI boundaries, but that if it happens in e.g. a function signature the ABI break will be quite loud because the mangling of the type changes with the ODR signature (which includes e.g. the version of the library).

We should also say that it's fine to use these types as return types and parameter types of functions, but only if said functions are marked as HIDE_FROM_ABI.

We should also say that such types must never be used as a member of another type, except if that other type is *also* marked as HIDE_FROM_ABI_TYPE.

639

I think I would do this now:

#define _LIBCPP_HIDE_FROM_ABI_TYPE \
    _LIBCPP_HIDDEN \
    __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))