www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Cross Compiler

reply "Jeroen Bollen" <jbinero gmail.com> writes:
Is there a DMD cross compiler, or am I forced to use the GDC? I 
don't really mind using GDC, but I've always preferred DMD for 
some odd reason. I guess it has some good point, like faster 
compilation time and more up-to-date.
Mar 02 2014
next sibling parent reply "Mathias LANG" <pro.mathias.lang gmail.com> writes:
On Sunday, 2 March 2014 at 21:08:38 UTC, Jeroen Bollen wrote:
 Is there a DMD cross compiler, or am I forced to use the GDC? I 
 don't really mind using GDC, but I've always preferred DMD for 
 some odd reason. I guess it has some good point, like faster 
 compilation time and more up-to-date.
I never tried for myself, but DMD is supposed to be able to be a cross compiler (see src/mars.h). Of course this apply only if you are targeting x86 / x86_64. If you want an ARM cross compiler you have to stick with LDC / GDC AFAIK.
Mar 02 2014
parent reply "Jeroen Bollen" <jbinero gmail.com> writes:
On Sunday, 2 March 2014 at 21:39:11 UTC, Mathias LANG wrote:
 On Sunday, 2 March 2014 at 21:08:38 UTC, Jeroen Bollen wrote:
 Is there a DMD cross compiler, or am I forced to use the GDC? 
 I don't really mind using GDC, but I've always preferred DMD 
 for some odd reason. I guess it has some good point, like 
 faster compilation time and more up-to-date.
I never tried for myself, but DMD is supposed to be able to be a cross compiler (see src/mars.h). Of course this apply only if you are targeting x86 / x86_64. If you want an ARM cross compiler you have to stick with LDC / GDC AFAIK.
Am I correct saying no special flags are required?
Mar 02 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Sunday, 2 March 2014 at 21:40:50 UTC, Jeroen Bollen wrote:
 On Sunday, 2 March 2014 at 21:39:11 UTC, Mathias LANG wrote:
 On Sunday, 2 March 2014 at 21:08:38 UTC, Jeroen Bollen wrote:
 Is there a DMD cross compiler, or am I forced to use the GDC? 
 I don't really mind using GDC, but I've always preferred DMD 
 for some odd reason. I guess it has some good point, like 
 faster compilation time and more up-to-date.
I never tried for myself, but DMD is supposed to be able to be a cross compiler (see src/mars.h). Of course this apply only if you are targeting x86 / x86_64. If you want an ARM cross compiler you have to stick with LDC / GDC AFAIK.
Am I correct saying no special flags are required?
-m32 / -m64 control target platform for DMD. For ARM + GDC/LDC you should check their wiki's / manuals.
Mar 02 2014
parent "Jeroen Bollen" <jbinero gmail.com> writes:
On Sunday, 2 March 2014 at 21:49:28 UTC, Dicebot wrote:
 On Sunday, 2 March 2014 at 21:40:50 UTC, Jeroen Bollen wrote:
 On Sunday, 2 March 2014 at 21:39:11 UTC, Mathias LANG wrote:
 On Sunday, 2 March 2014 at 21:08:38 UTC, Jeroen Bollen wrote:
 Is there a DMD cross compiler, or am I forced to use the 
 GDC? I don't really mind using GDC, but I've always 
 preferred DMD for some odd reason. I guess it has some good 
 point, like faster compilation time and more up-to-date.
I never tried for myself, but DMD is supposed to be able to be a cross compiler (see src/mars.h). Of course this apply only if you are targeting x86 / x86_64. If you want an ARM cross compiler you have to stick with LDC / GDC AFAIK.
Am I correct saying no special flags are required?
-m32 / -m64 control target platform for DMD. For ARM + GDC/LDC you should check their wiki's / manuals.
Al right, thanks!
Mar 02 2014
prev sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
If you want to build a Windows exe on Linux, you can also just 
run the windows version of dmd in wine.
Mar 02 2014
parent reply "Jeroen Bollen" <jbinero gmail.com> writes:
How to stop DMD from linking against any libraries? A simple 
program like this already links to quite a few libraries:

 void main()
 {
         return;
 }
	linux-vdso.so.1 =>  (0x00007fffdf5fe000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007f3ba9433000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 
(0x00007f3ba912f000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 
(0x00007f3ba8f26000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 
(0x00007f3ba8b5e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3ba9679000)
Mar 03 2014
next sibling parent "Jeroen Bollen" <jbinero gmail.com> writes:
On Monday, 3 March 2014 at 14:31:09 UTC, Jeroen Bollen wrote:
 How to stop DMD from linking against any libraries? A simple 
 program like this already links to quite a few libraries:

 void main()
 {
        return;
 }
	linux-vdso.so.1 =>  (0x00007fffdf5fe000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007f3ba9433000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 
(0x00007f3ba912f000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 
(0x00007f3ba8f26000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 
(0x00007f3ba8b5e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3ba9679000)
I'm guessing this is caused by the presence of the main method. Why would a single method require all those libraries though?
Mar 03 2014
prev sibling parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
"Jeroen Bollen"  wrote in message 
news:unvhloslmpxvxhawypoq forum.dlang.org...

 How to stop DMD from linking against any libraries? A simple program like 
 this already links to quite a few libraries:
The easiest way is to link yourself. You can run dmd with -v to get the link command and start from there.
Mar 03 2014
parent reply "Jeroen Bollen" <jbinero gmail.com> writes:
On Monday, 3 March 2014 at 15:36:02 UTC, Daniel Murphy wrote:
 "Jeroen Bollen"  wrote in message 
 news:unvhloslmpxvxhawypoq forum.dlang.org...

 How to stop DMD from linking against any libraries? A simple 
 program like this already links to quite a few libraries:
The easiest way is to link yourself. You can run dmd with -v to get the link command and start from there.
Cheers
Mar 03 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Monday, 3 March 2014 at 15:44:30 UTC, Jeroen Bollen wrote:
 On Monday, 3 March 2014 at 15:36:02 UTC, Daniel Murphy wrote:
 "Jeroen Bollen"  wrote in message 
 news:unvhloslmpxvxhawypoq forum.dlang.org...

 How to stop DMD from linking against any libraries? A simple 
 program like this already links to quite a few libraries:
The easiest way is to link yourself. You can run dmd with -v to get the link command and start from there.
Cheers
Please be aware of https://d.puremagic.com/issues/show_bug.cgi?id=12268 though
Mar 03 2014
parent reply "Jeroen Bollen" <jbinero gmail.com> writes:
On Monday, 3 March 2014 at 16:21:25 UTC, Dicebot wrote:
 On Monday, 3 March 2014 at 15:44:30 UTC, Jeroen Bollen wrote:
 On Monday, 3 March 2014 at 15:36:02 UTC, Daniel Murphy wrote:
 "Jeroen Bollen"  wrote in message 
 news:unvhloslmpxvxhawypoq forum.dlang.org...

 How to stop DMD from linking against any libraries? A simple 
 program like this already links to quite a few libraries:
The easiest way is to link yourself. You can run dmd with -v to get the link command and start from there.
Cheers
Please be aware of https://d.puremagic.com/issues/show_bug.cgi?id=12268 though
Is any sort of static linkage really necessary though?
Mar 03 2014
parent reply "Jeroen Bollen" <jbinero gmail.com> writes:
On Monday, 3 March 2014 at 17:21:50 UTC, Jeroen Bollen wrote:
 On Monday, 3 March 2014 at 16:21:25 UTC, Dicebot wrote:
 Please be aware of
 https://d.puremagic.com/issues/show_bug.cgi?id=12268 though
Is any sort of static linkage really necessary though?
Seems like it is, without specifying the libraries I get an error: app.o: In function `main': app.d:(.text.main+0x13): undefined reference to `_d_run_main' app.o:(.text.d_dso_init[.data.d_dso_rec]+0x32): undefined reference to `_d_dso_registry' collect2: error: ld returned 1 exit status
Mar 03 2014
parent reply "Jeroen Bollen" <jbinero gmail.com> writes:
Just realized that's probably the missing runtime. Why does it 
need a runtime though? It's just returning.
Mar 03 2014
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Monday, 3 March 2014 at 19:03:20 UTC, Jeroen Bollen wrote:
 Just realized that's probably the missing runtime. Why does it 
 need a runtime though? It's just returning.
There's some hidden references to the runtime outputted, especially when you write a D main, which adds references to d_run_main and other such stuff. If you make it an extern(C) main instead of a regular D main, it gets rid of some of that, but it will still complain about the d_dso_registry thing (at least on Linux). You can add a dummy "extern(C) void _d_dso_registry() {}" to it to hack past that too, but you probably shouldn't - going without the runtime is a fair amount of work for little practical benefit, though it can be pretty educational. The definition of this function in druntime is src/rt/sections_linux.d From that file: /* For each shared library and executable, the compiler generates code that * sets up CompilerDSOData and calls _d_dso_registry(). * A pointer to that code is inserted into both the .ctors and .dtors * segment so it gets called by the loader on startup and shutdown. */ extern(C) void _d_dso_registry(CompilerDSOData* data)
Mar 03 2014
parent "Jeroen Bollen" <jbinero gmail.com> writes:
On Tuesday, 4 March 2014 at 01:22:15 UTC, Adam D. Ruppe wrote:
 On Monday, 3 March 2014 at 19:03:20 UTC, Jeroen Bollen wrote:
 Just realized that's probably the missing runtime. Why does it 
 need a runtime though? It's just returning.
There's some hidden references to the runtime outputted, especially when you write a D main, which adds references to d_run_main and other such stuff. If you make it an extern(C) main instead of a regular D main, it gets rid of some of that, but it will still complain about the d_dso_registry thing (at least on Linux). You can add a dummy "extern(C) void _d_dso_registry() {}" to it to hack past that too, but you probably shouldn't - going without the runtime is a fair amount of work for little practical benefit, though it can be pretty educational. The definition of this function in druntime is src/rt/sections_linux.d From that file: /* For each shared library and executable, the compiler generates code that * sets up CompilerDSOData and calls _d_dso_registry(). * A pointer to that code is inserted into both the .ctors and .dtors * segment so it gets called by the loader on startup and shutdown. */ extern(C) void _d_dso_registry(CompilerDSOData* data)
What does the runtime actually do?
Mar 04 2014