Dependency management in D

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 18 09:56:53 PDT 2014


On Thursday, 18 September 2014 at 16:48:22 UTC, Scott Wilson 
wrote:
> Unit of compilation is one D file but I saw if I pass several D
> files to the compiler only one .o file is generated. Whats the
> story there.

DMD will generate one object file per module file, unless you use 
the -of option. With -of, the compiler will compile all module 
files to a single object file.

> Plus if I change a non template function in one module then
> theres no way to tell make no rebuild of modules importing it.
> The dmd -deps call seems to generate all recursively. In
> gcc/makedepend if one function changes only relinking is needed
> or nothing if dynamic loading.

Yes, currently any changes, including function bodies, cause a 
rebuild of importing modules. One reason for this is CTFE - 
changing a function body can affect the code in importing modules 
if they invoke the function during compilation. You could use .di 
files to separate declarations from implementations.

> Overall as far as I understand compiler is fast but dependency
> mgmt is coarse. Also whats the deal with cyclic dependencies. I
> saw discussion that its not possible but wrote a few test 
> modules
> and it works fine.

Cyclic dependencies between modules which all have module or 
static constructors are forbidden, because it is unknown in which 
order the constructors are expected to run.


More information about the Digitalmars-d mailing list