[cfe-dev] LLVM/Clang and setjmp/longjmp exception handling on MinGW

Ruben Van Boxem vanboxem.ruben at gmail.com
Tue Nov 1 06:06:19 PDT 2011


2011/11/1 David Chisnall <csdavec at swan.ac.uk>

> Nope.  SEH is not the right way of implementing exceptions on Win64 (it's
> not really the right way of implementing C++ exceptions on Win32 either).
>  The right way is to use the Win64 exception ABI:
>
> http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx
>
> This is not patented, and is fairly similar to the DWARF zero-cost model,
> just with (in typical Microsoft fashion) different layouts for everything.
>  The exception model in LLVM IR would map very cleanly to this, but (as far
> as I know) no one is working on it yet.  It would be possible to use the
> same LSDA format as on other platforms, and just provide a struct
> UNWIND_INFO for each function pointing to this, with fairly minimal changes
> to the personality function.  I'd be happy to make these changes in
> libcxxrt...
>

What about associated stack unwinding? I'm not quite familiar with all
this, and am kind of going half-blind on anything Google pops up. I did
take a look at the Win64 EH specification, but couldn't find the link to
what's happening in libcxxrt. And libcxxrt depends on libunwind or similar,
so that needs to be handled appropriately as well. I would very much
appreciate if you could make those changes to libcxxrt, although I'm unsure
if I'm able to do anything sensible here...

2011/11/1 NAKAMURA Takumi <geek4civic at gmail.com>

> 2011/11/1 Ruben Van Boxem <vanboxem.ruben at gmail.com>:
> > GCC doesn't have any Dwarf exception handling on 64-bit Windows, due to
> it
> > being either extremely hard or impossible to get right. I would like to
> get
> > Clang to produce working exception code for Windows. The "right way" is
> > patented (SEH), so pretty of limits to anyone not from MS (or Borland,
> the
> > patent holder). I'm not trying to wake up this discussion again. I just
> want
> > to enable/implement/fix sjlj exception handling for Windows, in
> hopefully a
> > MinGW GCC compatible way.
>
> As called the patent is Win32 x86 specific implementations, IANAL.
>
> Charles Davis had been working on implementing x64 EH. I don't know
> how they work.
> Ruben, I suppose Kai has been working for x64 EH, right?
> (it is dw2-like implementation, IIRC)
>
> Anyway, would you like us to implement sjlj on win32 x86?
>

As it stands, Windows+Clang == no working exceptions, which... sucks. It
would be nice to have a nasty sjlj fallback untill the "proper" solution
arrives. I was trying to enable this for MinGW at least in Clang, but it
seems adding a bool UseSjLjExceptions() const; to the Windows Toolchain
that returns true isn't doing anything :(

Ruben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111101/5707ca28/attachment.html>


More information about the cfe-dev mailing list