[Lazarus] Large program size - 1.8 MB for empty GUI project (uses clause in initialization vs implementation?)

Marco van de Voort marcov at stack.nl
Fri Apr 10 11:15:37 CEST 2009


On Thu, Apr 09, 2009 at 11:35:44AM +0200, svaa wrote:
> Vincent Snijders escribi??:
> > No, the initialization section of the graphics unit and its dependencies 
> > is used. The lesson is: you cannot smart link away initialization (and 
> > finalization) sections of a unit.
> 
> Why not?
> 
> Is there are a design reason for such behavior?
> 
> I mean.
> Is there a reason why a linker should never remove such sections?
> Or the problem is that it is too difficult  and complex to implement  
> such a  smart compiler/linker?

Take a line like

initialization
 Register(TSomeComponent);

This means the type of some class goes into some array.  However, it can be
that some bit of code loads the identifier from disk and looks them up in
this array, and then creates the component and streams in data from disk via
RTTI. This means that already all published stuff must be linked in, and all
code and fields that these use. 

Similarlyo a certain percentage of virtual methods and overrides can also be
reached.

It is nearly impossible for a compiler to see if this scenario is likely or
not.



More information about the Lazarus mailing list