Incremental compilation with DMD

Tom S h3r3tic at remove.mat.uni.torun.pl
Sun Sep 13 15:18:05 PDT 2009


Don wrote:
> Walter Bright wrote:
>> Tom S wrote:
>>> Walter Bright wrote:
>>>> What you can try is creating a database that is basically a lib 
>>>> (call it A.lib) of all the modules compiled with -lib. Then 
>>>> recompile all modules that depend on changed modules in one command, 
>>>> also with -lib, call it B.lib. Then for all the obj's in B, replace 
>>>> the corresponding ones in A.
>>>
>>> That's what I'm getting at :)
>>
>> With this approach, you could wind up with some 'dead' obj files in 
>> A.lib, but aside from a bit of bloat in the lib file, they'll never 
>> wind up in the executable.
> 
> I'm feeling horribly guilty for having asked for module-level static 
> if(). I have a dreadful suspicion that it might have been a profoundly 
> bad idea.

No need to feel guilty. This problem actually manifests itself in many 
other cases than just static if, e.g. changing an alias in the modified 
module, adding some fields to a struct or methods to a class. Basically 
anything that would bite us if we had C/C++ projects solely in .h files 
(except multiple definition errors). I've prepared some examples (.d and 
.bat files) of these at http://h3.team0xf.com/dependencyFail.7z 
(-version is used instead of literally changing the code). I have no 
idea how Java or C# deal with these. Could be smart linking or some sort 
of static analysis.

As for the 'dead' obj files, one could run a 'garbage collection' step 
from time to time ;)

-- 
Tomasz Stachowiak
http://h3.team0xf.com/
h3/h3r3tic on #D freenode



More information about the Digitalmars-d mailing list