From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IkCXLj2T11/SYwAAWB0awg (envelope-from ) for ; Mon, 14 Dec 2020 11:30:53 -0500 Received: by simark.ca (Postfix, from userid 112) id B32E81F0AA; Mon, 14 Dec 2020 11:30:53 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI,RDNS_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5CBBC1E99A for ; Mon, 14 Dec 2020 11:30:53 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C4A1385042A; Mon, 14 Dec 2020 16:30:52 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 02D023854815 for ; Mon, 14 Dec 2020 16:30:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 02D023854815 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca 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 9C91B1E99A; Mon, 14 Dec 2020 11:30:49 -0500 (EST) Subject: Re: [PATCH][gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib To: Tom de Vries , gdb-patches@sourceware.org References: <20201207122016.GA14320@delia> From: Simon Marchi Message-ID: <1373362e-778e-65f6-1d85-3e75e1c34823@simark.ca> Date: Mon, 14 Dec 2020 11:30:49 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201207122016.GA14320@delia> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-12-07 7:20 a.m., Tom de Vries wrote: > Hi, > > When running test-case gdb.base/info-shared.exp, I see in gdb.log: > ... > Executing on host: \ > gcc ... -fPIC -fpic -c -o info-shared-solib1.c.o info-shared-solib1.c > ... > > The -fPIC comes from the test-case: > ... > if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \ > [list additional_flags=-fPIC]] != "" } { > ... > but the -fpic, which overrides the -fPIC comes from gdb_compile_shlib. > > The proc gdb_compile_shlib adds the -fpic or similar dependent on platform > and compiler. However, in some cases it doesn't add anything, which is > probably why all those test-case pass -fPIC. > > Fix this by removing -fPIC from all the calls to gdb_compile_shlib, and > ensuring that gdb_compile_shlib takes care of adding it, if required. > > Tested on x86_64-linux. > > Any comments? I agree with the direction, where the test cases themselves should encode the least knowledge as possible about how to compile things. So from my point of view, this LGTM. Just one formatting nit below. > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index e413bab93c..e35d236018 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -4304,17 +4304,21 @@ proc gdb_compile_shlib {sources dest options} { > lappend obj_options "additional_flags=-qpic" > } > "clang-*" { > - if { !([istarget "*-*-cygwin*"] > - || [istarget "*-*-mingw*"]) } { > + if { [istarget "*-*-cygwin*"] > + || [istarget "*-*-mingw*"] } { > + lappend obj_options "additional_flags=-fPIC" > + } else { > lappend obj_options "additional_flags=-fpic" > } > } > "gcc-*" { > - if { !([istarget "powerpc*-*-aix*"] > + if { [istarget "powerpc*-*-aix*"] > || [istarget "rs6000*-*-aix*"] > || [istarget "*-*-cygwin*"] > || [istarget "*-*-mingw*"] > - || [istarget "*-*-pe*"]) } { > + || [istarget "*-*-pe*"] } { The last line is not aligned with the others. I never know how to properly wrap TCL code, but you can at least make them aligned with the existing ones. Simon