[libcxx-commits] [libcxx] [libc++] Make ABI annotations explicit for windows-specific code (PR #140507)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 19 07:38:07 PDT 2025


philnik777 wrote:

> > I guess so. Is there a tool like `nm` we can use to extract that information on windows? I guess mingw has something very similar, probably even `nm` itself, but I'm not aware of an equivalent for MSVC.
> 
> Yeah mingw has got `nm` or `llvm-nm`. For msvc style environments, clang-cl probably ships with `llvm-nm` as well. If not, and for pure MSVC environments (which libc++ don’t support now) you’d maybe use `dumpbin.exe` which would indeed be a more involved matter.

Makes sense. Does `llvm-nm` have support for MSVC binaries?

> > I've uploaded a new version which should hopefully fix the issue.
> 
> Thanks! Libc++ builds now, but building user code now fails
> 
> ```
> /home/martin/clang-nightly-mon/aarch64-w64-mingw32/include/c++/v1/__locale_dir/support/windows.h:186:1: error: cannot add 'abi_tag' attribute in a redeclaration
>   186 | _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
>       | ^
> /home/martin/clang-nightly-mon/aarch64-w64-mingw32/include/c++/v1/__config:566:5: note: expanded from macro '_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS'
>   566 |     _Pragma(_LIBCPP_TOSTRING(clang attribute _LibcxxExplicitABIAnnotations.push(__attribute__((                        \
>       |     ^
> <scratch space>:126:110: note: expanded from here
>   126 |  clang attribute _LibcxxExplicitABIAnnotations.push(__attribute__(( __exclude_from_explicit_instantiation__, __abi_tag__("fe210000"))), apply_to = function)
>       |                                                                                                              ^
> /home/martin/clang-nightly-mon/aarch64-w64-mingw32/include/stdlib.h:606:24: note: previous declaration is here
>   606 |   unsigned int __cdecl _rotl(unsigned int _Val,int _Shift);
>       |                        ^
> /home/martin/clang-nightly-mon/aarch64-w64-mingw32/include/c++/v1/__locale_dir/support/windows.h:186:1: error: unterminated '#pragma clang attribute push' at end of file
>   186 | _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
>       | ^
> /home/martin/clang-nightly-mon/aarch64-w64-mingw32/include/c++/v1/__config:566:5: note: expanded from macro '_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS'
>   566 |     _Pragma(_LIBCPP_TOSTRING(clang attribute _LibcxxExplicitABIAnnotations.push(__attribute__((                        \
>       |     ^
> <scratch space>:126:8: note: expanded from here
>   126 |  clang attribute _LibcxxExplicitABIAnnotations.push(__attribute__(( __exclude_from_explicit_instantiation__, __abi_tag__("fe210000"))), apply_to = function)
>       |        ^
> ```
> 
> > I don't have a windows environment available, so it's not easy to test for me.
> 
> FWIW, I do all this build testing on Linux; a cross compiling llvm-mingw environment is available by just untarring a package from https://github.com/mstorsjo/llvm-mingw/releases.

I've just tried that, but didn't get that far. Still, I think I've found the problem and updated the PR.

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


More information about the libcxx-commits mailing list