[fpc-pascal] What's in Hello World

Michael Van Canneyt michael at freepascal.org
Sun Jan 7 11:39:39 CET 2024



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

> Am 07.01.2024 um 10:01 schrieb Florian Klämpfl via fpc-pascal:
>> 
>> 
>>> Am 06.01.2024 um 20:05 schrieb Matthew Phillips via fpc-pascal 
>>> <fpc-pascal at lists.freepascal.org>:
>>> 
>>> I compiled the Hello World program from the docs and noticed that it's
>>> 435k. Compared to a lot of newer languages, like Golang, that's not bad
>>> at all.
>>> 
>>> I then compiled the equivalent C program with gcc which came out at
>>> 33k. So I'm just curious, where does the difference comes from?
>>> Could it be that fpc is including some parts that are not being used in
>>> this simple of a program or is more going on?
>> 
>> https://wiki.freepascal.org/Size_Matters
>> 
> To underline this with some numbers (I assume you mean the demo/text/hello.pp 
> which only contains a mere "Writeln('Hello World')" and no additional units; 
> all tests on x86_64-linux with 3.3.1):
>
> - 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.

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

Michael.


More information about the fpc-pascal mailing list