Difference in dmd and gdmd -lib option
Dan Olson
zans.is.for.cans at yahoo.com
Thu Nov 1 23:58:44 PDT 2012
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
More information about the D.gnu
mailing list