Recent

Author Topic: ENORMOUS executables  (Read 54575 times)

euthymos

  • New Member
  • *
  • Posts: 15
ENORMOUS executables
« on: June 16, 2006, 05:10:09 pm »
Is it normal that a freepascal program with only 1 *empty* form takes 6
MB
if not compressed, and 600 KB if stripped and UPX-compressed??? It is still quite enormous.

Oscar

  • Newbie
  • Posts: 6
ENORMOUS executables
« Reply #1 on: June 16, 2006, 07:33:47 pm »
This problem is allready solved....

use after compiling :

strip --strip-all myprogram.exe
upx myprogram.exe


Greetings Oscar
Take a homebrew !!
Creating software for it : http://home.planet.nl/~gerrl002/lazarus/index.htm

euthymos

  • New Member
  • *
  • Posts: 15
ENORMOUS executables
« Reply #2 on: June 16, 2006, 07:44:50 pm »
Quote from: "Oscar"
This problem is allready solved....

use after compiling :

strip --strip-all myprogram.exe
upx myprogram.exe


Greetings Oscar


Already made it. 600 KB if still dramatically too much. It's simply unbelievable, there are no apparent reasons for an executable to be so enormous. The same identical program in Qt (C++) is only 34 KB (uncompressed!).

There is something wrong...

Oscar

  • Newbie
  • Posts: 6
ENORMOUS executables
« Reply #3 on: June 16, 2006, 07:52:59 pm »
Is quite normal.....In Delpi thats also a basic minimal size of a windows application.....

Greetings Oscar
Take a homebrew !!
Creating software for it : http://home.planet.nl/~gerrl002/lazarus/index.htm

euthymos

  • New Member
  • *
  • Posts: 15
ENORMOUS executables
« Reply #4 on: June 16, 2006, 07:54:52 pm »
Quote from: "Oscar"
Is quite normal.....In Delpi thats also a basic minimal size of a windows application.....

Greetings Oscar


Which is ~400KB uncompressed, ~130KB compressed.

In freepascal/lazarus, minimal size is ~6000KB (!!!) uncompressed, ~600KB compressed. Numbers are better than words.

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
ENORMOUS executables
« Reply #5 on: June 17, 2006, 12:15:53 am »
You should study a bit before you do some stupid comments like this.

No idea HOW you got the C++ example working, but unless you used something like wxWidgets, then your comparison of size is simply crap.

There's a difference between smartlinking and full dynamic linking.

Lazarus has an abstraction layer called LCL (Delphi has it as VCL) which is SMARTLINKED (meaning static linked only what's used into the binary). With C++ and QT you dynamicly link everything even a stupid printf. This means that all those megabytes are in all those required shared libs (libc.so, libqt3.so etc)

Now ever tried static-linking a GCC "hello world" program? 800kb. Ofcourse it's not smartlinking but you get the idea. Run ldd on dynamic hello world from gcc and smartlinked one (about 18kb) from fpc. Now you see the difference, and where the stuff is with C++.

Smartlinking is very useful for backwards and forwards compatibility and distributing and pascal has traditionaly been using it since it never has it's RTL part of any OS basic distro.

euthymos

  • New Member
  • *
  • Posts: 15
ENORMOUS executables
« Reply #6 on: June 17, 2006, 12:25:30 am »
Quote from: "Almindor2"
Lazarus has an abstraction layer called LCL (Delphi has it as VCL) which is SMARTLINKED (meaning static linked only what's used into the binary). With C++ and QT you dynamicly link everything even a stupid printf. This means that all those megabytes are in all those required shared libs (libc.so, libqt3.so etc)


Almindor, you're right. I already knew about that. You are focusing on this matter just to skip the real question, which is: "how can you even think of publishing a compiler that makes a 6000-KB empty executable?"

An executable of 6000 KB (~650 KB if UPX-ed) challenges human understanding and struggles against common sense. I've made a program in Delphi 6, including database inferfaces, custom components, bundled dlls, ecc... and it is just 2.6MB (~960 KB if UPX-ed). The wiki does not solve the problem, which keeps on being the strangest thing I've ever seen in my computer... An executable 6000KB? I'll tell my friends, they won't believe me!  :D

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
ENORMOUS executables
« Reply #7 on: June 17, 2006, 12:28:06 am »
The problem is also that:
a) if you have custom compile Lazarus, LCL isn't smartlinkable properly
b) the GNU linker is crap
c) smartlinking objects/class is rather ineffective and the whole LCL is classes. There are people working on this (Synopsis made a linker for fpc in windows for now, 10x faster and eats much less memory for example) but you can't expect something useless as binary size to be a top concern of a cross-platform delphi.

Binaries up to 5mb are ok and if you look at some newer even non pascal/smartlinked binaries they ship (see games for example) you'll get even bigger ones.

euthymos

  • New Member
  • *
  • Posts: 15
ENORMOUS executables
« Reply #8 on: June 17, 2006, 12:36:22 am »
Quote from: "Almindor2"
The problem is also that:
a) if you have custom compile Lazarus, LCL isn't smartlinkable properly

I've downloaded the binaries and I ran them under Windows. Tried also in Linux: same result.


Quote
b) the GNU linker is crap

How can I solve this problem?


Quote
There are people working on this but you can't expect something useless as binary size to be a top concern of a cross-platform delphi.

According to me, It's quite relevant. Skipping the problem isn't a solution, and even those horrible hacks like UPX are not effective.


Quote
Binaries up to 5mb are ok

If they contain something.


Thank you for your answers.

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
ENORMOUS executables
« Reply #9 on: June 17, 2006, 01:03:27 am »
I can't see your problem. If you think that 6 megs are too big, don't use lazarus :)

euthymos

  • New Member
  • *
  • Posts: 15
ENORMOUS executables
« Reply #10 on: June 17, 2006, 01:20:17 am »
Quote from: "Legolas"
I can't see your problem. If you think that 6 megs are too big, don't use lazarus :)


Unexceptionable... What a great answer!


Just a funny thing:

Code: [Select]

program helloworld;

begin
     writeln('Hello World');
     readln;
end.


Four lines of code, no linked units. Same program, three different compilers:

Turbo Pascal 5.5: 2 KB
Borland Delphi 6: 16 KB
Lazarus/FreePascal: 255 KB

Delphi 6 vs. Lazarus ratio: 1:15
Turbo Pascal 5.5 vs. Lazarus ratio: 1:127


261.393 bytes of what? Random data?



I don't like to be polemic. But, I mean, we have to face reality.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
ENORMOUS executables
« Reply #11 on: June 17, 2006, 02:23:37 am »
Quote
261.393 bytes of what? Random data?


I don't remember the exact comand but you can use the linker to generate a Map with *all* procedures on your software. I already experimented this, and my findings are:

Free Pascal / Lazarus Smartlinking isn't as powerful as Delphi's. So the result is that your Hello world 1 form executable contains support for a infinite amount of things it doesn't use. I think it contains code for almost all standard controls, XML support, the full Free Pascal RunTime Library, a lot of Free Component Library (FCL).

The result is that Free Pascal software starts very big, but it also grows very, very, very, very slowly when you add more forms and more code.

c or c++ starts very small, but as you add code it grows, grows very fast and becomes huge!

So it may seam horrible for hello worlds, but real world applications are not hello worlds, so we acctually have a great advantage here.

My friends who develop with c++ were amazed at how small the executable of a big project is on Lazarus! On c++ the hello world is small, but real world applications get huge.

Quote
I don't like to be polemic. But, I mean, we have to face reality.


The reality is that hello worlds are useless =)

Just to exemplify what I said. I wrote a digital oscilloscope gui on lazarus (screenshot, source code and documentation here: http://eletronicalivre.incubadora.fapesp.br/portal/english/oscilloscope/ )

What is the size of the executable? Almost the same as the hello world.

And don't beliave it would be smaller on c++ because it would not.
[/quote]

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
ENORMOUS executables
« Reply #12 on: June 17, 2006, 02:35:41 am »
> Almindor, you're right. I already knew about that. You are focusing on this matter just to skip the real question, which is: "how can you even think of publishing a compiler that makes a 6000-KB empty executable?"

This is non-sense. That executable includes debug information required by the GNU Debbuger. No one distributes an executable with debug info. So, to start with, use strip.

And no, as I said above, the executable is very far from empty. It already includes almost all a real world application needs (even if not utilized).

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
ENORMOUS executables
« Reply #13 on: June 17, 2006, 02:51:51 am »
Quote from: "euthymos"
Quote from: "Legolas"
I can't see your problem. If you think that 6 megs are too big, don't use lazarus :)


Unexceptionable... What a great answer!


Indeed. AFAICS you like small things. My answer was small. :P

Quote

Turbo Pascal 5.5: 2 KB
Borland Delphi 6: 16 KB
Lazarus/FreePascal: 255 KB


Ok, you are right. Now try to recompile your Hello World for another platform (I let to you the choice) and, please, post here your results for turbo pascal and borland delphi. I'm just curious.

BTW, this topic was discussed a zillion of times here: if you try to search, you will find "why&because" answers too.

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
ENORMOUS executables
« Reply #14 on: June 17, 2006, 12:41:26 pm »
Quote

Code: [Select]

program helloworld;

begin
     writeln('Hello World');
     readln;
end.


Four lines of code, no linked units. Same program, three different compilers:

Turbo Pascal 5.5: 2 KB
Borland Delphi 6: 16 KB
Lazarus/FreePascal: 255 KB

Delphi 6 vs. Lazarus ratio: 1:15
Turbo Pascal 5.5 vs. Lazarus ratio: 1:127


261.393 bytes of what? Random data?

I don't like to be polemic. But, I mean, we have to face reality.


The reality is that you are an ignorant:
-rwxr-xr-x 1 ales ales 23317 2006-06-17 12:39 test

That's 23kb for you boy.

Try to use SMARTLINKING AND STRIPPING next time. This is answered in the FAQ a million times and a million times on this forum AND NO IT WON'T EVER BE THE DEFAULT OPTION.

Your ignorance is starting to bug me.

Oh and as a little addition, you are NOT comparing Lazarus with anything, Lazarus is NOT the compiler, it's JUST the IDE. It's FPC you compare all the time. If you use LCL (forms) you just compare FPC + LCL vs other like Delphi Compiler + VCL.

 

TinyPortal © 2005-2018