Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

FREE Basic & Pascal (Developers)

posted by Laaca(R) Homepage, Czech republic, 05.07.2014, 12:07

Yes, the EXE files generated by Freepascal are rather big. However you can reduce the size.
My test results for "Hello world!" program.
(begin writeln('Hello world!');end.)

FPC 1.0.10 (static link+strip all debug info option): 61440 bytes
FPC 1.0.10 (smart link+strip all debug info option): 25600 bytes (can be compressed with "UPX --best" to 13740 bytes)

FPC 2.6.4 (static link+strip all debug info option): 140800(!) bytes
FPC 2.6.4 (smart link+strip all debug info option): 39424 bytes (can be compressed with "UPX --best to 18320 bytes)

Now what happens if we just for fun include another unit (in our example CLASSES).
(uses classes; begin writeln('Hello world!');end.)

FPC 1.0.10 (static,...): 217600 bytes
FPC 1.0.10 (smart,...): 97792 bytes

FPC 2.6.4 (static,...): 481792(!!) bytes
FPC 2.6.4 (smart,...): 216064 bytes

1) The size of FPC binary is caused by automaticaly included set of basic units (unit System, ev. also ObjPas). Between FPC 1.0.10 and FPC 2.6.4 came many new features, procedures and functions into these units so the their size remarkably increased.
->If the size is critical, use FPC 1.0.10

2) The same effect appears with every other unit included.
->If the size is critical, don't include another units due few trivial functions and code the necessary things yourself.

3) Smart linking helps a lot. It tries to include into generated EXE only touched parts from units and strip the unused parts from units.
The more internal complicated the unit is the worse result from smart linking you can expect.
-> Good to know when creating own units.

4) It does not follow from testing example above but the optimalization setting (Level 0-2, size/speed code generation) has only very small influence on the generated size. (in both: FPC 1.0.10 and 2.6.4)

However -- on bigger projects these size differencies are less remarkable.
I tried several compilation of my testing program (loader and viewer) for various font files.
It uses quite a lot of my own code but only very small bits from Crt, DOS, Objects and Go32 units.

FPC 1.0.10 static: 222152 (L2) or 229816 (L0)
smart: 189440

FPC 2.6.4 static 317952 (L2) or 318976 (L0)
smart: 105984 (!!!)

The superiority of 2.6.4 smartlinking if suprising in light of previous tests.
Perhaps has 2.6.4 better dead code removal algorithm.



Complete thread:

Back to the forum
Board view  Mix view
15297 Postings in 1378 Threads, 254 registered users, 14 users online (0 registered, 14 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum