Re: GDB 8.3.1 gdbserver linker error: needs -lrt

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 2020-01-30 5:17 p.m., Paul Smith wrote:
> On Thu, 2020-01-30 at 16:35 -0500, Simon Marchi wrote:
>> GDBSERVER_LIBS is a variable in gdb/gdbserver/Makefile, but I don't
>> think it's meant to be overriden from the command line.
> 
> Sure, but even if it's not meant to be overridden it should be possible
> to do so.  make always obeys variable overrides on the command line,
> and also passes those overrides along to sub-makes; the only way to
> avoid that is do to odd things with make recursion.
> 
>> It would probably work to set LIBS while configuring gdbserver:
>>
>>   ./configure LIBS="-lrt"
> 
> When you say "configuring gdbserver" I'm not sure what you mean, but
> definitely doing this in the root of the GDB distribution does not
> work.  The root makefile will have LIBS=-lrt in it, but that variable
> is not passed on.

Hmm right, the list of things passed down is explicit, and LIBS is not part
of that.  I don't really know if passing down LIBS would be the right thing
to do or not.

> Further, the link line for gdbserver doesn't include that variable;
> it's just:
> 
>   gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS} $(LIBGNU) $(LIBIBERTY)
>         $(SILENCE) rm -f gdbserver$(EXEEXT)
>         $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
>                 -o gdbserver$(EXEEXT) $(OBS) $(LIBGNU) $(LIBIBERTY) \
>                 $(GDBSERVER_LIBS) $(XM_CLIBS)
> 

When I suggested that, I expected that LIBS would be set in the environment
when gdbserver's configure would run, and so it would pick it up and add it
to the link line, given that `./gdb/gdbserver/configure --help` says:

  Some influential environment variables:
    ...
    LIBS        libraries to pass to the linker, e.g. -l<library>

That part seems to work.  When I do

  ./configure LIBS="-lpopt"

directly in gdbserver's source directory, popt ends up listed as:

  XM_CLIBS = -lpopt

in the generated Makefile.  XM_CLIBS is included in the link line for
gdbserver, but it's not in the IPA's.  I have no idea what XM_CLIBS stands
for.

> None of the "normal" libs variables are listed in this link line. 
> That's why I chose GDBSERVER_LIBS.
> 
> The link line for libinproctrace.so is even less configurable:
> 
>   $(IPA_LIB): $(sort $(IPA_OBJS)) ${CDEPS}
>         $(SILENCE) rm -f $(IPA_LIB)
>         $(ECHO_CXXLD) $(CC_LD) -shared -fPIC -Wl,--soname=$(IPA_LIB) \
>                 -Wl,--no-undefined $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
>                 -o $(IPA_LIB) ${IPA_OBJS} -ldl -pthread
> 
>> That would work around the problem, but if you want to fix it for
>> good, for all users in the same situation, then it would probably
>> require a patch to configure.ac, to add "-lrt" to LIBS when needed.
> 
> Yes, definitely... that's why I posted the message :).


Sorry I can't be of more help, I'm probably as (or more) confused by the
situation as you are.

Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.