Recent

Author Topic: Reducing exe/binary size wiki entry  (Read 6988 times)

reinerr

  • New Member
  • *
  • Posts: 37
Reducing exe/binary size wiki entry
« on: October 29, 2012, 01:48:44 am »
I've just edited the wiki entry Why are the generated binaries so big to say near the start to use -Xg (external debug symbols). I thought this should easily fix the issue (on all platforms?) and wonder why it is not set as default? I'm posting here in case there are any issues with it (particularly for non-Windows systems - I only use Windows) but also so people can more quickly find a solution te reduce the size of their exe.

The size of binaries generated by Lazarus come up occasionally but the wiki entry was long and unapologetic and ignored this quick fix. Granted, the option may not always have been there but its been there since I've used Lazarus properly.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Reducing exe/binary size wiki entry
« Reply #1 on: October 29, 2012, 02:34:37 am »
It probably is. But nobody ever took the time to test it.

Not only would it need to be tested on all platforms, but also with a wide variety of GDB versions. Some platforms (Mac) still use gdb 6.3.5 (and that is supported); most linuxes will be on some 7.x (7.0 to 7.5). Windows is the only platform where gdb is part of the Lazarus install. It also can depend on the linker used. So that is even more to test.


Also, I am not sure if it is better.

Yes currently a few people see 15 MB for an empty form and are surprised.
But at least it gives them the chance to google and learn the difference between a debug and release build.

If you use -Xg the exe may be smaller. But it still is a debug build. People will just never know. Until maybe it is to slow for what thy need.
After all debug-info is not the only difference:
- smart linking (which must be off for debugging, even, if using -Xg)
  so a debug build will still be bigger than release
- range, IO, overflow checks
- -O1 versus -O2 (or -O3)
- -gh (heap trace mem manager)
- compiled in asserts
....


So unless you do wince (the debug info is to big for the emulator/device), why would you mind if your debug build is huge. You need a release build anyway.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Reducing exe/binary size wiki entry
« Reply #2 on: October 29, 2012, 07:02:41 am »
Quote
I'm posting here in case there are any issues with it (particularly for non-Windows systems - I only use Windows)
I'm using the setting almost always but found 2 downsides: heaptrc and exception stack dumps don't contain line info. Both are fpc internal functions and they only look for debug info in the exe. So the external debug info is only useful if you run the app inside gdb. And if you are using heaptrc, even running inside gdb will not give you the line info in the heaptrc dump. You need to use other tools to translate the addresses into line info.

Chronos

  • Full Member
  • ***
  • Posts: 240
    • PascalClassLibrary
Re: Reducing exe/binary size wiki entry
« Reply #3 on: October 29, 2012, 02:21:51 pm »
For windows application I prefer to include debug info as external file. It is possible to read from that file and show user nice info similar to EurekaLog and others.
And it can be matter of simple insert component from component palette without deep knowledge of background processing.
http://svn.zdechov.net/PascalClassLibrary/ExceptionLogger/

For commercial applications it may not be good idea to include debug info as it can help to reverse engineering your program. Debug file can be distributed as separated file used only by developer. In such case exe file and debug file should match. Installer as InnoSetup can compress 60 MB debug file to 5 MB.

Then external debug file may be not necessary used as default behavior but it can be simply activated if needed.
« Last Edit: December 21, 2018, 09:25:35 pm by Chronos »

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: Reducing exe/binary size wiki entry
« Reply #4 on: October 29, 2012, 03:43:58 pm »
Very nice Chronos !!! I just made a post-it with your URL :P i think i'll use it in my projects :)
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Reducing exe/binary size wiki entry
« Reply #5 on: October 29, 2012, 05:21:57 pm »
http://svn.zdechov.net/svn/PascalClassLibrary/ExceptionLogger/

Have you tried the leak view package?

It doesn't work with -Xg.
But you can compile with debug info, take a copy to keep with dbg info, and strip the release by hand.

Then if you get a stacktrace (the way fpc apps log to the console/logfile) you can paste it, and resolve against the exe with the info.

leak view then can navigate the sources in the IDE for you.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Reducing exe/binary size wiki entry
« Reply #6 on: November 01, 2012, 12:27:44 pm »
FYI, there's a bug report open for default debug and release modes in Lazarus projects:
http://bugs.freepascal.org/view.php?id=22743
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Reducing exe/binary size wiki entry
« Reply #7 on: November 01, 2012, 12:59:28 pm »
@Chronos Thanks a lot for the link. I didn't know about it. I might adopt it in my projects as well.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

 

TinyPortal © 2005-2018