[libcxx-commits] [libcxx] [libc++] Introduce a new attribute keyword for Clang improves compatibility with Mingw-GCC (PR #141040)

Tomohiro Kashiwada via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 11 04:59:11 PDT 2025


kikairoya wrote:

> > 6. Modify Clang more to inherit dllexport to inner-type and export it
> > I guess this option works without any breakage of existing binaries but introduce a new incompatibility with MinGW-GCC.
> > Additionally, same as 3., MinGW-GCC will be left incompatible with libc++.
> 
> I don't see how this would leave GCC incompatible with libc++. If you build the libc++ DLL with Clang, it would dllexport the necessary inner classes. When building user code with GCC, it does not instantiate the inner classes, and it would be able to link them from the libc++ DLL, right? The only issue would be if you'd try to build the libc++ DLL with GCC, where it wouldn't have sufficient dllexports (linking with `-Wl,--export-all-symbols` would help though).


Yes, technically you're right. I've updated 6.) to reflect that perspective more accurately.
Though, I would consider it incompatible if `-Wl,--export-all-symbols` is still needed despite using `__declspec(dllexport)`. Otherwise, we could say Clang targeting MinGW doesn't need to annotate exports at all - but that's clearly not acceptable in libc++'s model.



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


More information about the libcxx-commits mailing list