September 06, 2013
On Thursday, 5 September 2013 at 17:37:51 UTC, Temtaime wrote:
> Seems that ldc doesn't support MSVC I/O.
>
> Also errors in mixins
>
> .\phobos-ldc\std\internal\digest\sha_SSSE3.d(651): Error: matching '}' expected, not end of file

Are you trying to create a 32bit build? Druntime does not support MS CRT in 32bit mode. That is a heritage of dmd which uses the dmc runtime for 32bit.

(The refactoring for 32bit is on my todo list.)

Kai
September 06, 2013
Maybe i'll druntime rewrite to support 32 bit CRT.
Knows one what's wrong with invariants?
Thanks for any help.

Regards.
September 06, 2013
How it's only the error that prevents me to build hello world application.
September 06, 2013
*now, of course
September 07, 2013
I figured out the bug.

test.d:
int foo() { asm { naked; xor EAX, EAX; ret; } }

ldc2 test.d -c

When looking obj file:
foo named as _D4test3fooFZi

If i remove "naked" then function named as __D4test3fooFZi that is correct.

I'll look at naked functions declaration.
September 07, 2013
Oh, it's need to rewrite the if in naked.cpp

        if (global.params.targetTriple.getOS() == llvm::Triple::MinGW32)
        {
            fullMangle = "_";
        }

To

        if (global.params.targetTriple.getOS() == llvm::Triple::MinGW32 || global.params.targetTriple.getOS() == llvm::Triple::Win32)
        {
            fullMangle = "_";
        }
September 08, 2013
On Saturday, 7 September 2013 at 16:20:00 UTC, Temtaime wrote:
> Oh, it's need to rewrite the if in naked.cpp
>
>         if (global.params.targetTriple.getOS() == llvm::Triple::MinGW32)
>         {
>             fullMangle = "_";
>         }
>
> To
>
>         if (global.params.targetTriple.getOS() == llvm::Triple::MinGW32 || global.params.targetTriple.getOS() == llvm::Triple::Win32)
>         {
>             fullMangle = "_";
>         }

Thanks for tracking this down. I committed your suggested change right.

Regards
Kai
September 08, 2013
On Friday, 6 September 2013 at 20:59:06 UTC, Temtaime wrote:
> Maybe i'll druntime rewrite to support 32 bit CRT.
> Knows one what's wrong with invariants?
> Thanks for any help.
>
> Regards.

Hi Temtaime,

in most case the situation in Druntime is as follows:

- a check for Win32 implies the DigitalMars runtime
- a check for Win64 implies the Microsoft runtime

The obvious fix is to distinguish betweeb the runtimes, e.g.:

version( DigitalMars )
{
    version( Win32 )
        version = DMCRT;
    version( Win64 )
        version = MSVCRT;
}
version( LDC )
{
    version( Win32 )
        version = MSVCRT;
    version( Win64 )
        version = MSVCRT;
}

and then consequently using DMCRT and MSVCRT.

Regards
Kai
September 08, 2013
I've fixed runtime to use MSVCRT, everything except one goes ok.

Now last problem is on handling exceptions. LDC uses DWARF2 functions from GCC.
Why not instrinsics from LLVM? LLVM supports SJLJ exception handling.

http://llvm.org/docs/ExceptionHandling.html

I don't know just now how properly rewrite exception handling in LDC to use LLVM functions.

I'll respect the one who can help deal with it.
September 08, 2013
On Sunday, 8 September 2013 at 14:26:08 UTC, Temtaime wrote:
> I've fixed runtime to use MSVCRT, everything except one goes ok.
>
> Now last problem is on handling exceptions. LDC uses DWARF2 functions from GCC.
> Why not instrinsics from LLVM? LLVM supports SJLJ exception handling.
>
> http://llvm.org/docs/ExceptionHandling.html
>
> I don't know just now how properly rewrite exception handling in LDC to use LLVM functions.
>
> I'll respect the one who can help deal with it.

Hi Temtaime,

LLVM uses solely Dwarf EH handling. But the implementation differs: if the unwind functions from libgcc are available then they are used (e.g. Linux). If not available then SJLJ is used (if implemented) or the handling from the OS (as my Win64 patch does). If nothing is implemeted (e.g. Win32) then exceptions are simply ignored.

I once had a look into SJLJ EH lowering but it is complicated, too.

Regards
Kai