This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ar: POSIX way of creating static library containing similarly named objects


Hi Nick,

On Fri, 19 Apr 2013 08:58:43 +0100, nick clifton wrote:

> Use the 'q' option rather than the 'r' option when adding the object
> files to the library - and create the symbol index after adding the
> objects, rather than at the same time.  Ie:
> 
>    % ar cr libstate.a src/namespace_foo/state.o % ar q  libstate.a
>    src/namespace_bar/state.o % ar s  libstate.a % readelf -c libstate.a
>    Index of archive libstate.a: (2 entries, 0x8 bytes in the symbol
>    table)
>    Binary libstate.a(state.o) contains:
>          foo
>    Binary libstate.a(state.o) contains:
>          foo

This technique worked really well until I noticed strange behaviour when 
running programs generated from partial builds where symbols were getting 
duplicated in the library and not replaced as they should.

Only solution to this (that I can see) would be to rebuild the library 
each time a partial build is initiated and add every single object using 
the `q' option, but in large projects this isn't really viable.

Another possible solution is to drop my pedantic hat and just go with 
Cary's suggestion of using a thin archive instead.

Nick and Cary, thanks for the input.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]