public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Delete temporary response file
@ 2015-06-22 17:48 Eric Botcazou
  2015-06-23 15:35 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2015-06-22 17:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: Tristan Gingold

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

Hi,

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
-L/usr/lib64
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*
ccVSQ6W5

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  <gingold@adacore.com>

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


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1000 bytes --]

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;
-    }
 }
 
 \f
@@ -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);
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Delete temporary response file
  2015-06-22 17:48 [patch] Delete temporary response file Eric Botcazou
@ 2015-06-23 15:35 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2015-06-23 15:35 UTC (permalink / raw)
  To: Eric Botcazou, gcc-patches; +Cc: Tristan Gingold

On 06/22/2015 11:37 AM, Eric Botcazou wrote:
> Hi,
>
> 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
> -L/usr/lib64
> 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*
> ccVSQ6W5
>
> 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  <gingold@adacore.com>
>
> 	* collect2.c (collect_wait): Unlink the response file here instead of...
> 	(do_wait): ...here.
> 	(utils_cleanup): ...and here.
OK.
jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-23 15:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-22 17:48 [patch] Delete temporary response file Eric Botcazou
2015-06-23 15:35 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).