[fpc-pascal] Smart-linking versus Whole Program Optimization

Yuriy Sydorov jura at cp-lab.com
Wed Mar 10 19:49:59 CET 2021


On 10.03.2021 14:29, Jonas Maebe via fpc-pascal wrote:
> On 10/03/2021 13:17, Yuriy Sydorov via fpc-pascal wrote:
>> On 10.03.2021 11:34, LacaK via fpc-pascal wrote:
>>>
>>> A.) I compile my (units) program/library with -CX -XX (set in Project
>>> Options)
>>>
>>
>> Just a small note:
>>
>> -CX -XX are not needed for the top-tier targets nowadays. The section
>> based smart linking is a default option in recent FPC versions.
> 
> At least -XX is still necessary, otherwise we don't enable dead
> code/data stripping in the linker (at least not on Linux). And on macOS,
> -CX is also needed, otherwise the compiler does not emit a directive in
> the object files that dead code/data stripping should be enabled based
> on whether or not there are references to the global symbols preceding them.

Yes, you are right. On Windows, since introduction of the internal linker long time ago, both -CX -XX are ignored and 
smart linking is always ON. I've supposed that this is also true for any target which supports tf_smartlink_sections and 
these options are only needed for older smart linking method which involves generation of static libraries containing 
tons of object files.

> Neither parameter may be necessary on Windows, but that's probably the
> only one.

Android and MS-DOS targets also ignore -CX -XX

Yuriy.


More information about the fpc-pascal mailing list