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  <rguent...@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.

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;

Reply via email to