Re: Any easy way to aggregate and segregate only needed code forgcc ?

On 2013-08-25 11:16, pbhat wrote:

> I am new to this. Any advise in the right direction will be of great
> help. Thanks in advance.

I had to do that years ago, but it was for MsDOS and using Borlandc. In
that case, any function in an object file where another function was
actually called, got linked, used or not. The trick was to put a single
function per file.c, which generated a single file.obj. Then, the entire
lot of object files could be collected into a archive.lib.

It worked, only used functions got linked.
Compiling time skyrocketed, though.

On the other hand, another language from the same brand, Borland Pascal,
did the pruning internally, automatically and fast. the result was that
hello.c produced a much larger file (6 times?) than hello.pas.

The situation in Linux will depend on what the linker does.
Unfortunately I lack the knowledge to answer this, but I’m interested in
learning about it. Maybe you can ask in forums dedicated to embedded
design, they will have hit the same issue before you. Or have a look at
how busybox does it.

Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

Thank you.