[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fwd: libtool munges '-(' linker options.]
From: |
Robert Boehne |
Subject: |
Re: [Fwd: libtool munges '-(' linker options.] |
Date: |
Mon, 10 Mar 2003 08:58:28 -0600 |
Scott,
Rather than pass linker flags with libtool libraries between -( and -)
you should put the actual library you want there, i.e.
../foo/.libs/libfoo.a
or whatever it may be. Fundamentally it doesn't make much sense to have
a libtool library in the middle of a slew of flags that aren't portable
anyway.
HTH,
Robert
Scott James Remnant wrote:
>
> 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?
>
> ------------------------------------------------------------------------
> Name: signature.asc
> signature.asc Type: application/pgp-signature
> Description: This is a digitally signed message part
>
> ------------------------------------------------------------------------
> _______________________________________________
> Libtool mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/libtool