www.digitalmars.com         C & C++   DMDScript  

D.gnu - Difference in dmd and gdmd -lib option

reply Dan Olson <zans.is.for.cans yahoo.com> writes:
I am coming back to D fun after a year.  I am playing on osx 10.6 and just
built native gdc last weekend using github gdc-4.7.

Sorry if this has been discussed before, but my searches could not find
it.  I discovered that dmd and gdmd -lib behave different. I really like
the way dmd -lib option works.  Is this known, expected, or something
that should be fixed?

dmd -lib breaks up a d module (file) into separate compilation units so,
for example, if a d module has 5 funtions, the library will have 5 or
more .o (one for each function).  If you link to only one of those
functions, you only get it in your final executable.

gdmd does not.  It produces a single .o per d module

The beauty of the dmd approach is that I can call D code from an objc
program, and only the parts of the dmain2.d needed are linked in
(rt_init/rt_term).  With gdc, I can't get rt_init() and rt_term()
without also getting the dmain2's extern(C) main().

So I am forced to have D be main.  Or I must go in and break up dmain2.d
into smaller code pieces if I want to have D libs callable by objc.

I am switching to gdc because "I have a Dream" that one day D can be
used to write ios apps.  And gdc has the arm ISA so I can cross-compile.
So it is closer than dmd.  I know eventually it will need a rewritten
druntime, but my baby step is to just compile a D function and call it
from an ios app.  But even tinier step I am on now is to call a D
function from iphone sim (which uses i386).

Thanks and many adventures,
Dan
Nov 01 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-11-02 07:58, Dan Olson wrote:

 I am switching to gdc because "I have a Dream" that one day D can be
 used to write ios apps.  And gdc has the arm ISA so I can cross-compile.
 So it is closer than dmd.  I know eventually it will need a rewritten
 druntime, but my baby step is to just compile a D function and call it
 from an ios app.  But even tinier step I am on now is to call a D
 function from iphone sim (which uses i386).
Cool, I also tried this, with DMD tough. I didn't get very far, there are functionality that DMD needs that's missing from the iPhone SDK. -- /Jacob Carlborg
Nov 02 2012
parent reply Dan Olson <zans.is.for.cans yahoo.com> writes:
Jacob Carlborg <doob me.com> writes:

 Cool, I also tried this, with DMD tough. I didn't get very far, there
 are functionality that DMD needs that's missing from the iPhone SDK.
Jacob, how far did you get? A couple years ago I started building a bare druntime. Not too useful because I stripped GC and with that goes classes, delagates, dynamic arrays, and other stuff I don't recall. I was going for small embedded use of D (not ios) and wanted to see how much of the language required GC support. Anyway, I was thinking of reviving some of that to build a minimal support runtime for arm/ios, but leave the GC in since ios is not a small embedded system. Eventualy add more and more of phobos. The reason I want to do this is that I think objective-c should just be one of those interesting hybrid languages in the evolution tree, but should begin to die off since modern languages are so better designed (my opinion). I read a post in D newsgroup years ago about a compiler mod that allows D to use objective-C style method dispatch (by M. Fortin? or somebody like that - I'd have to search). An ARM D with his feature, then you can use D to write for ios. It would make programming fun! Well, more fun.
Nov 02 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-11-02 17:12, Dan Olson wrote:

 Jacob, how far did you get?
I didn't try much, I never was able to compile DMD with the SDK used buy the simulator. One thing I know was missing was the Gestalt function, it's used to get information about Mac OS X, like what exact version.
 A couple years ago I started building a bare druntime. Not too useful
 because I stripped GC and with that goes classes, delagates, dynamic
 arrays, and other stuff I don't recall. I was going for small embedded
 use of D (not ios) and wanted to see how much of the language required
 GC support.

 Anyway, I was thinking of reviving some of that to build a minimal
 support runtime for arm/ios, but leave the GC in since ios is not a
 small embedded system. Eventualy add more and more of phobos.

 The reason I want to do this is that I think objective-c should just be
 one of those interesting hybrid languages in the evolution tree, but
 should begin to die off since modern languages are so better designed
 (my opinion). I read a post in D newsgroup years ago about a compiler
 mod that allows D to use objective-C style method dispatch (by M.
 Fortin? or somebody like that - I'd have to search). An ARM D with his
 feature, then you can use D to write for ios. It would make programming
 fun!  Well, more fun.
That would be so cool to have. The DMD fork you referring to would be this one by Michel Fortin: http://michelf.ca/projects/d-objc/ There's an alpha version available but it's getting quite old now. -- /Jacob Carlborg
Nov 02 2012