public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: psmith@gnu.org, gdb@sourceware.org
Subject: Re: GDB 8.3.1 gdbserver linker error: needs -lrt
Date: Thu, 30 Jan 2020 22:50:00 -0000	[thread overview]
Message-ID: <f229a4d6-6522-f9ca-bd0a-e67f8a2f95a5@simark.ca> (raw)
In-Reply-To: <d67c570a8d2f2a5f4775891ff7b858365c868382.camel@gnu.org>

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

  reply	other threads:[~2020-01-30 22:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 21:23 Paul Smith
2020-01-30 21:35 ` Simon Marchi
2020-01-30 22:17   ` Paul Smith
2020-01-30 22:50     ` Simon Marchi [this message]
2020-01-31  7:44       ` Eli Zaretskii
2020-01-31 16:48         ` Paul Smith
2020-01-31 17:17           ` Eli Zaretskii
2020-01-31 17:23             ` Paul Smith
2020-02-01  3:05               ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f229a4d6-6522-f9ca-bd0a-e67f8a2f95a5@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb@sourceware.org \
    --cc=psmith@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).