www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Building latest LDC on windows

reply "Temtaime" <temtaime gmail.com> writes:
Hello, guys!
Wanna to investigate in LDC on windows, but can't compile 
druntime.

druntime-ldc\src\rt\trace.d(836): Error: statement not allowed in 
naked function

Seems to be LDC mistake.
Sep 05 2013
next sibling parent reply "Temtaime" <temtaime gmail.com> writes:
Also there is many errors in stdio.d

.\phobos-ldc\std\stdio.d(618): Error: undefined identifier 
'_fileno'
.\phobos-ldc\std\stdio.d(619): Error: undefined identifier 
'_setmode'
.\phobos-ldc\std\stdio.d(619): Error: undefined identifier 
_O_BINARY
.\phobos-ldc\std\stdio.d(620): Error: undefined identifier 
'_setmode'
Sep 05 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
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
Sep 05 2013
next sibling parent "Temtaime" <temtaime gmail.com> writes:
std.bigint failing to compile:

<inline asm>:1:2: error: unknown directive
         .section        
.gnu.linkonce.t._D3std8internal4math10biguintx8634__T24multibyteIncrementAssignVa45Z24multibyteIncrementAssignFNaAkkZk,"ax"
         ^
<inline asm>:17:2: error: unknown directive
         .section        
.gnu.linkonce.t._D3std8internal4math10biguintx8634__T24multibyteIncrementAssignVa43Z24multibyteIncrementAssignFNaAkkZk,"ax"
         ^
<inline asm>:33:2: error: unknown directive
         .section        
.gnu.linkonce.t._D3std8internal4math10biguintx8625__T15multibyteMulAddVa45Z15multibyteMulAddFNaAkxAkkkZk,"ax"
         ^
<inline asm>:100:2: error: unknown directive
         .section        
.gnu.linkonce.t._D3std8internal4math10biguintx8625__T15multibyteMulAddVa43Z15multibyteMulAddFNaAkxAkkkZk,"ax"
         ^
LLVM ERROR: Error parsing inline asm
Sep 05 2013
prev sibling parent reply "Kai Nacke" <kai redstar.de> writes:
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
Sep 06 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
Maybe i'll druntime rewrite to support 32 bit CRT.
Knows one what's wrong with invariants?
Thanks for any help.

Regards.
Sep 06 2013
next sibling parent reply "Temtaime" <temtaime gmail.com> writes:
How it's only the error that prevents me to build hello world 
application.
Sep 06 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
*now, of course
Sep 06 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
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.
Sep 07 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
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 = "_";
         }
Sep 07 2013
parent "Kai Nacke" <kai redstar.de> writes:
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
Sep 08 2013
prev sibling parent reply "Kai Nacke" <kai redstar.de> writes:
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
Sep 08 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
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.
Sep 08 2013
parent reply "Kai Nacke" <kai redstar.de> writes:
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
Sep 08 2013
parent reply "FreeSlave" <freeslave93 gmail.com> writes:
I have problems too.
I do 'make', but after 15% it says
"Error: cannot write native asm: Error opening output file 
'C:\Users\Roman\AppData\Local\Temp\ldc-9540aef.s'
runtime/CMakeFiles/druntime-ldc.dir/build.make:58: recipe for 
target `runtime/src/core/atomic.obj' failed
CMakeFiles/Makefile2:296: recipe for target 
`runtime/CMakeFiles/druntime-ldc.dir/all' failed
Makefile:126: recipe for target `all' failed
"

I got ldc2.exe, but when I try to compile hello world program, it 
says same thing about native asm.
Sep 12 2013
next sibling parent David Nadlinger <code klickverbot.at> writes:
On Thu, Sep 12, 2013 at 9:14 PM, FreeSlave <freeslave93 gmail.com> wrote:
 I have problems too.
 I do 'make', but after 15% it says
 "Error: cannot write native asm: Error opening output file
 'C:\Users\Roman\AppData\Local\Temp\ldc-9540aef.s'
 runtime/CMakeFiles/druntime-ldc.dir/build.make:58: recipe for target
 `runtime/src/core/atomic.obj' failed
 CMakeFiles/Makefile2:296: recipe for target
 `runtime/CMakeFiles/druntime-ldc.dir/all' failed
 Makefile:126: recipe for target `all' failed
This is indeed a regression in Git master (the Windows builds are unfortunately not part of the CI systems yet), the first bad commit seems to be https://github.com/ldc-developers/ldc/commit/272230fe595b41e6db156244793f32380eee50d8. David
Sep 13 2013
prev sibling next sibling parent David Nadlinger <code klickverbot.at> writes:
On Sat, Sep 14, 2013 at 1:17 AM, David Nadlinger <code klickverbot.at> wrote:
 This is indeed a regression in Git master (the Windows builds are
 unfortunately not part of the CI systems yet), the first bad commit
 seems to be https://github.com/ldc-developers/ldc/commit/272230fe595b41e6db156244793f32380eee50d8.
Added the issue to the tracker: https://github.com/ldc-developers/ldc/issues/471 David
Sep 13 2013
prev sibling parent David Nadlinger <code klickverbot.at> writes:
On Thu, Sep 12, 2013 at 9:14 PM, FreeSlave <freeslave93 gmail.com> wrote:
 I have problems too.
 I do 'make', but after 15% it says
 "Error: cannot write native asm: Error opening output file
 'C:\Users\Roman\AppData\Local\Temp\ldc-9540aef.s'
 runtime/CMakeFiles/druntime-ldc.dir/build.make:58: recipe for target
 `runtime/src/core/atomic.obj' failed
 CMakeFiles/Makefile2:296: recipe for target
 `runtime/CMakeFiles/druntime-ldc.dir/all' failed
 Makefile:126: recipe for target `all' failed
 "

 I got ldc2.exe, but when I try to compile hello world program, it says same
 thing about native asm.
Should be fixed in Git master. David
Sep 15 2013
prev sibling parent reply "Kai Nacke" <kai redstar.de> writes:
On Thursday, 5 September 2013 at 17:16:41 UTC, Temtaime wrote:
 Hello, guys!
 Wanna to investigate in LDC on windows, but can't compile 
 druntime.

 druntime-ldc\src\rt\trace.d(836): Error: statement not allowed 
 in naked function

 Seems to be LDC mistake.
Hi, how to you compile LDC? rt.trace.d is a part of druntime which is not supported by LDC on all platforms - it's excluded in the CMakeLists.txt file. In general, LDC can be compiled on Windows 64 using CMake with the instructions from the wiki (http://wiki.dlang.org/Building_and_hacking_LDC_on_Windows_using_MSVC). And yes, it is still alpha and every help is welcome. Regards Kai
Sep 05 2013
next sibling parent reply "Michael" <pr m1xa.com> writes:
Little bit of good news from LLVM and GoingNative
http://blog.llvm.org/2013/09/a-path-forward-for-llvm-toolchain-on.html
Sep 06 2013
parent reply "Kai Nacke" <kai redstar.de> writes:
On Friday, 6 September 2013 at 15:48:08 UTC, Michael wrote:
 Little bit of good news from LLVM and GoingNative
 http://blog.llvm.org/2013/09/a-path-forward-for-llvm-toolchain-on.html
Yeah, nice. But my patches for Win64 EH support are still in the review queue. Kai
Sep 06 2013
parent reply "Michael" <pr m1xa.com> writes:
On Friday, 6 September 2013 at 18:44:05 UTC, Kai Nacke wrote:
 On Friday, 6 September 2013 at 15:48:08 UTC, Michael wrote:
 Little bit of good news from LLVM and GoingNative
 http://blog.llvm.org/2013/09/a-path-forward-for-llvm-toolchain-on.html
Yeah, nice. But my patches for Win64 EH support are still in the review queue. Kai
I found somewhere (maybe in rust mail-lists) that patent in this field will expire at spring 2014 ;)
Sep 06 2013
parent "Kai Nacke" <kai redstar.de> writes:
On Friday, 6 September 2013 at 19:31:08 UTC, Michael wrote:
 On Friday, 6 September 2013 at 18:44:05 UTC, Kai Nacke wrote:
 On Friday, 6 September 2013 at 15:48:08 UTC, Michael wrote:
 Little bit of good news from LLVM and GoingNative
 http://blog.llvm.org/2013/09/a-path-forward-for-llvm-toolchain-on.html
Yeah, nice. But my patches for Win64 EH support are still in the review queue. Kai
I found somewhere (maybe in rust mail-lists) that patent in this field will expire at spring 2014 ;)
Nope. There is no patent on the Win64 EH handling. (But there is a patent on Win32 EH handling which expires next year.) It is simply that it is hard to get reviews. Kai
Sep 06 2013
prev sibling parent "Temtaime" <temtaime gmail.com> writes:
I'm trying to make custom project to build druntime.

Okay, i'm just dropped that file, thanks.

There is some strange errors
phobos-ldc.lib(ti_ulong.obj) : error LNK2001: unresolved external 
symbol __D9inv
ariant12_d_invariantFC6ObjectZv 4
phobos-ldc.lib(ti_ushort.obj) : error LNK2001: unresolved 
external symbol __D9in
variant12_d_invariantFC6ObjectZv 4
phobos-ldc.lib(ti_int.obj) : error LNK2001: unresolved external 
symbol __D9invar
iant12_d_invariantFC6ObjectZv 4
phobos-ldc.lib(ti_uint.obj) : error LNK2001: unresolved external 
symbol __D9inva
riant12_d_invariantFC6ObjectZv 4

Any ideas?
Sep 06 2013