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

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 20 13:58:33 PDT 2025


philnik777 wrote:

@dschuff I didn't expect this. It looks like the compiler takes the visibility of the namespace where `std::hash` is declared. Since we didn't declare any non-type visibility before, this turns out to be a user-visible change. Though I'm not sure any compiler engineer thought about this specific case deeply before. It looks like Clang and GCC can't agree on which visibility to use if there are different declarations with different namespace visibility (and neither compiler complains in the slightest): https://godbolt.org/z/hGGhTG6f3

Even more fascinatingly, they also agree that it should be hidden when using `-fvisibility=hidden`, even though the namespace asks for default visibility!? (https://godbolt.org/z/GEbMnod1x)

I feel like this case is special enough that it doesn't warrant a revert - though maybe some compiler folks should take a look. The workaround is also rather simple: just explicitly mark the function with the correct visibility (which IMHO you should do anyways if you build dylibs).

CC @AaronBallman @cor3ntin (sorry, not sure who the resident visibility expert is)

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


More information about the libcxx-commits mailing list