Patchwork Do not redirect ld stdout/stderr in collect2 with -debug

login
register
mail settings
Submitter Richard Guenther
Date June 10, 2013, 12:01 p.m.
Message ID <alpine.LNX.2.00.1306101358420.26078@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/250227/
State New
Headers show

Comments

Richard Guenther - June 10, 2013, 12:01 p.m.
This fixes one very annoying thing collect2 does when trying to
debug LTO WPA issues.  Even with -v you need to wait until all
LTRANS stages completed to see the lto1 -fwpa invocation which
is because collect2 buffers and replays stdout/stderr of ld
(to avoid duplicating that in some cases).  But I really want
to see the output immediately but there is no way to do that.
The easiest is to disable the buffering with -debug (that is,
-Wl,-debug to the -flto driver command line).

Tested with/without -debug.

Ok for trunk?

Thanks,
Richard.

2013-06-10  Richard Biener  <rguenther@suse.de>

	* collect2.c (main): Do not redirect ld stdout/stderr when
	debugging.
Joseph S. Myers - June 10, 2013, 2:44 p.m.
On Mon, 10 Jun 2013, Richard Biener wrote:

> This fixes one very annoying thing collect2 does when trying to
> debug LTO WPA issues.  Even with -v you need to wait until all
> LTRANS stages completed to see the lto1 -fwpa invocation which
> is because collect2 buffers and replays stdout/stderr of ld
> (to avoid duplicating that in some cases).  But I really want
> to see the output immediately but there is no way to do that.
> The easiest is to disable the buffering with -debug (that is,
> -Wl,-debug to the -flto driver command line).
> 
> Tested with/without -debug.
> 
> Ok for trunk?

OK.

Patch

Index: gcc/collect2.c
===================================================================
--- gcc/collect2.c	(revision 199732)
+++ gcc/collect2.c	(working copy)
@@ -1189,8 +1189,11 @@  main (int argc, char **argv)
 #ifdef COLLECT_EXPORT_LIST
   export_file = make_temp_file (".x");
 #endif
-  ldout = make_temp_file (".ld");
-  lderrout = make_temp_file (".le");
+  if (!debug)
+    {
+      ldout = make_temp_file (".ld");
+      lderrout = make_temp_file (".le");
+    }
   *c_ptr++ = c_file_name;
   *c_ptr++ = "-x";
   *c_ptr++ = "c";