On Thu, 23 Jul 2020, Alexandre Oliva wrote:
> 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?
OK.
Ricahrd.
>
> 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
> + }
> + }
> + }
> }
> }
>
>
>
>
--
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)