For what it's worth, the hello world program in powerbasic (https://www.powerbasic.com) comes to a whooping 7,168 bytes. That's the console version, not the gui version, that's a bit bigger, but by not much more.  I have an epub reader I've been working on for a few years, on and off, and that program which has a complete gui, web browser calls, and the like, weighs in at just over 75K.  I always use powerbasic if I'm writing a windows only program, since it's ability to produce such small executables is well known.  Heck, it even has a #bloat command in the compiler to artificially inflate the size of the exe files it builds, because so many didn't believe that it was producing an actual windows binary.

I use FPC when working on cross platform programs, since it can compile for many platforms, unless I need a gui.  In that case, I use java, since I can put it in grid mode, and then I don't have to worry about how the gui is laid out.  Something that typically takes sighted assistance, and a great deal of time otherwise.

Of course, GCC produces small binaries too, and I'll use that too when the need arrises.

It all depends on what I am working on, and where it is going to run.


On 1/7/2024 7:33 PM, Michael Van Canneyt via fpc-pascal wrote:


On Sun, 7 Jan 2024, Sven Barth via fpc-pascal wrote:


- FPC compiled as is: 388976 B
- FPC compiled with full smartlinking: 55920 B
- FPC compiled with C linkage: 388760 B
- FPC compiled with full smartlinking and C linkage: 56792 B

Maybe it is a good idea to add these numbers to the above WIKI page, to quantify
the discussion and to illustrate what the effect is of various options.

Probably... 🤷‍♀️

And just for the fun of it, the size if the RTL is compiled into a dynamic package and that is used:

- no smartlinking: 15784 B
- with smartlinking: 15608 B

With the librtl.so having a size of 649912 B which will ammortize itself if multiple applications use dynamic packages.

Nice result. Smaller than a C program :-)


I think we should also explain why linking to C has almost no effect on actual binary size.

That's mainly because the functions that differ between FPC_USE_LIBC and not are rather slim syscalls anyway, so the main bunch of Pascal code is still the same in both cases.

I know this, but most likely users will not realize this... :-)

Michael.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to