[fpc-pascal] Separate debug info for release builds
Henry Vermaak
henry.vermaak at gmail.com
Fri Nov 1 16:29:42 CET 2024
On Fri, 1 Nov 2024 at 15:16, Martin Frb via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:
> On 01/11/2024 15:59, Henry Vermaak via fpc-pascal wrote:
> I may not have all the factors, but O- O1 and O2 are not debug info, but optimization.
> So they generate different code, and that leads to different exe sizes.
I understand that. I was comparing a build with (-O2) to a build with
(-O2 -g -Xg). The -Xg isn't particularly relevant here, building with
(-O2 -g) then stripping leaves you with a binary that's much larger
than without -g. This works fine with gcc and the binaries are the
same size after stripping.
> I am not sure it explains the full size diff you get. Depending on the code, you may have a difference due to smart linking.
>
> To check if any other symbols (e.g. those needed for the linker) differ between the various builds, you can try to use strip, and that shows you how much actually remains for the app-code/data.
All binaries are fully stripped.
> Then of course there are a few problems that make the whole thing more complex.
>
> gcc can (afaik) generate working debug info for optimized code.
>
> fpc does not. If data is in registers then fpc does not represent that (at least not always correctly) in the debug info. So data will be show incorrect in the debugger.
> fpc does not generate line info for inlined code. And I don't know how well/exact line info is for different level of optimization in different fpc versions.
> And some versions of fpc (or maybe some linkers?) caused broken debug info when smart linking was enabled.
>
> So basically, if you want to debug, then you can't really optimize.
> Or at least you must check exactly what is supported by the version of fpc you use.
Sure, I understand that optimising messes up debugging, I just want a
stack trace that points me in the general direction of what's going
wrong (and that works OK in simple tests). Except if fpc ignores -O2
somehow when I pair it with -g?
Henry
More information about the fpc-pascal
mailing list