Preview: LDC2 on Windows 64bit with SEH support

David Nadlinger code at klickverbot.at
Sat May 25 11:56:22 PDT 2013


On 25 May 2013, at 18:08, Kai Nacke wrote:
> 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.

Great! I'll definitely give it a try once I find a few spare minutes.

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

I suppose I need to invoke it from a Visual Studio Command Prompt (resp. 
execute the appropriate batch file first)?

> - 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 didn't think about the issue in any detail yet, but could you maybe 
use llvm::ResumeInst to work around this?

David


More information about the digitalmars-d-ldc mailing list