public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <oliva@adacore.com>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, ebotcazou@adacore.com, joseph@codesourcery.com
Subject: Re: drop -aux{dir,base}, revamp -dump{dir,base}
Date: Tue, 19 May 2020 06:00:50 -0300	[thread overview]
Message-ID: <orh7wcuwn1.fsf@livre.home> (raw)
In-Reply-To: <ortv0cux2c.fsf@livre.home> (Alexandre Oliva's message of "Tue, 19 May 2020 05:51:39 -0300")

On May 19, 2020, Alexandre Oliva <oliva@adacore.com> wrote:

> - fix for outputs.exp for platforms with nonempty ldflags, libs,
>   ldscripts, or output_format in the dejagnu board configuration, and
>   for link tests with aux dumps in the testsuite when ldflags, libs or
>   ldscripts in the board config name files that gcc would regard as
>   additional inputs.

protect filenames in linker flags with -Wl,

From: Alexandre Oliva <oliva@adacore.com>

outputs.exp is not suited for remote compilation, so disable it if
host is remote.  Make it so that any extra data that complements fail
messages goes in a separate line, instead of appearing to be part of
the test name.

ldflags, libs, ldscripts and output_format flags that would normally
be passed to the compiler driver when linking would not be passed in
our special arrangement that bypasses the dejagnu requirement of
naming an output file when creating an executable.  With this patch we
collect them into a variable and add them to the options when running
linking tests.

Another issue with linking tests is that any object or library names
in these board configuration knobs would be taken by the compiler
driver as another input, changing the name of auxiliary outputs such
as those that -save-temps creates.  Tests that look for the auxiliary
outputs for single-inputs would not find them, and end up UNSUPPORTED.
This is fixed by prependig "-Wl," to any filename that appears in
ldflags, libs or ldscripts.


for  gcc/testsuite/ChangeLog

	* gcc.misc-tests/outputs.exp: Skip if host is remote.
	(link_options): New.  Compute once, use in all link tests.
	(outest): Move extra notes for fails to separate line.
	* lib/gcc-defs.exp (gcc_adjusted_linker_flags): New.
	(gcc_adjust_linker_flags): New.
	(dg-additional-files-options): Call it.
---
 gcc/testsuite/gcc.misc-tests/outputs.exp |   36 +++++++++++++++++++++++---
 gcc/testsuite/lib/gcc-defs.exp           |   42 ++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.misc-tests/outputs.exp b/gcc/testsuite/gcc.misc-tests/outputs.exp
index 6cb2c64..889db17 100644
--- a/gcc/testsuite/gcc.misc-tests/outputs.exp
+++ b/gcc/testsuite/gcc.misc-tests/outputs.exp
@@ -31,7 +31,7 @@ set b "outputs"
 # doesn't return the same values, so disable parallelization
 # of this *.exp file.  The first parallel runtest to reach
 # this will run all the tests serially.
-if ![gcc_parallel_test_run_p $b] {
+if {![gcc_parallel_test_run_p $b] || [is_remote host]} {
     return
 }
 gcc_parallel_test_enable 0
@@ -43,6 +43,29 @@ if ![check_no_compiler_messages gsplitdwarf object {
     set gsplit_dwarf ""
 }
 
+# Prepare additional options to be used for linking.
+# We do not compile to an executable, because that requires naming an output.
+set link_options ""
+set dest [target_info name]
+foreach i { ldflags libs ldscripts } {
+    if {[board_info $dest exists $i]} {
+	set skip ""
+	foreach opt [split [board_info $dest $i]] {
+	    if { $skip != "" } then {
+		set skip ""
+	    } elseif { $opt == "-Xlinker" } then {
+		set skip $opt
+	    } elseif { ![string match "-*" $opt] && [file isfile $opt] } {
+	    	set opt "-Wl,$opt"
+	    }
+	    append link_options " additional_flags=$opt"
+	}
+    }
+}
+if {[board_info $dest exists output_format]} {
+    append link_options " additional_flags=-Wl,-oformat,[board_info $dest output_format]"
+}
+
 # For the test named TEST, run the compiler with SOURCES and OPTS, and
 # look in DIRS for OUTPUTS.  SOURCES is a list of suffixes for source
 # files starting with $b in $srcdir/$subdir, OPTS is a string with
@@ -79,7 +102,12 @@ proc outest { test sources opts dirs outputs } {
     }
     set options ""
     foreach opt [split $opts " "] {
-	set options "$options additional_flags=$opt"
+	append options " additional_flags=$opt"
+    }
+    # Add linker flags if we're linking
+    if {![string match "* -\[ESc\] *" " $opts "]} {
+	global link_options
+	append options "$link_options"
     }
     set gcc_output [gcc_target_compile $src "" none "$options"]
     set outs {}
@@ -136,13 +164,13 @@ proc outest { test sources opts dirs outputs } {
     if { [llength $outs] == 0 } then {
 	pass "$test: extra"
     } else {
-	fail "$test: extra $outs"
+	fail "$test: extra\n$outs"
     }
 
     if { [string equal "$gcc_output" ""] } then {
 	pass "$test: std out"
     } else {
-	fail "$test: std out $gcc_output"
+	fail "$test: std out\n$gcc_output"
     }
 
 }
diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp
index 4abb2b3..fc7e8e2 100644
--- a/gcc/testsuite/lib/gcc-defs.exp
+++ b/gcc/testsuite/lib/gcc-defs.exp
@@ -285,11 +285,53 @@ proc dg-additional-files { args } {
     set additional_files [lindex $args 1]
 }
 
+set gcc_adjusted_linker_flags 0
+
+# Add -Wl, before any file names in ldflags, libs, and ldscripts, 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
+    if {$gcc_adjusted_linker_flags} {
+	return
+    }
+    set gcc_adjusted_linker_flags 1
+
+    if {![is_remote host]} {
+	set dest [target_info name]
+	foreach i { ldflags libs ldscripts } {
+	    if {[board_info $dest exists $i]} {
+		set opts [board_info $dest $i]
+		set nopts {}
+		set skip ""
+		foreach opt [split $opts] {
+		    if { $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
+		}
+		if { $nopts != $opts } {
+		    unset_currtarget_info $i
+		    set_currtarget_info $i "$nopts"
+		}
+	    }
+	}
+    }
+}
+
 # Return an updated version of OPTIONS that mentions any additional
 # source files registered with dg-additional-sources.  SOURCE is the
 # name of the test case.
 
 proc dg-additional-files-options { options source } {
+    gcc_adjust_linker_flags
+
     global additional_sources
     global additional_sources_used
     global additional_files


-- 
Alexandre Oliva, freedom fighter    he/him    https://FSFLA.org/blogs/lxo/
Free Software Evangelist              Stallman was right, but he's left :(
GNU Toolchain Engineer           Live long and free, and prosper ethically

  parent reply	other threads:[~2020-05-19  9:01 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26  5:30 introduce -fcallgraph-info option Alexandre Oliva
2019-10-26  8:12 ` Richard Biener
2019-10-26 11:21   ` Alexandre Oliva
2019-10-27  9:08     ` Alexandre Oliva
2019-10-28  8:38       ` Richard Biener
2019-10-30 10:12         ` Alexandre Oliva
2019-10-30 11:28           ` Richard Biener
2019-11-02 19:31             ` Alexandre Oliva
2019-11-04  8:28               ` Richard Biener
2019-11-06 10:53                 ` Alexandre Oliva
2019-11-20  4:35                   ` Alexandre Oliva
2019-11-20  9:16                     ` Richard Biener
2019-11-06 15:38                 ` Alexandre Oliva
2019-11-07  7:49                   ` Richard Biener
2019-11-07 10:50                     ` Alexandre Oliva
2019-11-07 11:48                       ` Richard Biener
2019-11-07 12:30                         ` Alexandre Oliva
2019-11-07 14:02                           ` Richard Biener
2019-11-07 22:39                             ` Alexandre Oliva
2019-11-08  8:28                               ` Richard Biener
2019-11-08 23:12                                 ` Eric Gallager
2019-11-15  1:34                                   ` Alexandre Oliva
2019-11-15  1:01                                 ` Alexandre Oliva
2019-11-15  7:30                                   ` Alexandre Oliva
2019-11-15  8:08                                     ` Richard Biener
2019-11-15 22:50                                       ` Alexandre Oliva
2019-12-03 22:44                                   ` Alexandre Oliva
2019-12-09  9:41                                     ` Richard Biener
2019-12-12  1:14                                       ` Alexandre Oliva
2019-12-25 10:05                               ` Alexandre Oliva
2019-12-26 19:00                                 ` drop -aux{dir,base}, revamp -dump{dir,base} (was: Re: introduce -fcallgraph-info option) Alexandre Oliva
2020-01-09 13:33                                   ` Richard Biener
2020-01-09 19:09                                     ` drop -aux{dir,base}, revamp -dump{dir,base} Alexandre Oliva
2020-01-16 11:06                                       ` Alexandre Oliva
2020-01-16 11:15                                         ` Alexandre Oliva
2020-01-17  2:14                                           ` Joseph Myers
2020-01-20 10:38                                         ` Richard Biener
2020-01-22  1:25                                           ` Alexandre Oliva
2020-01-22  8:15                                             ` Richard Biener
2020-01-23 20:06                                               ` Alexandre Oliva
2020-01-24  1:50                                               ` Alexandre Oliva
2020-05-19  8:51                                                 ` Alexandre Oliva
2020-05-19  8:59                                                   ` Alexandre Oliva
2020-05-19  9:29                                                     ` Richard Biener
2020-05-19  8:59                                                   ` Alexandre Oliva
2020-05-19  9:30                                                     ` Richard Biener
2020-05-19  9:00                                                   ` Alexandre Oliva [this message]
2020-05-19  9:04                                                   ` Richard Biener
2020-05-22  0:32                                                     ` Alexandre Oliva
2020-05-22  6:05                                                       ` Richard Biener
2020-05-26  7:08                                                         ` Alexandre Oliva
2020-05-26  8:52                                                           ` Richard Biener
2020-05-26  9:02                                                             ` Martin Liška
2020-05-26 10:00                                                             ` Alexandre Oliva
2020-05-26 12:14                                                             ` Alexandre Oliva
2020-05-26 13:52                                                             ` Alexandre Oliva
2020-05-26 13:56                                                               ` Richard Biener
2020-05-27 22:05                                                                 ` Alexandre Oliva
2020-05-27 23:01                                                                   ` Jeff Law
2020-06-02 11:52                                                                   ` Alexandre Oliva
2020-06-02 12:02                                                                     ` Richard Biener
2020-05-27  1:04                                                               ` Broken build (was: Re: drop -aux{dir,base}, revamp -dump{dir,base}) Hans-Peter Nilsson
2020-05-27 14:30                                                                 ` Broken build Alexandre Oliva
2020-05-27 15:04                                                                   ` Hans-Peter Nilsson
2020-05-28  0:53                                                                     ` Alexandre Oliva
2020-05-28  0:39                                                                 ` Anthony Green
2020-06-02 11:29                                                                   ` Alexandre Oliva
2020-06-02 14:07                                                                     ` Hans-Peter Nilsson
2020-05-27  9:45                                                           ` drop -aux{dir,base}, revamp -dump{dir,base} Andreas Schwab
2020-05-27 10:28                                                             ` Andreas Schwab
2020-05-27 14:41                                                               ` Alexandre Oliva
2020-05-27 14:59                                                                 ` Andreas Schwab
2020-06-09 12:29                                                           ` Thomas Schwinge
2020-06-09 12:42                                                             ` BRIG FE testsuite: Fix all dump-scans (Was: Re: drop -aux{dir, base}, revamp -dump{dir, base}) Martin Jambor
2020-06-09 18:31                                                               ` BRIG FE testsuite: Fix all dump-scans (Was: Re: drop -aux{dir,base}, revamp -dump{dir,base}) Mike Stump
2020-06-11 14:28                                                                 ` BRIG FE testsuite: Fix all dump-scans (Was: Re: drop -aux{dir, base}, revamp -dump{dir, base}) Martin Jambor
2020-06-12 20:52                                                                   ` BRIG FE testsuite: Fix all dump-scans (Was: Re: drop -aux{dir,base}, revamp -dump{dir,base}) Mike Stump
2020-06-10 21:50                                                               ` BRIG FE testsuite: Fix all dump-scans Alexandre Oliva
2020-06-23  9:44                                                             ` drop -aux{dir,base}, revamp -dump{dir,base} Alexandre Oliva
2020-06-23 11:30                                                               ` Martin Jambor
2020-06-09 13:08                                                           ` Thomas Schwinge
2020-06-10 22:24                                                             ` Alexandre Oliva
2020-06-17 10:50                                                               ` Tobias Burnus
2020-06-18  2:58                                                                 ` Alexandre Oliva
2020-06-18  6:10                                                             ` Alexandre Oliva
2020-06-18  9:41                                                               ` Tobias Burnus
2020-06-18 10:39                                                                 ` Alexandre Oliva
2020-06-18 12:06                                                                   ` Tobias Burnus
2020-06-30 16:13                                                                     ` Thomas Schwinge
2020-07-14  5:46                                                                       ` Alexandre Oliva
2020-07-24  6:08                                                                         ` Thomas Schwinge
2020-07-24 17:54                                                                           ` Alexandre Oliva
2020-07-14  5:49                                                                       ` Alexandre Oliva
2020-06-19  9:53                                                                 ` Alexandre Oliva
2020-06-19 16:09                                                                   ` Tobias Burnus
2020-06-22  6:08                                                                     ` Alexandre Oliva
2020-06-22  7:07                                                                       ` Tobias Burnus
2020-06-22 14:32                                                                         ` Alexandre Oliva
2020-06-23  8:17                                                                           ` Richard Biener
2020-06-30 16:35                                                                           ` Thomas Schwinge
2020-07-24 12:06                                                                             ` Thomas Schwinge
2020-06-30 18:52                                                                           ` Thomas Schwinge
2020-07-14  4:48                                                                             ` Alexandre Oliva
2020-07-24  6:01                                                                               ` Thomas Schwinge
2020-07-24 18:00                                                                                 ` Alexandre Oliva
2023-11-24 12:46                                                                           ` testsuite: Add 'only_for_offload_target' wrapper for 'scan-offload-tree-dump' etc. (was: drop -aux{dir,base}, revamp -dump{dir,base}) Thomas Schwinge
2020-06-23  9:50                                                             ` drop -aux{dir,base}, revamp -dump{dir,base} Alexandre Oliva
2020-06-30 16:07                                                               ` Thomas Schwinge
2020-07-23 21:12                                                               ` [PR95720] protect gluefile and wrap_flags with -Wl too (was: Re: drop -aux{dir,base}, revamp -dump{dir,base}) Alexandre Oliva
2020-07-24  6:48                                                                 ` Richard Biener
2020-05-26  8:09                                                       ` [wwwdocs] Re: drop -aux{dir,base}, revamp -dump{dir,base} Alexandre Oliva
2019-10-28 23:56 ` introduce -fcallgraph-info option Joseph Myers
2019-10-30  9:22   ` Alexandre Oliva
2019-10-30  9:43   ` Alexandre Oliva
2019-10-30 18:17     ` Joseph Myers
2019-11-06 21:27 ` Thomas Schwinge
2019-11-07 11:23   ` Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=orh7wcuwn1.fsf@livre.home \
    --to=oliva@adacore.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).