help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: partial linking


From: Ralf Wildenhues
Subject: Re: partial linking
Date: Fri, 5 Sep 2008 09:09:34 +0200
User-agent: Mutt/1.5.18 (2008-07-21)

Hello,

* tns1 wrote on Thu, Sep 04, 2008 at 10:12:27PM CEST:
> I have source tree with many folders containing many .o files each. I  
> wish to partially link the contents of each folder so I have one  
> combined .o file (library?) for each folder. These combined (object  
> files?, libraries?) will go thru a final link step at a later stage in  
> the build.

The combined .o files are just objects again, not libraries.

> Is there anything special about how this partial linking or can I just  
> do something like:
>
> $(OBJS)=a.o b.o c.o
> mylink.b : $(OBJS)
>       ld -o mylink.b $(OBJS)

BTW, why mylink.b and not mylink.o?  I think some vendor ld's may warn
about this, or fail to do the right thing.  Also, for partial linking
you would need to pass -r to ld.

> Does building in this multi-tiered fashion result in a larger final  
> image, or can the final link still remove redundancies?

You did not state what the final link will create.  If it creates a
static library, then your approach may introduce larger code into
programs that use this library, e.g., because the program really only
needs code from a.o but it then gets that from b.o and c.o, too.

If your final link creates a shared library or program, then I don't
think that there is anything to throw away.

Please note that partial linking isn't as portable as other ways of
linking.  Esp. since it's less commonly used, on some systems the GNU
binutils ld had a few bugs until recently (or still has, I don't know).

FWIW, depending on whether you can assume GNU ld, GNU make, or whether
you would be willing to use libtool, some optimizations and/or
simplifications may be applied to your general setup.
(I can expand but then please specify on which.)

Hope that helps.

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]