[fpc-pascal] Minimal size of compiled library (DLL under Windows)

LacaK lacak at zoznam.sk
Tue Apr 6 09:33:52 CEST 2021


>>
>> I am guessing, that there must be something in initialization 
>> sections of units (SysUtils and Classes), which cause that some code 
>> is included, right?
>> Can I somehow to avoid this grow of size (for example I need from 
>> Classes only TFPList)?
>
> Not in an easy way at the moment, I don't expect it to change anytime 
> soon.
>
> The problem is probably the streaming system that the compiler can't 
> easily determine if it is used runtime. This also has resourcestrings 
> as errors, uses typeinfo etc etc.  I also see interface related 
> support probably because tcomponent also implements interfaces.
>
What I can say is, that in initialization sections are touched:

SysUtils: WidestringManager, Exceptions, FormatSettings
Classes: TCriticalSection, TList, TThreadList, TComponent 
(IUnknown,IDispatch, RegisterInitComponentHandler() -> var 
InitHandlerList), Interface (var GlobalNameSpace: IReadWriteSync)

So we see that classes like TComponent and also interfaces are touched, 
but they are used only in conjuction with initilizing some global 
variables like InitHandlerList, GlobalNameSpace.

But these variables are never used in my library. Only again in 
finalization sections of above mentioned units.

Does it means, that smart-linking can not remove this code due to usage 
of this global variables in finalization section (resp. initialization 
sections)?

Probably it is too hard task for linker to determine which code is realy 
not needed ... WPO in this regard can not help?

-Laco.




More information about the fpc-pascal mailing list