Preview: LDC2 on Windows 64bit with SEH support

Kai Nacke kai at redstar.de
Sat May 25 09:08:19 PDT 2013


As promised at DConf I continued my work on the exception 
handling issue on Win64. The wiki page 
http://wiki.dlang.org/Building_and_hacking_LDC_on_Windows_using_MSVC
contains now a patch against LLVM head which enables exception 
support on Win64.

If you are curious but don't want to build LDC yourself you can 
also download a
preview version here: http://www.redstar.de/ldc/LDC.zip (MD5: 
fb149c3575cd2c35f56e4e10c19046fc).
This build is based on the upcoming 0.11.0 release and LLVM 3.4 
head with my patch applied.

Prerequisite: You need VS 2012 installed for the linker and the 
CRT dll. (Any version should do, including the C++ express 
version.)

This version has only alpha quality and contains known bugs:

- Non-ABI-compliant code is generated for aligned variables on 
the stack.
   This should be no issue if you do not use the vector extension.

- The epilogue core is always required to get the stack unwinding 
right.
   Unfortunately LLVM does not generate the epilogue code if it 
can prove that it is really dead code. E.g.:

void doIt()
{
     printf("doIt: start\n");
     try
     {
         printf("doIt: try\n");
         throw new Exception("Failure");
     }
     catch (OutOfMemoryError) {}
     finally
     {
         printf("doIt: finally\n");
     }
     printf("doIt: end\n");
}

This works as expected. But if you remove the catch statement 
then the application crashes. Root cause is that LLVM knows that 
everything after the throw is unreachable and therefore dead 
code. The last generated instruction in this function is a call 
to _d_resume_unwind. Without the epilogue code the unwind fails.

I like to get feedback on the implementation. I am quite sure 
that there are other bugs lurking around. Feel free to report any 
bug in our issue tracker at 
https://github.com/ldc-developers/ldc/issues/166 or in this forum.

Regards
Kai


More information about the digitalmars-d-ldc mailing list