Recent

Author Topic: Astronomic file size  (Read 34180 times)

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Astronomic file size
« Reply #15 on: December 06, 2010, 12:31:34 am »
This is my compilation of few own made applications. I don't use strip.exe or anything else, just UPX on 1 of them. The key is "Strip symbols from executable" and "Use external gdb debug symbols file", which i'm honestly shocked why they weren't on by default. Using level 1 optimization and nothing else.

These are all Win32 applications:
app1: 1666kb
app2: 1536kb
app3: 1764kb
app4: (console application, no forms): 62kb
app5: (+UPX pack): 498kb
OpenGL game1: 1920kb
OpenGL game2: 1866kb
LCL game: 1664kb

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: Astronomic file size
« Reply #16 on: December 06, 2010, 12:49:43 am »
Well User137, when you need a really good debugger that shows all variables values, it is not recommended to use optimization levels.
I personally don't care about a 20MB executable while i develop.
Once my unit and functional tests are passed, i do a :

strip --strip-all mybinary
upx -9 mybinary

But you way to use external gdb is good too as it's avoid the strip sequence :)
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Astronomic file size
« Reply #17 on: December 06, 2010, 08:10:20 am »
If you're using Lazarus svn, then you can set up different build modes (debug, release, optimized, etc). I set up two modes, debug and release.

Debug consists of: enable all checkings, no optimization at all, full debugging info, disable stripping and smartlinking.

Release consists of: disable all checkings, level 3 optimization + regvar, no debugging info, strip symbols and create smartlinkable units + enable smartlinking.

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Astronomic file size
« Reply #18 on: December 06, 2010, 09:29:06 am »
If you're using Lazarus svn, then you can set up different build modes (debug, release, optimized, etc). I set up two modes, debug and release.

Debug consists of: enable all checkings, no optimization at all, full debugging info, disable stripping and smartlinking.

Release consists of: disable all checkings, level 3 optimization + regvar, no debugging info, strip symbols and create smartlinkable units + enable smartlinking.


Eh, what am I doing wrong?

In Lazarus menu, I opened "Project"->"Project Options..."
On "Compiler Options"->"Code generation" node I checked "smart linkable" check box and "Level 3" radio button. On "Linking" node I checked "Strip Symbols from Executable" and "Link smart".

Nothing changed! The executable is still huge. The only thing that works for me is Strip from command line.

Is there something else I should set too? I'm missing something. %)

This I have just tried on Windows XP, win32 widget set, with fresh Lazarus revision 28635.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Astronomic file size
« Reply #19 on: December 06, 2010, 11:15:06 am »
Did you uncheck the other debugging related checkboxes in the linker tab, e.g. line info.

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Astronomic file size
« Reply #20 on: December 06, 2010, 01:10:37 pm »
Did you uncheck the other debugging related checkboxes in the linker tab, e.g. line info.

That's it, when "Display line numbers" is unchecked, the size is reduced, like when strip is used, thank you.

Actualy, "Display line numbers" is the only option that makes diference!
The following seems to be completely irrelevant:
Checking or unchecking "Strip Symbols from Executable", "Smart Linkable", "Link smart", so is setting higher optimization level. %)

Any combination of these options doesn't change the exe size. I can get only two exe sizes - one when "Display line numbers" is checked and the other when unchecked. Totally regardeless of other options I mentioned!

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Astronomic file size
« Reply #21 on: December 06, 2010, 01:16:12 pm »
Quote
Checking or unchecking "Strip Symbols from Executable"
Well if the compiler doesn't even generate any debugging symbols, of course there's nothing to strip.
Quote
"Smart Linkable", "Link smart"
Try recompiling LCL with this option, and choose Build All instead of just Build (it skips already compiled file if the compiled one is newer than the source).
Quote
so is setting higher optimization level
I take this for speed, not size. If you want smaller size, choose the size optimization (-Os).

Imants

  • Full Member
  • ***
  • Posts: 196
Re: Astronomic file size
« Reply #22 on: December 06, 2010, 03:49:05 pm »
Did you uncheck the other debugging related checkboxes in the linker tab, e.g. line info.

That's it, when "Display line numbers" is unchecked, the size is reduced, like when strip is used, thank you.

Actualy, "Display line numbers" is the only option that makes diference!
The following seems to be completely irrelevant:
Checking or unchecking "Strip Symbols from Executable", "Smart Linkable", "Link smart", so is setting higher optimization level. %)

Any combination of these options doesn't change the exe size. I can get only two exe sizes - one when "Display line numbers" is checked and the other when unchecked. Totally regardeless of other options I mentioned!

Have you checked "use external gdb debug symbols file (-Xg)"
It would need to dramatically reduce your exe file size

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Astronomic file size
« Reply #23 on: December 06, 2010, 06:21:57 pm »
Have you checked "use external gdb debug symbols file (-Xg)"
It would need to dramatically reduce your exe file size

Yes it does. Actually, it gets to one of exactly two different exe sizes which I can get as I said in some previous post.

To be honest, I could live perfectly fine with stripping from command line. Still, all these options are there and they just seem to not change exe size a bit.

Quote
Checking or unchecking "Strip Symbols from Executable"
Well if the compiler doesn't even generate any debugging symbols, of course there's nothing to strip.

And if they are there, they stay there.
Still, whatever I check or uncheck, the size of executable is never influenced by "Strip Symbols from Executable" checkbox!

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Astronomic file size
« Reply #24 on: December 06, 2010, 08:19:52 pm »
Try recompiling LCL with this option,

How?

and choose Build All instead of just Build (it skips already compiled file if the compiled one is newer than the source).

It doesn't help.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Astronomic file size
« Reply #25 on: December 06, 2010, 10:02:07 pm »
Smartlinking -XX is enabled by default on windows, because then the windows unit can contain all possible winapi calls, not just the ones that are actual present on your windows OS. Therefore adding -XX on windows doesn't change the executable size. Try adding -XX- in the custom options and you see the result with Smartlinking disabled (untested).

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Astronomic file size
« Reply #26 on: December 06, 2010, 11:53:30 pm »
I also add my experience:

Linux, 64-bit, Qt4

Empty project:
14,5MB / 4,6MB (after strip)

My project (~31 000 lines, 12 forms, 20 units):
18,1MB / 6,4MB (after strip)

So it seems Lazarus is suitable for large projects.

And one issue. Following code does not work after using UPX (works well after strip).
Code: [Select]
appIniFile:=TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
After UPX is appIniFile empty (=''). Seems that application forget its own name  :)
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Astronomic file size
« Reply #27 on: December 07, 2010, 02:04:46 am »
Quote
And one issue. Following code does not work after using UPX (works well after strip)
http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#Configuration_files

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Astronomic file size
« Reply #28 on: December 07, 2010, 02:45:08 am »
Thanks, since I write multiplatfotm application so your hint is useful for me.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Astronomic file size
« Reply #29 on: February 03, 2011, 12:31:14 am »
Quote
"Smart Linkable", "Link smart"
Try recompiling LCL with this option, and choose Build All instead of just Build (it skips already compiled file if the compiled one is newer than the source).

How exactly are the LCL compiler options set? Is it done by entering command options in the Compile Lazarus dialog or is there something else?
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

 

TinyPortal © 2005-2018