This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[LTO][PATCH] Delete temporary ltrans output files


Add code to delete temporary /tmp/cc*.ltrans.out files when no longer needed.


gcc/ChangeLog.lto
2008-12-09  Simon Baldwin  <simonb@google.com>

	* lto-wrapper.c (maybe_unlink_file): New.
	* (run_gcc): Call maybe_unlink_file() for ltrans_output_file.


Index: gcc/lto-wrapper.c
===================================================================
--- gcc/lto-wrapper.c	(revision 142591)
+++ gcc/lto-wrapper.c	(working copy)
@@ -173,6 +173,20 @@ fork_execute (char **argv)
   collect_wait (argv[0], pex);
 }
 
+/* Unlink a temporary LTRANS file unless requested otherwise.  */
+
+static void
+maybe_unlink_file (const char *file)
+{
+  if (!getenv ("WPA_SAVE_LTRANS"))
+    {
+      if (unlink_if_ordinary (file))
+	fatal_perror ("deleting LTRANS file %s", file);
+    }
+  else
+    fprintf (stderr, "[Leaving LTRANS %s]\n", file);
+}
+
 /* Execute gcc. ARGC is the number of arguments. ARGV contains the arguments. */
 
 static void
@@ -275,6 +289,7 @@ run_gcc (unsigned argc, char *argv[])
       while ((c = getc (stream)) != EOF)
 	putc (c, stdout);
       fclose (stream);
+      maybe_unlink_file (ltrans_output_file);
       free (ltrans_output_file);
       free (list_option_full);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]