OPTLINK needs to die.

Tom S h3r3tic at remove.mat.uni.torun.pl
Mon Feb 16 21:27:17 PST 2009


Walter Bright wrote:
> Jarrett Billingsley wrote:
>> http://d.puremagic.com/issues/show_bug.cgi?id=424
> 
> 
> I just added this to the bug report:
> 
> ======================
> The compiler already has a switch to generate multiple obj files from 
> one source file: -multiobj. I use it for debugging. But it would be a 
> royal pain to use if there's a lot.
> 
> A better way is to compile to a library with the -lib switch. That 
> splits the module into a zillion obj files, and stuffs them all into the 
> library. Then, link with the library (the main() program will still have 
> to be separate).
> =======================
> 
> Can you give it a try?

I've tried it before and unfortunately there's a problem with this 
approach: static ctors from modules linked from a .lib don't get executed:

 >cat Main.d
void main() {
}

 >cat Mod.d
extern (C) int printf(char*, ...);


static this() {
         printf("Running a static ctor for Mod"\n);
}

// compiling Mod into an .obj
 >dmd -c Main.d
 >dmd -c Mod.d
 >dmd Main.obj Mod.obj && Main.exe
Running a static ctor for Mod

// compiling Mod into a .lib
 >dmd -lib Mod.d
 >dmd Main.obj Mod.lib && Main.exe
 >


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



More information about the Digitalmars-d mailing list