diff mbox

make -flto -save-temps less verbose

Message ID 532255F7.1070701@codesourcery.com
State New
Headers show

Commit Message

Cesar Philippidis March 14, 2014, 1:05 a.m. UTC
On 3/13/14, 2:52 AM, Richard Biener wrote:
> On Thu, Mar 13, 2014 at 10:31 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Thu, Mar 13, 2014 at 1:10 AM, Cesar Philippidis
>> <cesar@codesourcery.com> wrote:
>>> I noticed that the lto-wrapper is a little noisy without the -v option
>>> when -save-temps is used. E.g.,
>>>
>>> $ gcc main.c -flto -save-temps
>>> [Leaving LTRANS /tmp/ccSEvaB7.args]
>>> [Leaving LTRANS /tmp/ccQomDzb.ltrans.out]
>>> [Leaving LTRANS /tmp/ccVzWdGZ.args]
>>> [Leaving LTRANS /tmp/ccQomDzb.ltrans0.o]
>>>
>>> Those messages probably should be suppressed unless the user wants
>>> verbose diagnostics. They also show up as errors in the testsuite
>>> (although none currently use -save-temps with -flto, yet). The attached
>>> patch addresses this issue by disabling those messages unless the user
>>> passes -v to the driver. I've also included a simple test case which
>>> would fail without the change.
>>>
>>> Is this OK for stage-4? If so, please check it in since I don't have an
>>> SVN account.
>>
>> Ok (I'll check it in).
> 
> I have not committed the testcase as it leaves the saved-temps files
> behind and
> 
> /* { dg-final { cleanup-saved-temps } } */
> 
> doesn't work.  May I ask you to see why and eventually fix it?
> Supposedly some weird TCL "upvar" stuff ... I get (after my lto.exp fix)
> 
> Running /space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/lto/lto.exp ...
> ERROR: /space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/lto/save-temps_0.c:
> error executing dg-final: bad level "5"
> 
> not sure how to set verboseness or debug that stuff (and no time to
> do that right now).

That error was caused by cleanup-saved-temps because it wants to use
testname_with_flags to get the names of the files to remove. Usually
dg-test would set testname_with_flags, but since the LTO tests usually
links multiple object files, lto.exp handles the building and execution
of the testcases directly and that variable doesn't get set.

My fix to have lto-execute cleanup the files generated by -save-temps
instead of calling cleanup-saved-temps in the testcase. That's necessary
because the name of the final LTO executable is different from name of
the testcase file. I've also extended cleanup-saved-temps to make it
aware of the LTO temporaries. Calling cleanup-saved-temps from dg-final
will still work if the test uses dg-test to run, just not for the tests
in gcc.dg/lto/.

Is this OK?

Thanks,
Cesar
2014-03-13  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/testsuite/
	* gcc.dg/lto/save-temps_0.c: New file.
	* lib/gcc-dg.exp (cleanup-saved-temps): Handle LTO temporaries.
	* lib/lto.exp (lto-execute): Cleanup LTO temporaries.

Comments

Richard Biener March 14, 2014, 9:32 a.m. UTC | #1
On Thu, 13 Mar 2014, Cesar Philippidis wrote:

> On 3/13/14, 2:52 AM, Richard Biener wrote:
> > On Thu, Mar 13, 2014 at 10:31 AM, Richard Biener
> > <richard.guenther@gmail.com> wrote:
> >> On Thu, Mar 13, 2014 at 1:10 AM, Cesar Philippidis
> >> <cesar@codesourcery.com> wrote:
> >>> I noticed that the lto-wrapper is a little noisy without the -v option
> >>> when -save-temps is used. E.g.,
> >>>
> >>> $ gcc main.c -flto -save-temps
> >>> [Leaving LTRANS /tmp/ccSEvaB7.args]
> >>> [Leaving LTRANS /tmp/ccQomDzb.ltrans.out]
> >>> [Leaving LTRANS /tmp/ccVzWdGZ.args]
> >>> [Leaving LTRANS /tmp/ccQomDzb.ltrans0.o]
> >>>
> >>> Those messages probably should be suppressed unless the user wants
> >>> verbose diagnostics. They also show up as errors in the testsuite
> >>> (although none currently use -save-temps with -flto, yet). The attached
> >>> patch addresses this issue by disabling those messages unless the user
> >>> passes -v to the driver. I've also included a simple test case which
> >>> would fail without the change.
> >>>
> >>> Is this OK for stage-4? If so, please check it in since I don't have an
> >>> SVN account.
> >>
> >> Ok (I'll check it in).
> > 
> > I have not committed the testcase as it leaves the saved-temps files
> > behind and
> > 
> > /* { dg-final { cleanup-saved-temps } } */
> > 
> > doesn't work.  May I ask you to see why and eventually fix it?
> > Supposedly some weird TCL "upvar" stuff ... I get (after my lto.exp fix)
> > 
> > Running /space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/lto/lto.exp ...
> > ERROR: /space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/lto/save-temps_0.c:
> > error executing dg-final: bad level "5"
> > 
> > not sure how to set verboseness or debug that stuff (and no time to
> > do that right now).
> 
> That error was caused by cleanup-saved-temps because it wants to use
> testname_with_flags to get the names of the files to remove. Usually
> dg-test would set testname_with_flags, but since the LTO tests usually
> links multiple object files, lto.exp handles the building and execution
> of the testcases directly and that variable doesn't get set.
> 
> My fix to have lto-execute cleanup the files generated by -save-temps
> instead of calling cleanup-saved-temps in the testcase. That's necessary
> because the name of the final LTO executable is different from name of
> the testcase file. I've also extended cleanup-saved-temps to make it
> aware of the LTO temporaries. Calling cleanup-saved-temps from dg-final
> will still work if the test uses dg-test to run, just not for the tests
> in gcc.dg/lto/.
> 
> Is this OK?

Yes, that works for me.  I have committed it.

Thanks,
Richard.
diff mbox

Patch

Index: gcc/testsuite/gcc.dg/lto/save-temps_0.c
===================================================================
--- gcc/testsuite/gcc.dg/lto/save-temps_0.c	(revision 0)
+++ gcc/testsuite/gcc.dg/lto/save-temps_0.c	(revision 0)
@@ -0,0 +1,8 @@ 
+/* { dg-lto-options {{ -O -flto -save-temps}} } */
+/* { dg-lto-do link } */
+
+int
+main (void)
+{
+  return 0;
+}
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp	(revision 208541)
+++ gcc/testsuite/lib/gcc-dg.exp	(working copy)
@@ -600,7 +600,7 @@  proc cleanup-saved-temps { args } {
     set suffixes {}
 
     # add the to-be-kept suffixes
-    foreach suffix {".mii" ".ii" ".i" ".s" ".o" ".gkd"} {
+    foreach suffix {".mii" ".ii" ".i" ".s" ".o" ".gkd" ".res" ".ltrans.out"} {
 	if {[lsearch $args $suffix] < 0} {
 	    lappend suffixes $suffix
 	}
@@ -611,6 +611,8 @@  proc cleanup-saved-temps { args } {
     set testcase [lindex $testcase 0]
     foreach suffix $suffixes {
 	remove-build-file "[file rootname [file tail $testcase]]$suffix"
+	remove-build-file "[file rootname [file tail $testcase]].exe$suffix"
+	remove-build-file "[file rootname [file tail $testcase]].exe.ltrans\[0-9\]*$suffix"
 	# -fcompare-debug dumps
 	remove-build-file "[file rootname [file tail $testcase]].gk$suffix"
     }
@@ -620,6 +622,9 @@  proc cleanup-saved-temps { args } {
 	foreach srcfile $additional_sources {
 	    foreach suffix $suffixes {
 		remove-build-file "[file rootname [file tail $srcfile]]$suffix"
+		remove-build-file "[file rootname [file tail $srcfile]].exe$suffix"
+		remove-build-file "[file rootname [file tail $srcfile]].exe.ltrans\[0-9\]*$suffix"
+
 		# -fcompare-debug dumps
 		remove-build-file "[file rootname [file tail $srcfile]].gk$suffix"
 	    }
Index: gcc/testsuite/lib/lto.exp
===================================================================
--- gcc/testsuite/lib/lto.exp	(revision 208541)
+++ gcc/testsuite/lib/lto.exp	(working copy)
@@ -413,7 +413,8 @@  proc lto-execute { src1 sid } {
     global dg-suppress-ld-options
     global LTO_OPTIONS
     global dg-final-code
-
+    global testname_with_flags
+    
     # Get extra flags for this test from the primary source file, and
     # process other dg-* options that this suite supports.  Warn about
     # unsupported flags.
@@ -577,6 +578,22 @@  proc lto-execute { src1 sid } {
 	    }
 	}
 
+	# Clean up after -save-temps.  The LTO tests don't use dg-test, so
+	# testname-for-summary needs to be defined explicitly for each
+	# file that needs to be removed.
+	set testname_with_flags $execname
+
+	eval "cleanup-saved-temps"
+
+	for {set i 0} {$i < $num_srcs} {incr i} {
+	    set testname_with_flags "${base}_${i}"
+	    eval "cleanup-saved-temps"
+	    set testname_with_flags "${sid}_${base}_${i}"
+	    eval "cleanup-saved-temps"
+	}
+	
+	unset testname_with_flags
+	
 	if { ![string compare "run" $compile_type] \
 	     || ![string compare "link" $compile_type] } {
 	    file_on_host delete $execname