www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DMD cross compiler

reply Manu <turkeyman gmail.com> writes:
I know there's been discussion on this before, I just want a
definitive reference.

It looks like it would be relatively straight forward for DMD to be a
cross-compiler.
A few version() statements could be runtime if's, and that's pretty much it.
When hacking on parts of DMD, I frequently make hacks that turn such
versions into runtime if's to test multiple targets from the one dev
workflow.

It would be about 100 times more convenient to supply an arg, than
make hacks all over the code... so, why not?
Sep 01 2018
next sibling parent reply Joakim <dlang joakim.fea.st> writes:
On Saturday, 1 September 2018 at 20:12:24 UTC, Manu wrote:
 I know there's been discussion on this before, I just want a 
 definitive reference.

 It looks like it would be relatively straight forward for DMD 
 to be a
 cross-compiler.
 A few version() statements could be runtime if's, and that's 
 pretty much it.
 When hacking on parts of DMD, I frequently make hacks that turn 
 such
 versions into runtime if's to test multiple targets from the 
 one dev
 workflow.

 It would be about 100 times more convenient to supply an arg, 
 than make hacks all over the code... so, why not?
What specifically do you want to cross-compile to, something like Windows to macOS? LDC already does all this, ie the one compiler cross-compiles to every other platform with a single flag, may just want to use it.
Sep 01 2018
next sibling parent Manu <turkeyman gmail.com> writes:
On Sat, 1 Sep 2018 at 18:55, Joakim via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Saturday, 1 September 2018 at 20:12:24 UTC, Manu wrote:
 I know there's been discussion on this before, I just want a
 definitive reference.

 It looks like it would be relatively straight forward for DMD
 to be a
 cross-compiler.
 A few version() statements could be runtime if's, and that's
 pretty much it.
 When hacking on parts of DMD, I frequently make hacks that turn
 such
 versions into runtime if's to test multiple targets from the
 one dev
 workflow.

 It would be about 100 times more convenient to supply an arg,
 than make hacks all over the code... so, why not?
What specifically do you want to cross-compile to, something like Windows to macOS? LDC already does all this, ie the one compiler cross-compiles to every other platform with a single flag, may just want to use it.
Yes, but we're talking about DMD...
Sep 01 2018
prev sibling parent reply bauss <jj_1337 live.dk> writes:
On Sunday, 2 September 2018 at 01:52:18 UTC, Joakim wrote:
 On Saturday, 1 September 2018 at 20:12:24 UTC, Manu wrote:
 I know there's been discussion on this before, I just want a 
 definitive reference.

 It looks like it would be relatively straight forward for DMD 
 to be a
 cross-compiler.
 A few version() statements could be runtime if's, and that's 
 pretty much it.
 When hacking on parts of DMD, I frequently make hacks that 
 turn such
 versions into runtime if's to test multiple targets from the 
 one dev
 workflow.

 It would be about 100 times more convenient to supply an arg, 
 than make hacks all over the code... so, why not?
What specifically do you want to cross-compile to, something like Windows to macOS? LDC already does all this, ie the one compiler cross-compiles to every other platform with a single flag, may just want to use it.
Not everyone can or want to use LDC.
Sep 03 2018
parent reply Joakim <dlang joakim.fea.st> writes:
On Monday, 3 September 2018 at 09:21:21 UTC, bauss wrote:
 On Sunday, 2 September 2018 at 01:52:18 UTC, Joakim wrote:
 On Saturday, 1 September 2018 at 20:12:24 UTC, Manu wrote:
 [...]
What specifically do you want to cross-compile to, something like Windows to macOS? LDC already does all this, ie the one compiler cross-compiles to every other platform with a single flag, may just want to use it.
Not everyone can or want to use LDC.
Why not? If you're not optimizing or iterating on your code, it's a reasonable replacement. If you're optimizing, you should only be using LDC or gdc.
Sep 03 2018
next sibling parent Manu <turkeyman gmail.com> writes:
On Mon, 3 Sep 2018 at 02:35, Joakim via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Monday, 3 September 2018 at 09:21:21 UTC, bauss wrote:
 On Sunday, 2 September 2018 at 01:52:18 UTC, Joakim wrote:
 On Saturday, 1 September 2018 at 20:12:24 UTC, Manu wrote:
 [...]
What specifically do you want to cross-compile to, something like Windows to macOS? LDC already does all this, ie the one compiler cross-compiles to every other platform with a single flag, may just want to use it.
Not everyone can or want to use LDC.
Why not? If you're not optimizing or iterating on your code, it's a reasonable replacement. If you're optimizing, you should only be using LDC or gdc.
DMD is for iterating on DMD ;) Making DMD patches in LDC and then pushing upstream is much more of a hassle. DMD build/iteration time is super fast too.
Sep 03 2018
prev sibling parent reply Laurent =?UTF-8?B?VHLDqWd1aWVy?= <laurent.treguier.sink gmail.com> writes:
On Monday, 3 September 2018 at 09:32:29 UTC, Joakim wrote:
 Why not? If you're not optimizing or iterating on your code, 
 it's a reasonable replacement. If you're optimizing, you should 
 only be using LDC or gdc.
What if you want to reproduce a bug that only happens when compiling with dmd for some weird reason ? Or what if you want to use the very latest features from dmd nightlies ?
Sep 03 2018
parent reply Iain Buclaw <ibuclaw gdcproject.org> writes:
On 3 September 2018 at 15:12, Laurent Tréguier via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Monday, 3 September 2018 at 09:32:29 UTC, Joakim wrote:
 Why not? If you're not optimizing or iterating on your code, it's a
 reasonable replacement. If you're optimizing, you should only be using LDC
 or gdc.
What if you want to reproduce a bug that only happens when compiling with dmd for some weird reason ? Or what if you want to use the very latest features from dmd nightlies ?
GDC is kept in sync with dmd nightlies on a weekly or twice-weekly basis.
Sep 03 2018
next sibling parent Laurent =?UTF-8?B?VHLDqWd1aWVy?= <laurent.treguier.sink gmail.com> writes:
On Monday, 3 September 2018 at 14:00:58 UTC, Iain Buclaw wrote:
 GDC is kept in sync with dmd nightlies on a weekly or 
 twice-weekly basis.
I saw the post about using the 2.081 frontend, but I didn't know about that. That's great, thanks for the info !
Sep 03 2018
prev sibling parent bauss <jj_1337 live.dk> writes:
On Monday, 3 September 2018 at 14:00:58 UTC, Iain Buclaw wrote:
 On 3 September 2018 at 15:12, Laurent Tréguier via 
 Digitalmars-d <digitalmars-d puremagic.com> wrote:
 On Monday, 3 September 2018 at 09:32:29 UTC, Joakim wrote:
 Why not? If you're not optimizing or iterating on your code, 
 it's a reasonable replacement. If you're optimizing, you 
 should only be using LDC or gdc.
What if you want to reproduce a bug that only happens when compiling with dmd for some weird reason ? Or what if you want to use the very latest features from dmd nightlies ?
GDC is kept in sync with dmd nightlies on a weekly or twice-weekly basis.
Sometimes all you got are a few hours when working professionally.
Sep 03 2018
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On Saturday, 1 September 2018 at 20:12:24 UTC, Manu wrote:
 I know there's been discussion on this before, I just want a 
 definitive reference.

 It looks like it would be relatively straight forward for DMD 
 to be a
 cross-compiler.
 A few version() statements could be runtime if's, and that's 
 pretty much it.
 When hacking on parts of DMD, I frequently make hacks that turn 
 such
 versions into runtime if's to test multiple targets from the 
 one dev
 workflow.

 It would be about 100 times more convenient to supply an arg, 
 than make hacks all over the code... so, why not?
Yeah, I don't see a reason why DMD should not be a cross-compiler. I've been thinking the same thing as well. -- /Jacob Carlborg
Sep 03 2018
parent Manu <turkeyman gmail.com> writes:
On Mon, 3 Sep 2018 at 01:40, Jacob Carlborg via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Saturday, 1 September 2018 at 20:12:24 UTC, Manu wrote:
 I know there's been discussion on this before, I just want a
 definitive reference.

 It looks like it would be relatively straight forward for DMD
 to be a
 cross-compiler.
 A few version() statements could be runtime if's, and that's
 pretty much it.
 When hacking on parts of DMD, I frequently make hacks that turn
 such
 versions into runtime if's to test multiple targets from the
 one dev
 workflow.

 It would be about 100 times more convenient to supply an arg,
 than make hacks all over the code... so, why not?
Yeah, I don't see a reason why DMD should not be a cross-compiler. I've been thinking the same thing as well.
Not being a cross-compiler makes iteration and testing unnecessarily hard and slow. We should try and reduce friction to developing DMD. Not being a cross-compiler has definitely stopped me on multiple instances on account of "ah, it's all just too hard!".
Sep 03 2018