Mailing lists / fpc-pascal / 2021-04
Minimal size of compiled library (DLL under Windows)
7 messages · 4 people · –
- LLacaK 3
- JJonas Maebe 2
- MMarco van de Voort 1
- SSven Barth 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Op 2021-04-03 om 13:22 schreef LacaK via fpc-pascal:
Show quoted text 6 lines
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.
LacaK via fpc-pascal schrieb am Sa., 3.
Apr. 2021, 13:22:
Show quoted text 21 lines
Everything that is touched by initialization or finalization sections, even if nothing else is used, will be included.
Regards,
Sven
Op 2021-04-03 om 13:22 schreef LacaK via fpc-pascal: Not in an easy way at the moment, I…
Show quoted text 15 lines
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.
LacaK wrote 6 lines
They are used in your library as far as the linker is concerned, because the init and finalisation sections are code like any other code.
Does it means, that smart-linking can not remove this code due to usage of this global variables in finalization section (resp. initialization sections)?
Indeed.
Probably it is too hard task for linker to determine which code is realy not needed ... WPO in this regard can not help?
No. There is no way for WPO to know what side effects the initialisation of those variables could have.
Jonas
May be, that important word is here "referenced" code. Once some code (procedure, class) is referenced then this code is linked / included.
It does not play role if it is really required by program / library ... right?
L.
Show quoted text 24 lines
LacaK wrote 5 lines
It is impossible for a linker to know whether code is "really required". It doesn't know what code does. It only knows whether or not it (theoretically) can get executed.
Jonas
