libtool
[Top][All Lists]
Advanced

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

Re: Linking just some static


From: Ralf Wildenhues
Subject: Re: Linking just some static
Date: Mon, 23 Feb 2009 10:45:22 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

* Jan Engelhardt wrote on Tue, Feb 17, 2009 at 12:56:39AM CET:
> On Monday 2009-02-16 19:56, Ralf Wildenhues wrote:
> ><http://thread.gmane.org/gmane.comp.gnu.libtool.patches/6727/focus=6730>
> >
> >Can you try out the patch, and report back?
> 
> It works, but does not yet deal with some cases.
> 
> My first try was:
> 
>   p1_LDADD = -Bstatic libours.la -Bdynamic libtheirs.la
> 
> automake then responded:
> 
>   Makefile.am:11: linker flags such as `-Bstatic' belong in `p1_LDFLAGS'

This needs fixing in Automake, of course.  This belongs in *LDADD.

> I had naturally added -Bstatic to p1_LDADD because that is where all
> the libraries are. Moving it to p1_LDFLAGS means that I give up
> part of the dependency tracking — `make p1` will then not built
> libours.la beforehand.

Exactly.

> The other issue is that since -Bstatic is passed verbatim down to ld,
> I get an error:

>   /bin/sh ./libtool  --tag=CC   --mode=link gcc -Wall -g -O2
>   -Bstatic libours.la -Bdynamic libtheirs.la  -o p1 p1.o  
> 
>   libtool: link: gcc -Wall -g -O2 -o .libs/p1 p1.o   -Wl,-Bstatic
>   ./.libs/libours.a /usr/lib/libHX.so -ldl -Wl,-Bdynamic ./.libs/libtheirs.so 
> 
>   /usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/bin/ld:
>   attempted static link of dynamic object `/usr/lib/libHX.so'
> 
> The (simplified) Makefile goes like:
> 
>   libours_la_LIBADD = -lHX
>   p1_LDFLAGS = -Bstatic libours.la -Bdynamic libtheirs.la
> 
> [libHX is a library for which I do not have a static .a version installed.]

> What I had in mind though was not what libtool currently does
> (namely, passing -Bstatic/dynamic to the linker verbatim), but something
> more along the lines of the libtool "-static" flag, that is, the
> linker to be called with
> 
>   gcc -Wall -g -O2 -o .libs/p1 p1.o .libs/libours.a /usr/lib/libHX.so
>   -ldl .libs/libtheirs.so

OK so I guess the patch still has a bug in that it may require, not only
prefer, static libraries with -Bstatic.

There was some discussion over whether "require" or "prefer" semantics
were desirable in the referenced thread, and there is no general
consensus on which meaning to implement (or whether to try and go for
both).

So it's back to the drawing and testing board for the patch.  One of
the problems is that
- for the "prefer one type of library but not the other" we might have
  to drop the switches for libraries which don't match,
- for the "require one type of library" we might have to test library
  types on systems where we didn't really care about it before (AIX).
  And we might have to use different switches (HP-UX, which has four
  switches for prefer/require static/shared).
  <http://wiki.azazil.net/GnuLibtoolProject/FeatureRequests/PerDeplibFlags>

Sigh.

Cheers,
Ralf




reply via email to

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