GDB 8.3.1 gdbserver linker error: needs -lrt

Paul Smith psmith@gnu.org
Thu Jan 30 22:17:00 GMT 2020


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.

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)

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 :).

Cheers!



More information about the Gdb mailing list