[fpc-pascal] Smart-linking versus Whole Program Optimization
Sven Barth
pascaldragon at googlemail.com
Wed Mar 10 11:22:29 CET 2021
LacaK via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am Mi., 10.
März 2021, 10:34:
> Hi,
>
> my goal is DO NOT include unused procedures, methods in final
> program/library on Win32 target exe/dll.
>
> A.) I compile my (units) program/library with -CX -XX (set in Project
> Options)
>
> B.) I did also experiments with WPO: -OWall -FWprogram.wpo -Xs- (plus
> -Owall -Fwprogram.wpo)
>
> Questions:
>
> 1. I did not notice difference between A and B (it seems like WPO did
> not reduce size of EXE (may be that I do something wrong))
>
It might simply be that WPO did not have anything to do.
1.1 is there way how I can check which procedures were striped out or
> vice-versa included?
>
You can create a map file using -Xm. This will list all sections that were
included, though it's quite a read. ;)
> 2. Is smart-linking/WPO capable to remove unused:
> 2.1 regular procedures/functions ?
>
Done by smartlinking.
2.2 methods of classes (non virtual, virtual) ?
>
The former is done by smartlinking (if they aren't required for e.g.
published properties). The later might be done by WPO, though I think that
the case of a virtual method not being used at all is not handled.
2.3 class methods of classes ?
>
Done by smartlinking.
In essence you gain the most by smartlinking. WPO only works in certain
situations (e.g. the compiler has a class hierarchy that works very well
for devirtualisation) and some things that could in theory be done with WPO
are simply not implemented.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210310/c7fc03c3/attachment.htm>
More information about the fpc-pascal
mailing list