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: [PATCH] Add plugin interface to LD [2/4] Claim files and add symbols.


[ groan, fat-fingered the send key prematurely... ]

[ Sorry to return to this issue, but I still haven't fixed it yet. ]

On 23/09/2010 07:13, Ralf Wildenhues wrote:
> * Dave Korn wrote on Thu, Sep 23, 2010 at 08:25:42AM CEST:
>> On 23/09/2010 06:36, Ralf Wildenhues wrote:
>>> * Dave Korn wrote on Thu, Sep 23, 2010 at 07:31:41AM CEST:
>>>> --- a/ld/Makefile.am
>>>> +++ b/ld/Makefile.am
>>>> @@ -1989,7 +1989,7 @@ if ENABLE_PLUGINS
>>>>  noinst_LTLIBRARIES = libldtestplug.la
>>>>  libldtestplug_la_SOURCES = testplug.c
>>>>  libldtestplug_la_CFLAGS= -g -O2
>>>> -libldtestplug_la_LDFLAGS = -no-undefined -rpath /nowhere
>>>> +libldtestplug_la_LDFLAGS = -no-undefined -rpath /nowhere -Wl,$(LIBIBERTY)
>>> Why the '-Wl,' prefix?  I'd have expected $(LIBIBERTY) to be added to
>>> libldtestplug_la_LIBADD.
>>   libiberty isn't built under libtool control at all, AFAIK, and is only ever
>> built as a static archive, so I was under the impression I've got to pass it
>> around behind libtool's back like this.
>
> Not because of that, no.
>
>>> If you need to work around libtool warning about adding static library
>>> deps to a shared library, then I suggest at least -Wc, rather than -Wl,
>>> but still I think you will run into troubles on static-only systems.
>>   What kind of problems?
>
> Ordering.  You can't rely on libtool expanding -Wl, link flags after the
> objects, meaning that libiberty may not be picked up at all.  (With
> static linking, objects and libraries are evaluated in a strict command
> line order, so all needed libraries must come after objects that need
> them.)

  Seems I'm not the only one who has this problem.  The makefile for GCC's
lto-plugin links libiberty like so:

> liblto_plugin_la_LIBADD = $(LIBELFLIBS) ../libiberty/pic/libiberty.a

which produces this warning on Linux:

> /bin/sh ./libtool --tag=CC   --mode=link /gnu/gcc/obj.clean/./prev-gcc/xgcc -B/gnu/gcc/obj.clean/./prev-gcc/ -B/opt/gold/i686-pc-linux-gnu/bin/ -B/opt/gold/i686-pc-linux-gnu/bin/ -B/opt/gold/i686-pc-linux-gnu/lib/ -isystem /opt/gold/i686-pc-linux-gnu/include -isystem /opt/gold/i686-pc-linux-gnu/sys-include    -Wall -Werror -g -O2 -fomit-frame-pointer -gtoggle   -o liblto_plugin.la -rpath /opt/gold/libexec/gcc/i686-pc-linux-gnu/4.6.0 lto-plugin.lo -lelf ../libiberty/pic/libiberty.a 
> 
> *** Warning: Linking the shared library liblto_plugin.la against the
> *** static library ../libiberty/pic/libiberty.a is not portable!


  When I try using LIBADD to link a static archive into a shared library on
Cygwin, such as like so:

> libldtestplug_la_LIBADD = $(LIBIBERTY)

... that warning becomes an error:

> *** Warning: Trying to link with static lib archive ../libiberty/libiberty.a.
> *** I have the capability to make that library automatically link in when
> *** you link to this library.  But I can only do this if you have a
> *** shared version of the library, which you do not appear to have
> *** because the file extensions .a of this argument makes me believe
> *** that it is just a static archive that I should not use here.

... and the link fails with unresolved symbols:

> Creating library file: .libs/libldtestplug.dll.a.libs/libldtestplug_la-testplug.
> o: In function `record_claim_file':
> /gnu/binutils/git.repo/binutils/ld/testplug.c:148: undefined reference to `_xmalloc'
> .libs/libldtestplug_la-testplug.o: In function `record_claimed_file_symbol':
> /gnu/binutils/git.repo/binutils/ld/testplug.c:261: undefined reference to `_xrealloc'
> .libs/libldtestplug_la-testplug.o: In function `record_add_file':
> /gnu/binutils/git.repo/binutils/ld/testplug.c:166: undefined reference to `_xmalloc'
> /gnu/binutils/git.repo/binutils/ld/testplug.c:166: undefined reference to `_xmalloc'
> /gnu/binutils/git.repo/binutils/ld/testplug.c:166: undefined reference to `_xmalloc'
> collect2: ld returned 1 exit status
> 
> make[2]: *** [libldtestplug.la] Error 1

  So if -Wl won't work, what can I do?  Do I have to build a libtool
convenience library out of the libiberty object files?

    cheers,
      DaveK


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