Solutions to the TypeInfo dependency injection issue?

kris foo at bar.com
Thu Mar 8 14:31:57 PST 2007


Walter Bright wrote:
> kris wrote:
> 
>> Walter Bright wrote:
>>
>>> kris wrote:
>>>
>>>> What about (c) how templates are affected at each step ?
>>>
>>>
>>>
>>> It's the same algorithm - nothing special about templates.
>>
>>
>> Is it possible, do you think, to be just a little more forthcoming on 
>> this?
>>
>> 1) when you batch-compile code with multiple references to a template, 
>> there is just one instance generated.
> 
> 
> Yes.
> 
>> 2) when you compile the same code modules individually, there are 
>> presumably multiple template instances generated?
> 
> 
> Yes.
> 
>> 3) how does the linker resolve the multiple template instances to just 
>> one?
> 
> 
> The template instantiations are put into COMDAT sections, and the linker 
> discards redundant ones.

Thank you;

4) all symbols required to represent typeinfo and templates are now 
duplicated in each object file ?

5) The linker does not have to search beyond the current object file for 
instances of #4 (as suggested by larsivi) ?

6) the result is a library with many more duplicate symbols than before, 
but arranged in such a manner that persuades the linker to do the "right 
thing" ?

7) there is no possibility of the linker following a 'bad chain', and 
thus linking in unused or otherwise redundant code ?



More information about the Digitalmars-d mailing list