Proposed improvements to the separate compilation model

Walter Bright newshound2 at digitalmars.com
Sat Jul 23 17:14:27 PDT 2011


On 7/23/2011 3:50 PM, Andrei Alexandrescu wrote:
> On 7/23/11 5:39 PM, bearophile wrote:
>> I have suggested some fine-grained hashing. Compute a hash from a
>> class definition, and later quickly compare this value with a value
>> stored elsewhere (like automatically written in the .di file).
>
> I discussed four options with Walter, and this was one of them. It has issues.
> The proposal as in this thread is the simplest and most effective I could find.

The only way the linker can detect mismatches is by embedding the hash into the 
name, i.e. more name mangling. This has serious issues:

1. The hashing cannot be reversed. Hence, the user will be faced with really, 
really ugly error messages from the linker that will make today's mangled names 
look like a marvel of clarity. Consider all the users today, who have a really 
hard time with things like:

     undefined symbol: _foo

from the linker. Now imagine it's:

     undefined symbol: _foo12345WQERTYHBVCFDERTYHGFRTYHGFTYUHGTYUHGTYUJHGTYU

They'll run screaming, and I would, too.

2. This hash will get added to all struct/class names, so there will be an 
explosion in the length of names the linker sees. This can make tools that deal 
with symbolic names in the executable (like debuggers, disassemblers, profilers, 
etc.) much more messy to deal with.

3. Hashes aren't perfect, they can have collisions, unless you want to go with 
really long ones like MD5.




More information about the Digitalmars-d mailing list