diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7ed7aad5004..169f5ee65d9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-11-24 Rafael Avila de Espindola + + * lto-wrapper.c (lto_wrapper_exit): Don't try to delete files if + being called recursively. + 2009-11-24 Basile Starynkevitch * Makefile.in (PLUGIN_HEADERS): Added files: cppdefault.h flags.h diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index cddd4156a35..5f24f59564d 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -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); }