[libcxx-commits] [libcxx] [libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (PR #131156)

James Y Knight via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 27 08:42:00 PDT 2025


jyknight wrote:

> FWIW we can work around the problem for specific classes in the library, which would be annoying, but definitely better than reverting.

I don't think this can be worked around for only specific classes, because (somewhat sadly, IMHO) the standard permits user specializations of nearly everything in the stdlib (other than a small list of explicit prohibitions).

> we'll work around the problem in the library until all compilers we support have been fixed.

While I see there's some inconsistency between compilers on what to do about conflicting attributes, the core issue is that visibility is inherited from the first namespace decl to the second, if the second _doesn't_ have any visibility attribute. Compilers agree upon that, and I don't think it's something that can or should be changed.

That is, the following is the _expected_ behavior from the compiler -- but, the resulting behavior of hiding the user function is invalid. I believe this implies libc++ simply must not declare hidden visibility on public namespaces (it may on private implementation details namespaces).

```
// libc++ header
namespace [[gnu::visibility("hidden")]] std {
...
}

// user code:
namespace std {
  // Broken: function given hidden visibility, because of previous visibility attribute.
  void f();
}
```


https://github.com/llvm/llvm-project/pull/131156


More information about the libcxx-commits mailing list