[fpc-pascal] Separate debug info for release builds

Nikolay Nikolov nickysn at gmail.com
Fri Nov 1 22:21:44 CET 2024


On 11/1/24 7:14 PM, Henry Vermaak via fpc-pascal wrote:
> On Fri, 1 Nov 2024 at 16:12, Henry Vermaak <henry.vermaak at gmail.com> wrote:
>> On Fri, 1 Nov 2024 at 15:49, Martin Frb via fpc-pascal
>> <fpc-pascal at lists.freepascal.org> wrote:
>>> Another factor could be that debug info affects smartlinking. Or leaves symbols for the linker in sections that are shared with non-debug info.
>> This seems to be the problem. I think adding -g turns off
>> smartlinking, which then blows up the binary size, I've just tested
>> with and without (-CX -XX).
> Looks like I can "fix" this by passing --gc-sections to ld.
>
> Are there any fpc devs that can comment on why smart linking gets
> switched off when -g is passed?

Because Free Pascal doesn't support smartlinking+debug info on most 
platforms. The only exception is macOS, where it is actually supported. 
Adding --gc-sections to the linker on other platforms will probably 
result in broken debug info and is not guaranteed to work. Of course, 
you are encouraged to try it and test it, and see if it works, but it 
probably doesn't.

Best regards,

Nikolay



More information about the fpc-pascal mailing list