Incremental compilation with DMD

Tom S h3r3tic at remove.mat.uni.torun.pl
Fri Sep 18 03:41:44 PDT 2009


Walter Bright wrote:
> Also, if you specify a .obj file directly to the linker, it will put all 
> of the symbols and data in that .obj file into the executable. The 
> linker does NOT remove functions.
> 
> What it DOES do is pull obj files out of a library to resolve unresolved 
> symbols from other obj files already linked in.
> 
> In other words, it's an additive process, not a subtractive one.

Tests seem to indicate otherwise. By the way, the linker in gcc can also 
remove unused sections (--gc-sections, which works best with 
-ffunction-sections).

----

 >cat foo.d
void main() {
}

version (WithFoo) {
         void foo() {
         }
}
 >dmd foo.d -c -of1.obj

 >dmd foo.d -version=WithFoo -c -of2.obj

 >diff 1.obj 2.obj
Files 1.obj and 2.obj differ

 >lib -l 1.obj   1>NUL  && cat 1.lst

Publics by name         module
__Dmain                          1
_D3foo12__ModuleInfoZ            1


Publics by module
1
         __Dmain                           _D3foo12__ModuleInfoZ

 >lib -l 2.obj   1>NUL  && cat 2.lst

Publics by name         module
__Dmain                          2
_D3foo12__ModuleInfoZ            2
_D3foo3fooFZv                    2


Publics by module
2
         __Dmain                           _D3foo12__ModuleInfoZ
         _D3foo3fooFZv

 >dmd -L/M 1.obj -of1.exe

 >dmd -L/M 2.obj -of2.exe

 >diff 1.exe 2.exe

 >diff 1.map 2.map

 >

----

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



More information about the Digitalmars-d mailing list