bug-gnulib
[Top][All Lists]
Advanced

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

Re: --as-needed linker option causes trouble with -lreadline/-ltermcap


From: Ralf Wildenhues
Subject: Re: --as-needed linker option causes trouble with -lreadline/-ltermcap
Date: Sat, 28 Mar 2009 17:02:36 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Jim,

* Jim Meyering wrote on Sat, Mar 28, 2009 at 03:22:14PM CET:
> When testing for the readline library, this works fine:
> 
>     echo 'char readline (); int main () { return readline (); }' > k.c
>     gcc k.c -lreadline -ltermcap
> 
> but in order to work around portability problems years ago, gnulib's
> lib-ignore.m4 makes it so the linker uses the --as-needed option:
> 
>     gcc k.c -Wl,--as-needed -lreadline -ltermcap
> 
> and that fails on RHEL 5.3
> (with binutils-2.17.50.0.6-9.el5.x86_64 and gcc-4.1.2-44.el5.x86_64):
> 
>     /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: 
> undefined reference to `PC'
>     /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: 
> undefined reference to `tgetflag'

libreadline depends upon libtermcap, but does not announce this
dependency with a DT_NEEDED entry (i.e., -ltermcap was not passed
to the command creating libreadline.so).  This is arguably a bug
in libreadline (but probably done intentionally to allow choosing
either termcap or ncurses or so).

To work around it in the test, I suppose you can link a program
that also requires a symbol from termcap.

Anyway, I thought CVS binutils had a patch to deal with this setup,
but reading the ld/NEWS entry, I'm not so sure anymore whether it
is sufficient:

  * --as-needed now links in a dynamic library if it satisfies undefined
    symbols in regular objects, or in other dynamic libraries.  In the
    latter case the library is not linked if it is found in a DT_NEEDED
    entry of one of the libraries already linked.

Hope that helps.

Cheers,
Ralf




reply via email to

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