www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - dmd as link driver

reply SK <sk metrokings.com> writes:
Hello D'ers,

Can dmd drive the linking process in two step compile-then-link builds?

Lacking this capability complicates the CMake discovery process that uses
small test compiles.  In short, the problem is that CMake needs, but does
not have, full knowledge of the C environment (to handle linking) before
testing the D environment.  I'm not a cmake expert, but I don't think I can
express this dependency between two tool chains.  A few experiments have
failed to get this working.

If the answer is that dmd cannot drive the linker, would a patch be easy
enough to consider?

-steve
Aug 12 2010
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
SK wrote:
 Can dmd drive the linking process in two step compile-then-link builds?
 
 Lacking this capability complicates the CMake discovery process that 
 uses small test compiles.  In short, the problem is that CMake needs, 
 but does not have, full knowledge of the C environment (to handle 
 linking) before testing the D environment.  I'm not a cmake expert, but 
 I don't think I can express this dependency between two tool chains.  A 
 few experiments have failed to get this working.
 
 If the answer is that dmd cannot drive the linker, would a patch be easy 
 enough to consider?
dmd does drive the linker. For example: dmd test will compile test.d and link it to form the test.exe executable. Similarly, dmd test.obj will just perform the link step.
Aug 13 2010
parent SK <sk metrokings.com> writes:
On Fri, Aug 13, 2010 at 1:02 AM, Walter Bright
<newshound2 digitalmars.com>wrote:

 dmd does drive the linker. For example:
Oops, sorry. I was thrown off the trail by the -L-l syntax for including a library. Gnu is my comfort zone and I went there without thinking. $ dmd -w -wi -c main.d $ dmd main.o -lphobos2 Error: unrecognized switch '-lphobos2' $ dmd main.o -L-lphobos2 (success)
Aug 13 2010
prev sibling parent Trass3r <un known.com> writes:
You can easily separate compilation and linking by using the -c option to  
just compile source files and then passing the object files to dmd to link  
it (or even invoke link yourself).
Aug 13 2010