[openib-general] Static linking with libibverbs

Jeff Squyres jsquyres at cisco.com
Thu Nov 2 05:23:28 PST 2006


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).

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), 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.  :-)

-- 
Jeff Squyres
Server Virtualization Business Unit
Cisco Systems





More information about the general mailing list