[Lazarus] Large program size - 1.8 MB for empty GUI project (uses clause in initialization vs implementation?)
Martin Friebe
lazarus at mfriebe.de
Wed Apr 8 18:14:29 CEST 2009
Alexey S. Smirnov wrote:
> Vincent Snijders ?????:
>> Can somebody explain to me why smartlinking works better when a unit
>> is in the implementation section than when it is in the interface
>> section? I thought for smartlinking it doesn't make a difference, the
>> unit is used anyway.
>>
> The Smart Link process should check what
> variables/functions/definitions are used in your project to cut off
> unused code. It is really simple to do so, if some units are listed in
> Implementation section - linker will only add unit functions that are
> mentioned in you code, not more.
> If units are listed in Interface section - it mean that potentially
> all code from that particular unit should be included. Because your
> global variable/class should have access to all provided
> code/procedures/properties.
>
Is this documented somewhere? I can't follow the logic anyway, the scope
how much my code uses of another unit can not be predicted, simply by
where I include the other code?
Actually, I do believe I have seen examples where code form units used
in the interface was successfully smart-linked.
However there is a differentiation what can be smart linked and what
not. If a class has RTTI information, then methods from it can not be
removed by smart-linking. Classes with RTTI (afaik) are either included
as a whole or not at all. (And that make sense, because RTTI allows to
access any method by finding it from a resource or literal string; which
are both not parsed by the compiler, and therefore not determinable)
Best Regards
Martin
More information about the Lazarus
mailing list