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 21:35:00 -0000	[thread overview]
Message-ID: <49c1cc4a-fe1b-8e35-b16b-76d9faec2173@simark.ca> (raw)
In-Reply-To: <06b764efa74573c9422da526f9d92aa2d9440e73.camel@gnu.org>

On 2020-01-30 4:23 p.m., Paul Smith wrote:
> Hi all;
> 
> I was trying to compile the latest GDB for my system and the link of
> gdbserver failed:
> 
> .../lib64/libstdc++.a(chrono.o):function std::chrono::_V2::system_clock::now(): error: undefined reference to 'clock_gettime'
> .../lib64/libstdc++.a(chrono.o):function std::chrono::_V2::steady_clock::now(): error: undefined reference to 'clock_gettime'
> 
> As you can see I compile with static libstdc++.  Also, I'm building
> against a pretty old version of GNU/Linux with an older GNU libc
> (CentOS 6.5 or so).
> 
> The problem is that on systems this old you need to add -lrt to the
> link line in order to get clock_gettime(), and the configure script
> doesn't look for this.
> 
> This causes both gdbserver and libinproctrace.so to fail to link,
> unless I hack the makefiles.
> 
> Gdb itself links properly because I'm linking with lzma and those libs
> happen to include -lrt:
> 
>   LIBLZMA = .../lib/liblzma.a -lrt
> 
> 
> Oddly enough, adding GDBSERVER_LIBS="-ldl -lrt" to the top GDB make
> command doesn't work (even for gdbserver: libinproctrace.so has no
> equivalent customizable library). I didn't look through the build
> system to figure out how my command line overrides are being lost but
> that's also something that should be fixed...
> 

GDBSERVER_LIBS is a variable in gdb/gdbserver/Makefile, but I don't think
it's meant to be overriden from the command line.  It's just an internal
variable to simplify the Makefile, as well as an autoconf variable (not sure
if that's the right term) that gets replaced in Makefile.in.

It would probably work to set LIBS while configuring gdbserver:

  ./configure LIBS="-lrt"

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.

Simon

  reply	other threads:[~2020-01-30 21:35 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 [this message]
2020-01-30 22:17   ` Paul Smith
2020-01-30 22:50     ` Simon Marchi
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=49c1cc4a-fe1b-8e35-b16b-76d9faec2173@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).