From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36527 invoked by alias); 30 Jan 2020 21:35:38 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 36516 invoked by uid 89); 30 Jan 2020 21:35:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=configuring, H*f:sk:06b764e, H*i:sk:06b764e X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Jan 2020 21:35:36 +0000 Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 022EB1E81F; Thu, 30 Jan 2020 16:35:34 -0500 (EST) Subject: Re: GDB 8.3.1 gdbserver linker error: needs -lrt To: psmith@gnu.org, gdb@sourceware.org References: <06b764efa74573c9422da526f9d92aa2d9440e73.camel@gnu.org> From: Simon Marchi Message-ID: <49c1cc4a-fe1b-8e35-b16b-76d9faec2173@simark.ca> Date: Thu, 30 Jan 2020 21:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <06b764efa74573c9422da526f9d92aa2d9440e73.camel@gnu.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-01/txt/msg00081.txt.bz2 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