[libcxx-commits] [PATCH] D150896: [libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes that we have instantiated externally
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 26 12:36:30 PDT 2023
ldionne added a subscriber: jwakely.
ldionne added a comment.
@philnik and I just discussed this issue in depth.
Fundamentally, the problem is that the library needs the ability to control what is contained in an explicit instantiation of a class by users. The Standard guarantees that users can explicitly instantiate stdlib classes if they provide at least one user-defined type in the instantiation. However, when a member function "escapes" into a user dylib by means of an explicit instantiation, ABI stability requires us to keep that member function stable. Since we can't commit to ABI stability for all implementation detail member functions, we need a way of excluding some member functions from the user's explicit instantiations. This is what the `exclude_from_explicit_instantiation` attribute achieves, and we are trying to approximate its effect on GCC by using `always_inline`.
We discussed for over an hour how to not require `exclude_from_explicit_instantiation`, which would then also get rid of the need for `always_inline` on GCC. However, the conclusion is that it's a fundamental and important tool for us to control what we let escape into users' dylibs via explicit instantiations. So we can't get rid of that attribute. As a result, I think the conclusion here is that we either
- need GCC to support this attribute
- or we drop the guarantee that users can do explicit instantiations on GCC (or if they do, then we don't guarantee ABI stability for them)
This is a mess. @jwakely Do you think there's any chance we could get GCC to add this attribute? The attribute is pretty simple, it basically excludes the marked member functions from any explicit instantiation or explicit instantiation declaration.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150896/new/
https://reviews.llvm.org/D150896
More information about the libcxx-commits
mailing list