[openib-general] Static linking with libibverbs

Michael S. Tsirkin mst at mellanox.co.il
Thu Nov 2 05:52:18 PST 2006


Quoting r. Jeff Squyres <jsquyres at cisco.com>:
> Subject: Re: Static linking with libibverbs
> 
> On Nov 2, 2006, at 8:13 AM, Michael S. Tsirkin wrote:
> 
> > Quoting r. Jeff Squyres <jsquyres at cisco.com>:
> >> Yes.  See the FAQ items on the OMPI web site from my first mail.
> >
> > OK, I see.
> > So what it boils down to, is linking with
> > -Wl,--whole-archive -libverbs <path>/mthca.a -Wl,--no-whole-archive
> > Is that right?
> 
> There's a few other details, but this is the Main Point, yes.
> 
> > But -u openib_driver_init will work as well, won't it?
> 
> I'm not entirely sure -- it might (I didn't try it).  It *should*  
> force creation of a valid code path into mthca.a and therefore use it  
> for all the resolution that is required (i.e., link in all the parts  
> of mthca.a that are actually required).

Since it worked for linking with static mthca.a and libiverbs.a,
I think it will link with -static as well.

> What I'm not sure about is whether the symbols that mthca needs from  
> libibverbs will be linked in properly (since the linker order is left  
> to right "-libverbs <path>/mthca.a").  I *think* they'll be available  
> from when mthca.a was originally created (i.e., libibverbs.a was  
> statically linked into mthca.a),

Surely not. mthca.a does not include objects from libibverbs.a

> but I don't know if the linker will  
> be smart enough to realize that there are two copies of some symbols  
> in libibverbs and further to realize that they are actually  
> duplicates of the same underlying symbol, and one can be safely  
> eliminated.  It's worth trying (but I don't really care too much :-) ).
> 
> Every time I think I understand linkers, we get weirdo cases like  
> this that make me remember I have no clue how they work.  :-)

Note that .a files are not actually created by the linker.

-- 
MST




More information about the general mailing list