From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125572 invoked by alias); 30 Jan 2020 22:50:03 -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 125564 invoked by uid 89); 30 Jan 2020 22:50:03 -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=H*f:sk:d67c570, H*i:sk:d67c570, H*MI:sk:d67c570, gdbservers 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 22:50:01 +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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 2C62D1E512; Thu, 30 Jan 2020 17:50:00 -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> <49c1cc4a-fe1b-8e35-b16b-76d9faec2173@simark.ca> From: Simon Marchi Message-ID: Date: Thu, 30 Jan 2020 22:50: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: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-01/txt/msg00083.txt.bz2 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 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