Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-04

Strip debug info

30 messages · 14 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Mace
to Reinier Olislagers
Reinier Olislagers wrote 15 lines
On 28-4-2012 8:57, Richard Mace wrote: > Hi, > What's the safest way of making the .exe smaller than default? Is it > just to strip debug info? > How would I do this? Perhaps this will give you some ideas? http://wiki.lazarus.freepascal.org/Size_Matters#Incorrect_compiler_configuration ... you can either not generated debug info at all or generate external debug info (.dbg)... Regards, Reinier

Thanks, I'll try with the -Xg switch

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120428/e52d3aa9/attachment.html>

Reply by email

John Landmesser
to Richard Mace: What's the safest way of making the .exe smaller than default? Is it just to strip debug…
Richard Mace wrote 15 lines
Hi, What's the safest way of making the .exe smaller than default? Is it just to strip debug info? How would I do this? Thanks in advance Richard -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

my DAU method is in terminal on linux

strip --strip-all ./MyApplication
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120428/77571fae/attachment.html>

Reply by email

John Landmesser
to Richard Mace: What's the safest way of making the .exe smaller than default? Is it just to strip debug…
Richard Mace wrote 15 lines
Hi, What's the safest way of making the .exe smaller than default? Is it just to strip debug info? How would I do this? Thanks in advance Richard -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

my DAU method is in terminal on linux

strip --strip-all ./MyApplication

strip.exe for Win is part of your fpc bin directory:

/lazarus/fpc/2.5.1/bin/i386-win32/strip.exe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120428/9906200b/attachment.html> -------------- next part --------------
An embedded and charset-unspecified text was scrubbed... Name: Attached Message Part
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120428/9906200b/attachment.ksh>

Reply by email

Richard Mace
to John Landmesser
John Landmesser wrote 27 lines
On 28.04.2012 08:57, Richard Mace wrote: Hi, What's the safest way of making the .exe smaller than default? Is it just to strip debug info? How would I do this? Thanks in advance Richard -- _______________________________________________ Lazarus mailing ://lists.lazarus.freepascal.org/mailman/listinfo/lazarus my DAU method is in terminal on linux strip --strip-all ./MyApplication strip.exe for Win is part of your fpc bin directory: /lazarus/fpc/2.5.1/bin/i386-win32/strip.exe

Would this be instead of the -Xg switch or as well as? Or does it do the same thing?

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120428/27f62b3b/attachment.html>

Reply by email

Richard Mace
to Reinier Olislagers: Perhaps this will give you some ideas? http://wiki.lazarus.freepascal.org/Size_Matters#Inc…
Reinier Olislagers wrote 13 lines
On 28-4-2012 8:57, Richard Mace wrote: > Hi, > What's the safest way of making the .exe smaller than default? Is it > just to strip debug info? > How would I do this? Perhaps this will give you some ideas? http://wiki.lazarus.freepascal.org/Size_Matters#Incorrect_compiler_configuration ... you can either not generated debug info at all or generate external debug info (.dbg)...

Is there any reason why the -Xg flag is not on at default? What's the disadvantage of using this flag? The reason I say is because there is a "massive" reduction in .exe size?

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120428/d478dc2c/attachment.html>

Reply by email

Jürgen Hestermann
to Richard Mace
Show quoted text 9 lines
... you can either not generated debug info at all or generate external debug info (.dbg)... Is there any reason why the -Xg flag is not on at default? What's the disadvantage of using this flag? The reason I say is because there is a "massive" reduction in .exe size?

Yes, that's what I wondered about too.

Reply by email

Florian Klämpfl
to Richard Mace: Is there any reason why the -Xg flag is not on at default? What's the disadvantage of…
Richard Mace wrote 20 lines
On 28 April 2012 08:21, Reinier Olislagers < <mailto:>> wrote: On 28-4-2012 8:57, Richard Mace wrote: > Hi, > What's the safest way of making the .exe smaller than default? Is it > just to strip debug info? > How would I do this? Perhaps this will give you some ideas? http://wiki.lazarus.freepascal.org/Size_Matters#Incorrect_compiler_configuration ... you can either not generated debug info at all or generate external debug info (.dbg)... Is there any reason why the -Xg flag is not on at default? What's the disadvantage of using this flag? The reason I say is because there is a "massive" reduction in .exe size?

What's the problem with the .exe size when compiling with debug info? If one compiles with debug settings, one usually wants to have the debug info? If not, don't use debug settings.

Reply by email

Jürgen Hestermann
to Florian Klämpfl
What's the problem with the .exe size when compiling with debug info? If one compiles with debug settings, one usually wants to have the debug info? If not, don't use debug settings.

Well, the problem is the size of the exe file. ;-) When I am working on a project I usually want to generate debug information for debugging.
But when I give the generated file to someone else I surely do not need this information in the exe file anymore.
So why should I be forced to search for ways to delete this information from the exe if there could be a way to avoid this hassle?

Reply by email

Florian Klämpfl
to Jürgen Hestermann
J?rgen Hestermann wrote 12 lines
Florian Kl?mpfl schrieb: > What's the problem with the .exe size when compiling with debug info? If > one compiles with debug settings, one usually wants to have the debug > info? If not, don't use debug settings. Well, the problem is the size of the exe file. ;-) When I am working on a project I usually want to generate debug information for debugging. But when I give the generated file to someone else I surely do not need this information in the exe file anymore. So why should I be forced to search for ways to delete this information from the exe if there could be a way to avoid this hassle?

There is no need to search for ways to delete this information, you need only a proper workflow: exes compiled for distribution shall be compiled with release settings which means:
- no debug info
- symbols fully stripped
- full optimization (which would make debugging harder)
- asserts ignored
- custom debug code ignored
- ...
Using debug and release settings is something very basic when working on software being deployed to others.

Reply by email

Graeme Geldenhuys
to Florian Klämpfl
Florian Kl?mpfl wrote
Using debug and release settings is something very basic when working on software being deployed to others.

I fully agree. MSEide has project setting groups where you can define debug and release settings. Lazarus IDE I believe now has such functionality too in Trunk. This is even possible from the command line using something like:

fpc @debug.cfg myproject.pas
fpc @release.cfg myproject.pas

The 'debug.cfg' and 'release.cfg' are simply text files with compiler settings (one per line).

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Martin
to Jürgen Hestermann: Yes, that's what I wondered about too.
J?rgen Hestermann wrote 12 lines
Richard Mace schrieb: > > ... you can either not generated debug info at all or generate > external debug info (.dbg)... > > > Is there any reason why the -Xg flag is not on at default? What's the > disadvantage of using this flag? The reason I say is because there is > a "massive" reduction in .exe size? > Yes, that's what I wondered about too.

Probably it is simple less tested, and therefore it is unknown if in works in all situations.

Also, I guess it is more error prone. Compile with external debug, then make changes, recompile but with release settings. Then you have an outdated debug info file, and if you happen to run that in the debugger, you get a lot of strange things....

Reply by email

Martin
to Jürgen Hestermann: Well, the problem is the size of the exe file. ;-) When I am working on a project I…
J?rgen Hestermann wrote 14 lines
Florian Kl?mpfl schrieb: > What's the problem with the .exe size when compiling with debug info? If > one compiles with debug settings, one usually wants to have the debug > info? If not, don't use debug settings. Well, the problem is the size of the exe file. ;-) When I am working on a project I usually want to generate debug information for debugging. But when I give the generated file to someone else I surely do not need this information in the exe file anymore. So why should I be forced to search for ways to delete this information from the exe if there could be a way to avoid this hassle?

Well, most people need 2 build profiles anyway.

For when I debug I have -Crio -O1, heap trc and other flags. On release I have -O2, and no -C...., no heaptrc...

Reply by email

Hans-Peter Diettrich
to Martin: Probably it is simple less tested, and therefore it is unknown if in works in all…
Show quoted text 6 lines
On 29/04/2012 09:56, J?rgen Hestermann wrote: Also, I guess it is more error prone. Compile with external debug, then make changes, recompile but with release settings. Then you have an outdated debug info file, and if you happen to run that in the debugger, you get a lot of strange things....

Give the executable different names. When debugging, the exe name is irrelevant since the application will be started by F9.

DoDi

Reply by email

Martin
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 10 lines
Martin schrieb: > On 29/04/2012 09:56, J?rgen Hestermann wrote: > Also, I guess it is more error prone. Compile with external debug, > then make changes, recompile but with release settings. Then you have > an outdated debug info file, and if you happen to run that in the > debugger, you get a lot of strange things.... Give the executable different names. When debugging, the exe name is irrelevant since the application will be started by F9.

Then you can always generate 2 exe too. One with and one without dbg info... If you generate, the 2 exe individually, people may debug their latest changes, and then ship the release exe, from the day before....

I am not saying, that external debug info could not be made default. And neither do I say, that the current solution has no problems (it obviously has)

In fact I think it would be great if it could be changed to use external dbg info (assuming it is done right).

Just pointing out, it is probably not as easy, as just a new default for that checkbox.
- Test it on various platforms, cross compile, remote debug, .... (ideally add to the debugger test suit)
- Test it for projects with starter/host application (debug libraries with external info)
- different gdb versions (at least 7.0 to 7.4 / 6.3.50 on Mac)
- implement checks in the IDE so no old file will be used accidental (different name; or remove/rename old dbg info file)

Maybe other things I haven't thought of.

In any case, while nice to have, it is nothing I am going to bother about. There is plenty other, that I find more important.

Reply by email

Jürgen Hestermann
to Martin: Probably it is simple less tested, and therefore it is unknown if in works in all…
>> Is there any reason why the -Xg flag is not on at default? What's

the disadvantage of using this flag? The reason I say is because there is a "massive" reduction in .exe size?

>> > Yes, that's what I wondered about too. Also, I guess it is more error prone. Compile with external debug,

then make changes,

recompile but with release settings. Then you have an outdated debug

info file, and

if you happen to run that in the debugger, you get a lot of strange

things....

Realy? If you compile without (external) debug info can you still run the debugger from the IDE?
If yes, this has to be disabled of course.
If not, then there is no danger that an outdated debug info file can be used.

Reply by email

Martin
to Jürgen Hestermann
J?rgen Hestermann wrote 20 lines
Martin schrieb: >>> Is there any reason why the -Xg flag is not on at default? What's the disadvantage of using this flag? The reason I say is because there is a "massive" reduction in .exe size? >>> >> Yes, that's what I wondered about too. > > Also, I guess it is more error prone. Compile with external debug, then make changes, > recompile but with release settings. Then you have an outdated debug info file, and > if you happen to run that in the debugger, you get a lot of strange things.... > Realy? If you compile without (external) debug info can you still run the debugger from the IDE? If yes, this has to be disabled of course. If not, then there is no danger that an outdated debug info file can be used.

Again, not that simple.

Currently, I can start the app (without debug info) by pressing F9. Just as a way to run it. Not to debug it.
So if that was no longer possible, then alternate means need to be created, to just run (there is a feature request for that already)

But *IF* such a check would be added.....
the appropriate way for the IDE to check is not to see, if the last compile did have dbg info. It is to check, if the debug info is available.

Example: I often use the "Run Param" > "Host App" to debug a different version of the executable. It works perfect. Of course that still works, even if the last compiled exe has no debug info.

And one can also compile the project outside the IDE, and debug it in the IDE .....

And, of course that makes it even more complicated: because if I debug a dll, I might have a project loaded that does uses the dll. I would have to test, if the debugger can use the dll's debug info, if the host app has no debug info.... (I do not know)

-----------
Again, yes the situation can (and need/should) be improved. But again: not that simple.

Reply by email

Alexander Klenin
to Martin

While I am personally ambivalent about the default state of -Xg switch, I'd like to point out another use case where it matters: compiling on Windows on slow machine with antivirus installed.

When I tried to persuade my students to switch to Lazarus from Delphi, I've got many complaints about Lazarus being too slow. About a third of these complaints were fixed by either excluding Lazarus directory from AV's monitoring list, or turning -Xg on.

Alexander S. Klenin

Reply by email

Richard Mace
to Alexander Klenin
Alexander Klenin wrote 9 lines
While I am personally ambivalent about the default state of -Xg switch, I'd like to point out another use case where it matters: compiling on Windows on slow machine with antivirus installed. When I tried to persuade my students to switch to Lazarus from Delphi, I've got many complaints about Lazarus being too slow. About a third of these complaints were fixed by either excluding Lazarus directory from AV's monitoring list, or turning -Xg on.

Sorry, I might have missed this, but what would be the main disadvantage for a newbie of having the -Xg switch don't really understand about the difference between having the debug info internal to the .exe or external, and I am guessing that the majority of people coming to Lazarus won't either. I just think the more people will be complaining about the default size of the .exe as apposed to having the debug info stored externally, unless I am really missing the point (quite possibly).

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120430/d08ac9a3/attachment.html>

Reply by email

Hans-Peter Diettrich
to Alexander Klenin: While I am personally ambivalent about the default state of -Xg switch, I'd like to point…
Show quoted text 8 lines
While I am personally ambivalent about the default state of -Xg switch, I'd like to point out another use case where it matters: compiling on Windows on slow machine with antivirus installed. When I tried to persuade my students to switch to Lazarus from Delphi, I've got many complaints about Lazarus being too slow. About a third of these complaints were fixed by either excluding Lazarus directory from AV's monitoring list, or turning -Xg on.

AV software tends to affect Delphi and its compiled projects, too. It's not a good idea to use AV software on a Windows development machine.

DoDi

Reply by email

Sven Barth
to Richard Mace: Sorry, I might have missed this, but what would be the main disadvantage for a newbie of…
"Richard Mace" wrote 16 lines
On 30 April 2012 04:49, Alexander Klenin wrote: > > While I am personally ambivalent about the default state of -Xg switch, > I'd like to point out another use case where it matters: > compiling on Windows on slow machine with antivirus installed. > > When I tried to persuade my students to switch to Lazarus from Delphi, > I've got many complaints about Lazarus being too slow. > About a third of these complaints were fixed by either excluding > Lazarus directory from AV's monitoring list, or turning -Xg on. Sorry, I might have missed this, but what would be the main disadvantage

for a newbie of having the -Xg switch on at default.

I don't really understand about the difference between having the debug

info internal to the .exe or external, and I am guessing that the majority of people coming to Lazarus won't either. I just think the more people will be complaining about the default size of the .exe as apposed to having the debug info stored externally, unless I am really missing the point (quite possibly).

The main disadvantage is that -Xg is rather untested (especially considering the things that Martin wrote about the IDE) so in the end it might be less "newb friendly" than the debug info included in the executable (co.Audrey questions like "why can't I debug anymore?").

Also AFAIK FPC's lineinfo units (for both Stabs and Dwarf) don't work with external debug info (I don't remember exactly so this needs to be tested).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120430/3b94c31c/attachment.html>

Reply by email

Alexander Klenin
to Hans-Peter Diettrich: AV software tends to affect Delphi and its compiled projects, too. It's not a good idea…
Hans-Peter Diettrich wrote
AV software tends to affect Delphi and its compiled projects, too.

Yes, but in recent years Delphi was included in "safe" lists of most AV products.

It's not a good idea to use AV software on a Windows development machine.

It is also not a good idea to use Windows on a development machine :) However, we live in imperfect world.

Alexander S. Klenin

Reply by email

Michael Schnell
to Alexander Klenin: While I am personally ambivalent about the default state of -Xg switch, I'd like to point…
Alexander Klenin wrote
When I tried to persuade my students to switch to Lazarus from Delphi, I've got many complaints about Lazarus being too slow. About a third of these complaints were fixed by either excluding Lazarus directory from AV's monitoring list, or turning -Xg on.

Dud you not try to persuade them to use Linux (where Viruses are no big problem) . :-)

-Michael

Reply by email

Andreas Schneider
to Michael Schnell: The "release" build could just delete this file (provided it's there where a…
Michael Schnell wrote 6 lines
On 04/29/2012 12:09 PM, Martin wrote: > .... Then you have an outdated debug info file, The "release" build could just delete this file (provided it's there where a corresponding "debug" build would create it). -Michael

Please don't oversimplify a release build. At least one other difference is smart linking. You shouldn't smart link for debug purposes, but it would be a good idea to smart link for release. Also optimizations should be turned of for debug while they should (or at least could) be enabled for release.

It helps to have several checks (overflow, range, etc.) on during debug too, but not for release.

It is (or should) not simply (be) a matter of debug info.

In that light I find the big exe even good as it gets users to find out why and think about debug/release builds. If they simply ship a "debug" exe (without actual debug info) they might still find bad things like slow performance etc, which might be caused by enabled checks and/or missing optimizations.

I think you have to understand the full package to properly build release ready software. And a far too huge size might be the best indicator that something isn't right yet :-)

Best Regards, Andreas -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 223 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120430/7af95166/attachment.bin>

Reply by email

Richard Mace
to Florian Klämpfl: There is no need to search for ways to delete this information, you need only a proper…
Show quoted text 22 lines
Well, the problem is the size of the exe file. ;-) > When I am working on a project I usually want to generate debug > information for debugging. > But when I give the generated file to someone else I surely do not need > this information in the exe file anymore. > So why should I be forced to search for ways to delete this information > from the exe if there could be a way to avoid this hassle? There is no need to search for ways to delete this information, you need only a proper workflow: exes compiled for distribution shall be compiled with release settings which means: - no debug info - symbols fully stripped - full optimization (which would make debugging harder) - asserts ignored - custom debug code ignored - ... Using debug and release settings is something very basic when working on software being deployed to others.

This is interesting, I'd had never actually thought of a work flow like this. So, would you have 2x different projects? 1 with as dubug and the 2nd as release, or is there a better way of doing it?

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120430/8bb5405c/attachment.html>

Reply by email

Bernd
to Richard Mace

2012/4/30 Richard Mace :

This is interesting, I'd had never actually thought of a work flow like this. So, would you have 2x different projects? 1 with as dubug and the 2nd as release, or is there a better way of doing it?

There are build modes. There is a page in the project options dialog where you can set up different build modes and each can have different settings. There is also a toolbar button in the IDE main window to change the currently active build mode. The UI to configure the build modes is not yet as intuitive as it could ideally be but it works.

Reply by email

Michael Schnell
to Bernd
Bernd wrote
There are build modes.

In fact I do understand that I can create build mode variables (macros) that can be checked with "{$if" in the source code, but I don't know how to use those to select different compile options (such as smart linking, optimizing or debug info creation).

-Michael

Reply by email

Žilvinas Ledas
to Michael Schnell
Michael Schnell wrote 9 lines
On 05/01/2012 12:54 AM, Bernd wrote: > There are build modes. In fact I do understand that I can create build mode variables (macros) that can be checked with "{$if" in the source code, but I don't know how to use those to select different compile options (such as smart linking, optimizing or debug info creation). -Michael

Build modes are not macros.
You can read here to know more about build modes:
http://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Build_modes

Regards,
?ilvinas

Reply by email