From patchwork Thu Jul 23 21:12:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1335142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BCQ6M2Lqxz9sPB for ; Fri, 24 Jul 2020 07:13:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34EAC3861962; Thu, 23 Jul 2020 21:13:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 0FCA83861962 for ; Thu, 23 Jul 2020 21:13:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0FCA83861962 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oliva@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 49C10116931; Thu, 23 Jul 2020 17:13:09 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id uDmIyCCIpuw5; Thu, 23 Jul 2020 17:13:09 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 5DBF211692E; Thu, 23 Jul 2020 17:13:08 -0400 (EDT) Received: from livre.home (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 06NLCxPc2318670 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Jul 2020 18:12:59 -0300 From: Alexandre Oliva To: Andrea Corallo Subject: [PR95720] protect gluefile and wrap_flags with -Wl too (was: Re: drop -aux{dir,base}, revamp -dump{dir,base}) In-Reply-To: (Alexandre Oliva's message of "Tue, 23 Jun 2020 06:50:26 -0300") Organization: Free thinker, does not speak for AdaCore References: <874krkqte6.fsf@euler.schwinge.homeip.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Date: Thu, 23 Jul 2020 18:12:59 -0300 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek , Richard Biener , ebotcazou@adacore.com, gcc-patches@gcc.gnu.org, Thomas Schwinge , joseph@codesourcery.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The testglue object file gets interpreted as another input file, changing the dump and aux output names in GCC unless it is protected by -Wl, like board file-named extra inputs. Refactor the code that modifies the board settings so that it can be used to modify regular variables as well, and do so. Regstrapped on x86_64-linux-gnu, fix confirmed on an affected platform by the bug reporter. Ok to install? for gcc/testsuite/ChangeLog PR testsuite/95720 * lib/gcc-defs.exp (gcc_adjust_linker_flags_list): Split out of... (gcc_adjust_linker_flags): ... this. Protect gluefile and wrap_flags. * gcc.misc-tests/outputs.exp: Use gcc_adjust_linker_flags_list. --- gcc/testsuite/gcc.misc-tests/outputs.exp | 14 ++------ gcc/testsuite/lib/gcc-defs.exp | 55 ++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/gcc/testsuite/gcc.misc-tests/outputs.exp b/gcc/testsuite/gcc.misc-tests/outputs.exp index 469d94c..0784a8e 100644 --- a/gcc/testsuite/gcc.misc-tests/outputs.exp +++ b/gcc/testsuite/gcc.misc-tests/outputs.exp @@ -56,17 +56,9 @@ set link_options "" set dest [target_info name] foreach i { ldflags libs ldscript } { if {[board_info $dest exists $i]} { - set skip "" - foreach opt [split [board_info $dest $i]] { - if { $opt == "" } then { - continue - } elseif { $skip != "" } then { - set skip "" - } elseif { $opt == "-Xlinker" } then { - set skip $opt - } elseif { ![string match "-*" $opt] && [file isfile $opt] } { - set opt "-Wl,$opt" - } + set opts [board_info $dest $i] + set nopts [gcc_adjust_linker_flags_list $opts] + foreach opt $nopts { append link_options " additional_flags=$opt" } } diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp index 87eeb7d..380a18b 100644 --- a/gcc/testsuite/lib/gcc-defs.exp +++ b/gcc/testsuite/lib/gcc-defs.exp @@ -287,9 +287,32 @@ proc dg-additional-files { args } { set gcc_adjusted_linker_flags 0 -# Add -Wl, before any file names in ldflags, libs, and ldscript, so -# that default object files or libraries do not change the names of -# gcc auxiliary outputs. +# Add -Wl, before any file names in $opts. Return the modified list. + +proc gcc_adjust_linker_flags_list { args } { + set opts [lindex $args 0] + set nopts {} + set skip "" + foreach opt [split $opts " "] { + if { $opt == "" } then { + continue + } elseif { $skip != "" } then { + set skip "" + } elseif { $opt == "-Xlinker" } then { + set skip $opt + } elseif { ![string match "-*" $opt] \ + && [file isfile $opt] } { + set opt "-Wl,$opt" + } + lappend nopts $opt + } + return $nopts +} + +# Add -Wl, before any file names in the target board's ldflags, libs, +# and ldscript, as well as in global testglue and wrap_flags, so that +# default object files or libraries do not change the names of gcc +# auxiliary outputs. proc gcc_adjust_linker_flags {} { global gcc_adjusted_linker_flags @@ -303,27 +326,23 @@ proc gcc_adjust_linker_flags {} { foreach i { ldflags libs ldscript } { if {[board_info $dest exists $i]} { set opts [board_info $dest $i] - set nopts {} - set skip "" - foreach opt [split $opts] { - if { $opt == "" } then { - continue - } elseif { $skip != "" } then { - set skip "" - } elseif { $opt == "-Xlinker" } then { - set skip $opt - } elseif { ![string match "-*" $opt] \ - && [file isfile $opt] } { - set opt "-Wl,$opt" - } - lappend nopts $opt - } + set nopts [gcc_adjust_linker_flags_list $opts] if { $nopts != $opts } { unset_currtarget_info $i set_currtarget_info $i "$nopts" } } } + foreach i { gluefile wrap_flags } { + global $i + if {[info exists $i]} { + set opts [set $i] + set nopts [gcc_adjust_linker_flags_list $opts] + if { $nopts != $opts } { + set $i $nopts + } + } + } } }