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: Option -static


On Thursday 07 January 2010 15:31:12 Takis Psarogiannakopoulos wrote:
> On Thu, 7 Jan 2010, H.J. Lu wrote:
> > On Thu, Jan 7, 2010 at 10:02 AM, Ian Lance Taylor <iant@google.com> wrote:
> > > If anybody actually implements this, I think better would be something
> > > like -Bprefer-static and -Bprefer-dynamic, and make them position
> > > dependent like -Bstatic and -Bdynamic.
> >
> > Sounds good to me.
> 
> I would implement that option if nobody else does/has already . I needed
> in any case for the OS I am running.  -Bprefer-static  sounds good,
> I am not sure about the position dependent part, as -Bstatic and -Bdynamic
> already do exactly that.
> -Bprefer-dymamic is in any case the default behavior of gold/gnu ld
> right? Nothing to implement really.

if you do attempt this, make sure you account for edge cases like 
shared/static libs being in different dirs and encountering them in different 
orders.  atm, the default gnu ld will pick the first library it finds whether 
it's static or dynamic.  i'd expect a "prefer" option to search all paths for 
the preferred type and if that fails, fall back to the default behavior (any 
valid type).  perhaps you'll need a third option of "-Bprefer-default" so that 
the default behavior can be restored to the implicit link options ...

examples would be:
$ tree
./main.c
./shared/libfoo.so
./static/libfoo.a
$ gcc main.c -Lshared -Lstatic -Wl,-Bprefer-static -lfoo -Wl,-Bprefer-default
$ gcc main.c -Lstatic -Lshared -Wl,-Bprefer-static -lfoo -Wl,-Bprefer-default
	... static/libfoo.a is used ...
$ gcc main.c -Lshared -Lstatic -Wl,-Bprefer-dynamic -lfoo -Wl,-Bprefer-default
$ gcc main.c -Lstatic -Lshared -Wl,-Bprefer-dynamic -lfoo -Wl,-Bprefer-default
	... static/libfoo.so is used ...
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


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