Thread overview
dmd as link driver
Aug 13, 2010
SK
Aug 13, 2010
Walter Bright
Aug 13, 2010
SK
Aug 13, 2010
Trass3r
August 13, 2010
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


August 13, 2010
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.
August 13, 2010
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).
August 13, 2010
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)