libtool
[Top][All Lists]
Advanced

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

Re: [Fwd: libtool munges '-(' linker options.]


From: Scott James Remnant
Subject: Re: [Fwd: libtool munges '-(' linker options.]
Date: 09 Mar 2003 04:21:47 +0000

On Sun, 2002-12-15 at 17:09, Albert Chin wrote:

> On Sun, Dec 15, 2002 at 04:42:42PM +0000, Scott James Remnant wrote:
> > Certain applications require the linker flags --start-group
> > and --end-group (abbreviated "-(" and "-)" ) in order to
> > resolve circular references between libraries.  However,
> > libtool "sorts" these flags and places them at the beginning
> > of the command-line, destroying their utility.  At the end
> > of this report is a uuencoded archive containing three
> > source files and a Makefile demonstrating the problem.
> > We end up with an archive A.a which uses symbols defined in B.a
> > and an archive B.a which uses symbols defined in A.a --- a
> > circular dependency.  The command:
> >   gcc -o foo c.o -Wl,"-(" A.a B.a -Wl,"-)"
> > correctly builds these archives into an executable by telling
> > ld that it should iterate over A.a and B.a to resolve all
> > circular references, instead of ld's usual search-once strategy.
> > However:
> >   libtool gcc -o foo c.o -Wl,"-(" A.a B.a -Wl,"-)"
> > yields:
> >   $ libtool gcc -o foo c.o -Wl,"-(" A.a B.a -Wl,"-)"
> >   gcc -o foo c.o -Wl,"-(" -Wl,"-)"  A.a B.a
> >   B.a(b.o): In function `b':
> >   b.o(.text+0x1b): undefined reference to `a'
> >   collect2: ld returned 1 exit status
> > 
> > As you can see, libtool re-orders the -( and -) flags, destroying
> > their function.  This is a bug in libtool (and it's making my
> > life quite difficult at the moment).
> 
> Why not invoke libtool as:
>   $ libtool gcc -o foo c.o -Wl,"-(",A.a,B.a,"-)"
> 
It actually turns out they weren't using ".a" files but ".la" files
instead.

I've received the following follow-up:

----8<--------8<--------8<--------8<--------8<--------8<--------8<----
Your proposed solution will not work.  The complete command-line from my
application is:
   $(LIBTOOL) --mode=link $(CC) $(STATIC_FLAG) $(AM_CFLAGS) $(CFLAGS) \
     $(LDFLAGS) -o $@ -Wl,-Tinclude/asm/link-script "-Wl,-(" \
     src/libflexc0.la $< src/libflexc1.la "-Wl,-)" @GC_LIB@ @LIBS@

Note that the ".la" files cannot be passed unmodified to the linker.
libtool *must* munge these appropriately *without* affecting the order
in which the -( flags are passed.  The patch I provided does solve this
problem.
---->8-------->8-------->8-------->8-------->8-------->8-------->8----

Any further ideas?

Scott
-- 
Scott James Remnant     Have you ever, ever felt like this?  Had strange
http://netsplit.com/      things happen?  Are you going round the twist?

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


reply via email to

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