Size of program vs library ?

classic Classic list List threaded Threaded
41 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Size of program vs library ?

fredvs
Hello.

Here size of "nude" program and library compiled with fpc 2.7.1.
Why is it a so big size-difference ?

Compiled with => fpc 2.7.1 => linux 64
Compiler parameters : -MObjFPC -Scghi -CX -Os1 -Xs -XX -vewnhi -fPIC

program prognude ;
begin
end. 
=> 26.9 k

library libnude ;
begin
end.
=> 196.3 k
______________________________

Here with same 'uos' unit in 'uses' :

program proguos ;
uses
uos;
begin
end. 
=> 211.1 k

library libuos ;
uses
uos;
begin
end.
=> 1000.1 k

Many thanks.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

Michael Van Canneyt


On Mon, 3 Feb 2014, Fred van Stappen wrote:

> Hello.
>
> Here size of "nude" program and library compiled with fpc 2.7.1.
> Why is it a so big size-difference ?
>
> Compiled with => fpc 2.7.1 => linux 64
> Compiler parameters : -MObjFPC -Scghi -CX -Os1 -Xs -XX -vewnhi -fPIC

I suspect PIC is to blame. This adds a lot of tables to your library.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
> Date: Mon, 3 Feb 2014 18:30:57 +0100
> From: [hidden email]

> To: [hidden email]
> Subject: Re: [fpc-pascal] Size of program vs library ?
>
>
>
> On Mon, 3 Feb 2014, Fred van Stappen wrote:
>
> > Hello.
> >
> > Here size of "nude" program and library compiled with fpc 2.7.1.
> > Why is it a so big size-difference ?
> >
> > Compiled with => fpc 2.7.1 => linux 64
> > Compiler parameters : -MObjFPC -Scghi -CX -Os1 -Xs -XX -vewnhi -fPIC
>
> I suspect PIC is to blame. This adds a lot of tables to your library.
>
> Michael.

Hum, when compile with or without -fPIC, it does not change anything,... i get exactly the same size...
 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

Michael Van Canneyt


On Mon, 3 Feb 2014, Fred van Stappen wrote:

> > Date: Mon, 3 Feb 2014 18:30:57 +0100
> > From: [hidden email]
> > To: [hidden email]
> > Subject: Re: [fpc-pascal] Size of program vs library ?
> >
> >
> >
> > On Mon, 3 Feb 2014, Fred van Stappen wrote:
> >
> > > Hello.
> > >
> > > Here size of "nude" program and library compiled with fpc 2.7.1.
> > > Why is it a so big size-difference ?
> > >
> > > Compiled with => fpc 2.7.1 => linux 64
> > > Compiler parameters : -MObjFPC -Scghi -CX -Os1 -Xs -XX -vewnhi -fPIC
> >
> > I suspect PIC is to blame. This adds a lot of tables to your library.
> >
> > Michael.
>
> Hum, when compile with or without -fPIC, it does not change anything,... i get exactly the same size...

If I am correct, the compiler will add the PIC by itself.
But someone of the compiler team should confirm this...

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs

> If I am correct, the compiler will add the PIC by itself.
> But someone of the compiler team should confirm this...
>
> Michael.

Yep, Michael, many thanks for answer.

Sorry to insist on that, but the size of fp library is very too big vs other libraries (C for example).

But there are huge advantages to use fp library : for example i never was able to create dynamic loaded libraries who load dynamically other libraries ( not possible with gcc, nor with M$ Visual Studio).

But with fp, it is possible...

So, if it could be possible to create fp library with a reasonable size, i think fp library is the future for all other libraries...

Many thanks.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

Sven Barth-2
Am 04.02.2014 13:35, schrieb Fred van Stappen:
Sorry to insist on that, but the size of fp library is very too big vs other libraries (C for example).
The size of FPC libraries will always(*) be bigger then e.g. C ones, because in FPC the RTL is statically linked into the program/library, while C libraries link against the C runtime library.

(*) Once dynamic runtime packages are supported this might change though...

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
>>(*) Once dynamic runtime packages are supported this might change though...

>>Regards,
>> Sven

Ok, thanks Sven, that will be the best...

But before the triumph of fp, i will do that universal audio open source library with fp too...

Many thanks for all of you, fp designers....

Fred

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
In reply to this post by Sven Barth-2
>> Sorry to insist on that, but the size of fp library is very too big vs other libraries (C for example).

> The size of FPC libraries will always(*) be bigger then e.g. C ones,
> because in FPC the RTL is statically linked into the program/library, while C libraries link against the C runtime library.

> (*) Once dynamic runtime packages are supported this might change though...

> Regards,
> Sven

Hello.

This is a old topic but maybe there are some news...

Are dynamic runtime packages supported yet ?

Thanks.

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
In reply to this post by Sven Barth-2
>> Sorry to insist on that, but the size of fp library is very too big vs other libraries (C for example).

> The size of FPC libraries will always(*) be bigger then e.g. C ones,
> because in FPC the RTL is statically linked into the program/library, while C libraries link against the C runtime library.

> (*) Once dynamic runtime packages are supported this might change though...

> Regards,
> Sven

Hello.

This is a old topic but maybe there are some news...

Are dynamic runtime packages supported yet ?

Thanks.

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

Sven Barth-2
In reply to this post by fredvs
On 14.01.2017 17:18, fredvs wrote:

>>> Sorry to insist on that, but the size of fp library is very too big vs
> other libraries (C for example).
>
>> The size of FPC libraries will always(*) be bigger then e.g. C ones,
>> because in FPC the RTL is statically linked into the program/library,
>> while C libraries link against the C runtime library.
>
>> (*) Once dynamic runtime packages are supported this might change
>> though...
>
>> Regards,
>> Sven
>
> Hello.
>
> This is a old topic but maybe there are some news...
>
> Are dynamic runtime packages supported yet ?

No, they're still WIP.

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

noreply
In reply to this post by fredvs

>>> Sorry to insist on that, but the size of fp library is very too big
>>> vs
> other libraries (C for example).


Except in the case of KOL applications where many of my KOL Dll's/Exe's
were smaller than any C/C++ tool could ever create... But KOL is window's
specific mostly. Someone ported it, AFAIR, to linux using.... some gui
widget set, but I don't remember how far that got
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
In reply to this post by fredvs
Hello.

Sorry to come back with this story but there are (good) news.

Using --gc-sections makes the library smartlinked.

So the question is:

Why FPC does not provide --gc-sections to the linker with the -XX paramer for libraries ? (Bug ?)

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
fredvs wrote
Hello.

Sorry to come back with this story but there are (good) news.

Using --gc-sections makes the library smartlinked.

So the question is:

Why FPC does not provide --gc-sections to the linker with the -XX paramer for libraries ? (Bug ?)

Fre;D
Nobody uses fpc library here ?

Strange that a (big) problem with maybe a solution does not interest anybody.

The size of fpc libraries makes fpc-libraries not usable in a real world.

I use some audio C libraries and a fpc library (that only link headers of that C libraries) is 10 times bigger than the C libraries !

And when a solution (or bug) is found ---> only silence as answer.


Fre;D


Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

Michael Van Canneyt


On Mon, 15 May 2017, fredvs wrote:

> fredvs wrote
>> Hello.
>>
>> Sorry to come back with this story but there are (good) news.
>>
>> Using
> *
>> --gc-sections
> *
>>  makes the library smartlinked.
>>
>> So the question is:
>>
>> Why FPC does not provide
> *
>> --gc-sections
> *
>>  to the linker with the -XX paramer for libraries ? (Bug ?)
>>
>> Fre;D
>
> Nobody uses fpc library here ?
>
> Strange that a (big) problem with maybe a solution does not interest
> anybody.

There is no problem.

> The size of fpc libraries makes fpc-libraries not usable in a real world.

Why ?

>
> I use some audio C libraries and a fpc library (that only link headers of
> that C libraries) is 10 times bigger than the C libraries !
>
> And when a solution (or bug) is found ---> only silence as answer.

There is no bug. You are comparing apples with pears.

A C library in the traditional unix sense is a set of routines that requires
other libraries to run - ultimately requiring libc.

A FPC library - due to it's windows origings heritage - is more like a static program.
It's almost 100% standalone, and does not require other libraries to function
(except the ones you explicitly link in). Inevitably, it is bigger.

Once dynamic packages are implemented, we can start comparing apples with
apples, and pears with pears. a dynamic package is more like a C library in
the unix sense. It makes sense to compare those.

If you want to compare today, you need to add the sizes of all the C
libraries that are loaded during execution of a C program with the size
of an FPC program.

I think you'll find that the sizes of FPC programs are not so different then.

Just check the size of libc:

ls /lib/x86_64-linux-gnu/libc-2.19.so -l

-rwxr-xr-x 1 root root 1853216 Mar 21 20:24 /lib/x86_64-linux-gnu/libc-2.19.so*

That is almost 2Mb that is linked in to every C library and program.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
Michael Van Canneyt wrote
On Mon, 15 May 2017, fredvs wrote:

> fredvs wrote
>> Hello.
>>
>> Sorry to come back with this story but there are (good) news.
>>
>> Using
> *
>> --gc-sections
> *
>>  makes the library smartlinked.
>>
>> So the question is:
>>
>> Why FPC does not provide
> *
>> --gc-sections
> *
>>  to the linker with the -XX paramer for libraries ? (Bug ?)
>>
>> Fre;D
>
> Nobody uses fpc library here ?
>
> Strange that a (big) problem with maybe a solution does not interest
> anybody.

There is no problem.

> The size of fpc libraries makes fpc-libraries not usable in a real world.

Why ?

>
> I use some audio C libraries and a fpc library (that only link headers of
> that C libraries) is 10 times bigger than the C libraries !
>
> And when a solution (or bug) is found ---> only silence as answer.

There is no bug. You are comparing apples with pears.

A C library in the traditional unix sense is a set of routines that requires
other libraries to run - ultimately requiring libc.

A FPC library - due to it's windows origings heritage - is more like a static program.
It's almost 100% standalone, and does not require other libraries to function
(except the ones you explicitly link in). Inevitably, it is bigger.

Once dynamic packages are implemented, we can start comparing apples with
apples, and pears with pears. a dynamic package is more like a C library in
the unix sense. It makes sense to compare those.

If you want to compare today, you need to add the sizes of all the C
libraries that are loaded during execution of a C program with the size
of an FPC program.

I think you'll find that the sizes of FPC programs are not so different then.

Just check the size of libc:

ls /lib/x86_64-linux-gnu/libc-2.19.so -l

-rwxr-xr-x 1 root root 1853216 Mar 21 20:24 /lib/x86_64-linux-gnu/libc-2.19.so*

That is almost 2Mb that is linked in to every C library and program.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Ha, news, finally.

Huh, did you read my post ?

It talk about smartlinking of libraries that does not work.

After lot of fight, there is a solution: using --gc-sections.

And the question was :

Why FPC does not provide --gc-sections to the linker with the -XX paramer for libraries ? (Bug ?)

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

Michael Van Canneyt


On Mon, 15 May 2017, fredvs wrote:

>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> Ha, news, finally.
>
> Huh, did you read my post ?

I did.

I responded to the statement that fpc libraries are big and "unusable".

> It talk about smartlinking of libraries that does not work.
>
> After lot of fight, there is a solution: using -*-gc-sections*.
>
> And the question was :
>
> /Why FPC does not provide --gc-sections to the linker with the -XX paramer
> for libraries ? (Bug ?) /

Not providing an option is not a bug.
At best, providing this option is a feature request on your part.

Why it does not provide the option?
For the same reason that it doesn't strip binaries by default, I suppose.
Or maybe this option didn't exist when the FPC library support was
implemented ? Maybe there are even other reasons I am not aware of.

But even when you do the --gc-sections, your library will still be bigger than
corresponding C libraries for the reasons I outlined in my initial response.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

noreply
In reply to this post by Michael Van Canneyt
On 2017-05-15 04:19, Michael Van Canneyt wrote:

> If you want to compare today, you need to add the sizes of all the C
> libraries that are loaded during execution of a C program with the
> size of an FPC program.
>
> I think you'll find that the sizes of FPC programs are not so different
> then.
>
> Just check the size of libc:
>
> ls /lib/x86_64-linux-gnu/libc-2.19.so -l


But if FPC also uses libc, in units like unix/linux/other .pp units,
that means FPC is using C libs too..

This also was a claim made by Golang that it doesn't use C code so you
are comparing apples to Women, but in fact, the women eat apples and
oranges and See (C) too.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

noreply
In reply to this post by fredvs
On 2017-05-15 04:26, fredvs wrote:
> After lot of fight, there is a solution: using -*-gc-sections*.
>
> And the question was :
>
> /Why FPC does not provide --gc-sections to the linker with the -XX
> paramer
> for libraries ? (Bug ?) /


Hopefully that's all there is to it, but how do you know that this
doesn't just work for your current code and is not reliable for all
situations?

If that's all there is too it, that's cool! But maybe fpc left it out
for a reason: like it only works in some test cases of libraries, but
not all test cases?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

Michael Van Canneyt
In reply to this post by noreply


On Mon, 15 May 2017, [hidden email] wrote:

> On 2017-05-15 04:19, Michael Van Canneyt wrote:
>> If you want to compare today, you need to add the sizes of all the C
>> libraries that are loaded during execution of a C program with the
>> size of an FPC program.
>>
>> I think you'll find that the sizes of FPC programs are not so different
>> then.
>>
>> Just check the size of libc:
>>
>> ls /lib/x86_64-linux-gnu/libc-2.19.so -l
>
>
> But if FPC also uses libc, in units like unix/linux/other .pp units,
> that means FPC is using C libs too..

Unless the user specifically includes it: It does not.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Size of program vs library ?

fredvs
In reply to this post by noreply
noreply wrote
On 2017-05-15 04:26, fredvs wrote:
> After lot of fight, there is a solution: using -*-gc-sections*.
>
> And the question was :
>
> /Why FPC does not provide --gc-sections to the linker with the -XX
> paramer
> for libraries ? (Bug ?) /


Hopefully that's all there is to it, but how do you know that this
doesn't just work for your current code and is not reliable for all
situations?

If that's all there is too it, that's cool! But maybe fpc left it out
for a reason: like it only works in some test cases of libraries, but
not all test cases?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
It works for all situations, so I propose that fpc add --gc-sections as parameter for the linker if the user has used -XX parameter to compile a library.

Fre;D
Many thanks ;-)
123