<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">On 01/11/2024 15:59, Henry Vermaak via
fpc-pascal wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAOVzLrfbbnMZnDz6+VDQKNiH08YESaX+8=y=sogQKD=MEPmaSg@mail.gmail.com">
<pre wrap="" class="moz-quote-pre">When I add -Xg, the compiler writes the debug info into a separate
.dbg file and adds a .gnu_debuglink section so the debugger can find
the info. So far so good (and simpler than having the use objcopy).
The size of the binary is much larger than building without debug
info, though. E.g. with -O2 it goes from 35K to 188K.
When I do exactly the same with gcc (via objcopy and strip), there's
almost no difference between the stripped binary and a binary built
without debugging info (even diffing objdump output).
Can anyone explain why this is?
</pre>
</blockquote>
<br>
I may not have all the factors, but O- O1 and O2 are not debug info,
but optimization.<br>
So they generate different code, and that leads to different exe
sizes.<br>
<br>
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.<br>
<br>
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.<br>
<br>
-----------<br>
Then of course there are a few problems that make the whole thing
more complex.<br>
<br>
gcc can (afaik) generate working debug info for optimized code.<br>
<br>
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.<br>
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.<br>
And some versions of fpc (or maybe some linkers?) caused broken
debug info when smart linking was enabled.<br>
<br>
So basically, if you want to debug, then you can't really optimize.
<br>
Or at least you must check exactly what is supported by the version
of fpc you use.<br>
<br>
</body>
</html>