2009-11-24 Rafael Avila de Espindola <espindola@google.com>
authorespindola <espindola@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Nov 2009 15:00:15 +0000 (15:00 +0000)
committerespindola <espindola@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Nov 2009 15:00:15 +0000 (15:00 +0000)
       * lto-wrapper.c (lto_wrapper_exit): Don't try to delete files if
       being called recursively.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154500 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/lto-wrapper.c

index 7ed7aad..169f5ee 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-24  Rafael Avila de Espindola  <espindola@google.com>
+
+       * lto-wrapper.c (lto_wrapper_exit): Don't try to delete files if
+       being called recursively.
+
 2009-11-24  Basile Starynkevitch  <basile@starynkevitch.net>
 
         * Makefile.in (PLUGIN_HEADERS): Added files: cppdefault.h flags.h
index cddd415..5f24f59 100644 (file)
@@ -66,12 +66,20 @@ static void maybe_unlink_file (const char *);
 static void
 lto_wrapper_exit (int status)
 {
-  if (ltrans_output_file)
-    maybe_unlink_file (ltrans_output_file);
-  if (flto_out)
-    maybe_unlink_file (flto_out);
-  if (args_name)
-    maybe_unlink_file (args_name);
+  static bool cleanup_done = false;
+  if (!cleanup_done)
+    {
+      /* Setting cleanup_done prevents an infinite loop if one of the
+         calls to maybe_unlink_file fails. */
+      cleanup_done = true;
+
+      if (ltrans_output_file)
+        maybe_unlink_file (ltrans_output_file);
+      if (flto_out)
+        maybe_unlink_file (flto_out);
+      if (args_name)
+        maybe_unlink_file (args_name);
+    }
   exit (status);
 }