[llvm-dev] Supporting libunwind on Windows 10 (32bit; 64bit) for MSVC and Clang

Martin Storsjö via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 16 13:42:28 PDT 2020


On Sat, 15 Aug 2020, Ivan Serdyuk wrote:

> 
> 
> On Sat, Aug 15, 2020 at 8:39 PM Martin Storsjö <martin at martin.st> wrote:
>       Hi,
> 
>
>       On Sat, 15 Aug 2020, Ivan Serdyuk wrote:
>
>       >       Just as Shoaib said, libunwind only is useful in
>       environments
>       >       that use
>       >       the Itanium C++ ABI - there's really no use for it in an
>       MSVC
>       >       context
>       >       (either using MSVC or clang-cl to compile it).
>       >
>       >       The particular linker error comes from the fact that
>       there's
>       >       functions
>       >       implemented in assembly, that expect the function name
>       to be
>       >       mangled the
>       >       itanium way, while the object files built by the
>       compiler expect
>       >       the
>       >       symbols to use the MSVC C++ name mangling, so there's an
>       >       undefined
>       >       reference.
>       >
>       >
>       > I see, thanks.
>       >
>       > Which options exist for MSVC, in sense an alternative to
>       libunwind and
>       > libbacktrace ?
>
>       Well for libunwind, there's really no use for it in an MSVC
>       setting. All
>       the unwinding functionality is already built into the operating
>       system,
>       available via the Rtl*Unwind* functions.
> 
> 
> Martin,
> you mean these functions
> https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtlunwind
> 
> https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtlunwind
> 2
> https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtlunwind
> ex
> https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtlvirtua
> lunwind
> ?

Yes, those are the functions used for unwinding on windows.

>       For libbacktrace, I guess the _Unwind_Backtrace function in
>       libunwind
>       might work and be useful, even if the rest of libunwind doesn't
>       make sense
>       in such a context.

Just FWIW, I made a RFC patch that fixes building libunwind in MSVC mode 
(still requiring clang-cl though), at https://reviews.llvm.org/D86041 - 
mostly just to show what it takes - not convinced that it necessarily is 
something that should be done.

It does seem like _Unwind_Backtrace in libunwind doesn't work properly on 
x86_64 windows at the moment though, but on aarch64 it seems to do what 
one would expect.

// Martin


More information about the llvm-dev mailing list