[libcxx-commits] [libcxx] [libc++] Don't add #pragma clang attribute with GCC (PR #206989)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 4 00:37:28 PDT 2026


philnik777 wrote:

> How will implicit ABI annotations work in non-Clang-based compilers?

It won't work. See below.

> Do you plan to use some other machinery to add hidden visibility, ODR ABI tags, etc?

No. As Louis already mentioned, we have some big problems on GCC currently, since the only way to make our ABI guarantees there is to add `[[gnu::always_inline]]` everywhere. This has always been a suboptimal choice, and bigger features like `std::format` are completely unusable to the point where we disable tests because they basically can't be compiled with GCC (unless you're willing to wait minutes and have dozens of gigs of ram per test). The move to implicit annotations on Clang is in part to fix this issue and be able to provide all the guarantees we want on Clang while being able to walk back our guarantees in exchange for actual usability on GCC. If GCC adds support for any features we need to improve our ABI guarantees I'm of course happy to bring them back. In case anybody who reads this and cares, these are some important ones:
- `[[clang::type_visibility]]`: This would allow us to make functions have the configured visibility (i.e. by default `default`, with `-fvisibility=X` X etc.).
- `[[clang::exclude_from_explicit_instantiation]]`: Removes the need for `[[gnu::always_inline]]` on classes exported from the ABI
- `#pragma clang attribute`: Needed to force hidden visibility on everything we want as well as ABI tagging everything automatically.

> However, this makes me realize that by adopting the pragmas approach, we probably regressed that support even more on GCC, since we wouldn't be applying ABI tags anymore to functions. @philnik777 is that the case? I don't remember discussing that when we reviewed #193045.

I'm pretty sure we talked about this. Yes, we're "losing" the ABI tags (we've `always_inline`d everything anyways, so they didn't make any difference whatsoever before). I'm also pretty sure that we concluded that `[[gnu::always_inline]]` everywhere is worse than not ABI tagging everything.

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


More information about the libcxx-commits mailing list