MinGW-w64 runtime library inclusion (Clang-compiled) for proper Win64 support?

kink noone at nowhere.com
Sat Jun 15 06:09:50 PDT 2013


> The thing is that Clang maps C "long double" to double as well, 
> just like MSVC. I'm not sure if that's generally the case when 
> targeting Windows or only if Clang itself has been compiled 
> with MSVC and not with MinGW.

I've just looked into the Clang sources; the "long double" 
mapping depends on the target triple, in this case specifically 
the OS component. "win32" specifies a Visual Studio target, for 
which "long double" is remapped to double (doesn't happen for the 
corresponding MinGW target). I commented out the remapping in the 
constructor of the VisualStudioWindowsX86_64TargetInfo class; the 
"long double" x87 type is now supported. A dummy function

__declspec(dllexport) long double foo(long double x) { return x + 
2.5; }

is now compiled to (dumpbin /disasm)

push        rbp
mov         rbp,rsp
sub         rsp,10h
fld         tbyte ptr [rbp+30h]
fld         st(0)
fstp        tbyte ptr [rbp-10h]
fld         dword ptr [180005698h]
faddp       st(1),st
add         rsp,10h
pop         rbp
ret

which looks quite okay. Calling it from an LDC-compiled exe still 
doesn't work though (returns NaN, probably an ABI issue). Still, 
it's an improvement. ;)


More information about the digitalmars-d-ldc mailing list