diff mbox

Reduce temporary disk-space usage by LTO ltrans phase

Message ID alpine.LNX.2.00.1112151314200.4527@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Dec. 15, 2011, 12:17 p.m. UTC
The following patch removes ltrans inputs as soon as they have been
processed by the ltrans phase.  In parallel mode, which is controlled
by make, this is done by truncating the input file, preserving its
timestamp.  Thus the patch should at most reduce the peak disk-space
needs by a factor of two (likely a lot less as the ltrans inputs
themselves are a lot bigger than the final object files).

I'll throw this at a LTO bootstrap and plan to commit it afterwards
if there are no complaints (this work was triggered by LTO bootstrap
failing for me because out-of-diskspace in /tmp during LTRANS).

Thanks,
Richard.

2011-12-15  Richard Guenther  <rguenther@suse.de>

	* lto-wrapper.c (run_gcc): In non-parallel mode remove
	ltrans inputs immediately after processing them.  In parallel
	mode truncate the ltrans inputs in the make rule that processes
	them if temporary files are not to be preserved.

Comments

Andrew Pinski Dec. 15, 2011, 8:44 p.m. UTC | #1
On Thu, Dec 15, 2011 at 4:17 AM, Richard Guenther <rguenther@suse.de> wrote:
> +               fprintf (mstream, "\t@-touch -r %s %s.tem && mv %s.tem %s\n",
> +                        input_name, input_name, input_name, input_name);

Is touch -r portable?

Thanks,
Andrew Pinski
Richard Biener Dec. 16, 2011, 8:39 a.m. UTC | #2
On Thu, 15 Dec 2011, Andrew Pinski wrote:

> On Thu, Dec 15, 2011 at 4:17 AM, Richard Guenther <rguenther@suse.de> wrote:
> > +               fprintf (mstream, "\t@-touch -r %s %s.tem && mv %s.tem %s\n",
> > +                        input_name, input_name, input_name, input_name);
> 
> Is touch -r portable?

Should not matter because '-' will prevent errors and errors go to
/dev/null in the patch I committed.  [in the end currently the
rules do not have any inputs, so changing time stamps of the ltrans
inputs shouldn't be an issue]

Richard.
diff mbox

Patch

Index: gcc/lto-wrapper.c
===================================================================
--- gcc/lto-wrapper.c	(revision 182360)
+++ gcc/lto-wrapper.c	(working copy)
@@ -811,9 +811,18 @@  cont:
 	      for (j = 1; new_argv[j] != NULL; ++j)
 		fprintf (mstream, " '%s'", new_argv[j]);
 	      fprintf (mstream, "\n");
+	      /* If we are not preserving the ltrans input files then
+	         truncate them as soon as we have processed it.  This
+		 reduces temporary disk-space usage.  */
+	      if (! debug)
+		fprintf (mstream, "\t@-touch -r %s %s.tem && mv %s.tem %s\n",
+			 input_name, input_name, input_name, input_name); 
 	    }
 	  else
-	    fork_execute (CONST_CAST (char **, new_argv));
+	    {
+	      fork_execute (CONST_CAST (char **, new_argv));
+	      maybe_unlink_file (input_name);
+	    }
 
 	  output_names[i] = output_name;
 	}
@@ -851,12 +860,13 @@  cont:
 	  collect_wait (new_argv[0], pex);
 	  maybe_unlink_file (makefile);
 	  makefile = NULL;
+	  for (i = 0; i < nr; ++i)
+	    maybe_unlink_file (input_names[i]);
 	}
       for (i = 0; i < nr; ++i)
 	{
 	  fputs (output_names[i], stdout);
 	  putc ('\n', stdout);
-	  maybe_unlink_file (input_names[i]);
 	  free (input_names[i]);
 	}
       nr = 0;