[clang] [Clang] Allow simpler visibility annotations when targeting win32 and mingw (PR #133699)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 26 01:12:58 PDT 2025
philnik777 wrote:
> > No. We can drop `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` and `_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS` by replacing it with `_LIBCPP_EXPORTED_FROM_ABI`.
>
> But how will that work when building with MinGW or MSVC? Or is that not supported?
Is is supported and keeps working exactly the same.
> I'm a bit conflicted about this. On the one hand, it will make things simpler for developers only building with Clang. On the other hand, it adds new entries to the matrix of how dllexport works across different compilers, which developers may need to understand, and which we need to maintain.
This patch doesn't change any semantics. It doesn't add new entries on any matrix, it simply allows adding attributes in places they are ignored without getting warnings, because what the user expects them to do is already done by an attribute in the correct place. This doesn't affect interoperability with other compilers and you even have to disable warnings about incorrect placements. Note that is _does_ significantly simplify the matrix of required visibility macros for projects primarily targeting Clang though.
> > > No. We can drop `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` and `_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS` by replacing it with `_LIBCPP_EXPORTED_FROM_ABI`.
> >
> >
> > But how will that work when building with MinGW or MSVC? Or is that not supported?
>
> I presume you mean "building with GCC"? (We do build for MinGW targets with Clang all the time.)
>
> Building libc++ with MSVC isn't supported - it lacks support for many constructs that libc++ requires.
>
> Building libc++ with GCC is tested and supported on Linux. In MinGW environments it should probably work but it's not continuously tested. But iirc @kikairoya did test it quite recently?
>
> So if we do require this behaviour from the compiler, we might close the door for using libc++ with GCC on Windows.
I don't see how we do this. It's simply different warnings.
> It may also be possible to just ignore the extra warnings with GCC with some extra flags about ignored attributes though.
Exactly. We already do this in lots of cases.
https://github.com/llvm/llvm-project/pull/133699
More information about the cfe-commits
mailing list