Thread overview
Cross Compiler Lniux to Win32
Dec 15, 2012
Nekroze
Dec 15, 2012
Nekroze
Dec 15, 2012
r_m_r
Dec 15, 2012
Nekroze
Dec 15, 2012
David
Dec 15, 2012
Johannes Pfau
Dec 16, 2012
Nekroze
Dec 16, 2012
Johannes Pfau
December 15, 2012
I have been thinking about starting a project recently to using llvm to make a little toy compiler however I quite dislike mingw and such on windows so was going to build a gcc cross compiler and try to make it so I can code and compile my win32 compiler (the compiler will be an exe and the code it makes will also run on windows) from linux.

However I really wanted to use D and the LLVM bindings for D but I am not sure if it is possible to cross compile for windows from linux or how to go about it.

The few things I have found around the net on such things has been about cross compiling for different CPU architectures but I still want to target x86/64 but just a different operating system.

So straight up, is DMD capable of cross compiling on linux targeting windows? I have never used the alternative D compilers (GDC, LDC etc) but are they capable of this perhaps?
December 15, 2012
On Saturday, 15 December 2012 at 13:05:32 UTC, Nekroze wrote:
> I have been thinking about starting a project recently to using llvm to make a little toy compiler however I quite dislike mingw and such on windows so was going to build a gcc cross compiler and try to make it so I can code and compile my win32 compiler (the compiler will be an exe and the code it makes will also run on windows) from linux.
>
> However I really wanted to use D and the LLVM bindings for D but I am not sure if it is possible to cross compile for windows from linux or how to go about it.
>
> The few things I have found around the net on such things has been about cross compiling for different CPU architectures but I still want to target x86/64 but just a different operating system.
>
> So straight up, is DMD capable of cross compiling on linux targeting windows? I have never used the alternative D compilers (GDC, LDC etc) but are they capable of this perhaps?

Sorry if i am a bit confusing but basically I am looking for a D compiler setup akin to MinGW on linux.
December 15, 2012
On 12/15/2012 06:35 PM, Nekroze wrote:
> So straight up, is DMD capable of cross compiling on linux targeting
> windows? I have never used the alternative D compilers (GDC, LDC etc)
> but are they capable of this perhaps?

You can try: http://gdcproject.org/wiki/Cross%20Compiler

check this thread for some details: http://forum.dlang.org/thread/k75guj$16pk$1@digitalmars.com

regards,
r_m_r
December 15, 2012
On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote:
> On 12/15/2012 06:35 PM, Nekroze wrote:
>> So straight up, is DMD capable of cross compiling on linux targeting
>> windows? I have never used the alternative D compilers (GDC, LDC etc)
>> but are they capable of this perhaps?
>
> You can try: http://gdcproject.org/wiki/Cross%20Compiler
>
> check this thread for some details: http://forum.dlang.org/thread/k75guj$16pk$1@digitalmars.com
>
> regards,
> r_m_r


Thanks r_m_r, this seems to be what i wanted a canadian-cross compiler, just didnt have the right term for it. Will have a look into this. Cheers!
December 15, 2012
Am 15.12.2012 14:56, schrieb Nekroze:
> On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote:
>> On 12/15/2012 06:35 PM, Nekroze wrote:
>>> So straight up, is DMD capable of cross compiling on linux targeting windows? I have never used the alternative D compilers (GDC, LDC etc) but are they capable of this perhaps?
>>
>> You can try: http://gdcproject.org/wiki/Cross%20Compiler
>>
>> check this thread for some details: http://forum.dlang.org/thread/k75guj$16pk$1@digitalmars.com
>>
>> regards,
>> r_m_r
> 
> 
> Thanks r_m_r, this seems to be what i wanted a canadian-cross compiler, just didnt have the right term for it. Will have a look into this. Cheers!

Good Luck! I tried this several times with different commandline options and different GCC and different GDC versions. If you get it working please let us know.
December 15, 2012
Am Sat, 15 Dec 2012 14:56:47 +0100
schrieb "Nekroze" <nekroze@eturnilnetwork.com>:

> On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote:
> > On 12/15/2012 06:35 PM, Nekroze wrote:
> >> So straight up, is DMD capable of cross compiling on linux
> >> targeting
> >> windows? I have never used the alternative D compilers (GDC,
> >> LDC etc)
> >> but are they capable of this perhaps?
> >
> > You can try: http://gdcproject.org/wiki/Cross%20Compiler
> >
> > check this thread for some details: http://forum.dlang.org/thread/k75guj$16pk$1@digitalmars.com
> >
> > regards,
> > r_m_r
> 
> 
> Thanks r_m_r, this seems to be what i wanted a canadian-cross compiler, just didnt have the right term for it. Will have a look into this. Cheers!

You don't need a canadian cross compiler. The terminology is a little
confusing, but a canadian cross compiler is if you compile _the
compiler_ on OS1, run the compiler on OS2 and the compiler generates
code for OS3. (and OS1 != OS2, OS2 != OS3)
In your case OS1==OS2==linux and OS3==mingw. This is a normal cross
compiler.

The instructions here:
http://gdcproject.org/wiki/Cross%20Compiler/crosstool-NG
should work. But the gdc windows binaries published by Daniel Green
have some additional bug fixes which are not part of the official gdc
source code so you won't get those fixes with your cross compiler.
December 16, 2012
On Saturday, 15 December 2012 at 19:46:11 UTC, Johannes Pfau wrote:
> Am Sat, 15 Dec 2012 14:56:47 +0100
> schrieb "Nekroze" <nekroze@eturnilnetwork.com>:
>
>> On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote:
>> > On 12/15/2012 06:35 PM, Nekroze wrote:
>> >> So straight up, is DMD capable of cross compiling on linux targeting
>> >> windows? I have never used the alternative D compilers (GDC, LDC etc)
>> >> but are they capable of this perhaps?
>> >
>> > You can try: http://gdcproject.org/wiki/Cross%20Compiler
>> >
>> > check this thread for some details: http://forum.dlang.org/thread/k75guj$16pk$1@digitalmars.com
>> >
>> > regards,
>> > r_m_r
>> 
>> 
>> Thanks r_m_r, this seems to be what i wanted a canadian-cross compiler, just didnt have the right term for it. Will have a look into this. Cheers!
>
> You don't need a canadian cross compiler. The terminology is a little
> confusing, but a canadian cross compiler is if you compile _the
> compiler_ on OS1, run the compiler on OS2 and the compiler generates
> code for OS3. (and OS1 != OS2, OS2 != OS3)
> In your case OS1==OS2==linux and OS3==mingw. This is a normal cross
> compiler.
>
> The instructions here:
> http://gdcproject.org/wiki/Cross%20Compiler/crosstool-NG
> should work. But the gdc windows binaries published by Daniel Green
> have some additional bug fixes which are not part of the official gdc
> source code so you won't get those fixes with your cross compiler.

See now i feel off knowing that there are patches i dont have and all...

Maybe i should wait for dmd's win64 support and compile llvm with visual studio, i wanted to target win64 really with this project and don't care much for 32bit support. This would be fine i guess so long as i could get away with being able to compile without using the llvm-config tool that gives you the library and include paths based on command line input because i am assuming i cant do something like that from a visualD or some such project.
December 16, 2012
Am Sun, 16 Dec 2012 04:02:41 +0100
schrieb "Nekroze" <nekroze@eturnilnetwork.com>:

>This would be fine i guess
> so long as i could get away with being able to compile without using the llvm-config tool that gives you the library and include paths based on command line input because i am assuming i cant do something like that from a visualD or some such project.

Well gdc's windows support is certainly not as good as dmds and dmd doesn't support cross compilation...

I guess the simplest solution is to somehow extract the needed compiler flags from llvm-config.