This is the mail archive of the 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]

[patch] Delete temporary response file


when you pass a response file at link time and you use the GNU linker, then 
collect2 creates another, temporary response file and passes it to the linker.
But it fails to delete the file after it is done.  This can easily be seen 
with the following manipulation:

eric@polaris:~/build/gcc/native> cat t.c
int main (void) { return 0; }
eric@polaris:~/build/gcc/native> cat t.resp
eric@polaris:~/build/gcc/native> gcc -c t.c
eric@polaris:~/build/gcc/native> export TMPDIR=$PWD
eric@polaris:~/build/gcc/native> gcc -o t t.o @t.resp
eric@polaris:~/build/gcc/native> ls cc*

The problem is that do_wait is not invoked by tlink_execute, only collect_wait 
is, so the cleanup code present therein is never invoked.

Tested on x86_64-suse-linux, OK for the mainline?

2015-06-22  Tristan Gingold  <>

	* collect2.c (collect_wait): Unlink the response file here instead of...
	(utils_cleanup): ...and here.

Eric Botcazou
Index: collect-utils.c
--- collect-utils.c	(revision 224708)
+++ collect-utils.c	(working copy)
@@ -68,6 +68,12 @@ collect_wait (const char *prog, struct p
     fatal_error (input_location, "can't get program status: %m");
   pex_free (pex);
+  if (response_file && !save_temps)
+    {
+      unlink (response_file);
+      response_file = NULL;
+    }
   if (status)
       if (WIFSIGNALED (status))
@@ -90,12 +96,6 @@ do_wait (const char *prog, struct pex_ob
   int ret = collect_wait (prog, pex);
   if (ret != 0)
     fatal_error (input_location, "%s returned %d exit status", prog, ret);
-  if (response_file && !save_temps)
-    {
-      unlink (response_file);
-      response_file = NULL;
-    }
@@ -224,7 +224,5 @@ utils_cleanup (bool from_signal)
      calls to maybe_unlink fails. */
   cleanup_done = true;
-  if (response_file)
-    maybe_unlink (response_file);
   tool_cleanup (from_signal);

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