aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2020-07-24 15:38:35 -0300
committerAlexandre Oliva <oliva@gnu.org>2020-07-24 16:13:37 -0300
commit5fa1767aa45e1a927e832ccc09e959d4c8a9548c (patch)
treeca3d07d8a8c62b692e82c12294fa2ff1a85db468
parentaa7e7eff5ec165dc8463a0e74309801b15d1feda (diff)
downloadgcc-5fa1767aa45e1a927e832ccc09e959d4c8a9548c.zip
gcc-5fa1767aa45e1a927e832ccc09e959d4c8a9548c.tar.gz
gcc-5fa1767aa45e1a927e832ccc09e959d4c8a9548c.tar.bz2
[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.
-rw-r--r--gcc/testsuite/gcc.misc-tests/outputs.exp14
-rw-r--r--gcc/testsuite/lib/gcc-defs.exp55
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
+ }
+ }
+ }
}
}