From 5fa1767aa45e1a927e832ccc09e959d4c8a9548c Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 24 Jul 2020 15:38:35 -0300 Subject: [PATCH] [PR95720] protect gluefile and wrap_flags with -Wl too 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. 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 + } + } + } } } -- 2.7.4