public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix -save-temp leaking lto files in /tmp
@ 2020-02-20 13:21 Bernd Edlinger
  2020-02-20 13:34 ` Richard Biener
  0 siblings, 1 reply; 9+ messages in thread
From: Bernd Edlinger @ 2020-02-20 13:21 UTC (permalink / raw)
  To: gcc-patches, Richard Biener

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

Hi,

this is the remaining issue that happens when -flto and -save-temps
is used together, it leaks several files in /tmp.

I try to give more background to how these temp files are
created, and in all likelihood the leaking of these
files is wanted, and certainly very helpful for debugging
lto issues, that's for sure.  It is just not helpful
that they need to be looked up in the /tmp folder, even
if you want to debug something with lto.

The short story is...

They are created here:

      if (parallel)
        {
          makefile = make_temp_file (".mk");
          mstream = fopen (makefile, "w");

and here:

      /* Note: we assume argv contains at least one element; this is
         checked above.  */

      response_file = make_temp_file ("");

      f = fopen (response_file, "w");

And in a few other places as well, it depends a bit
if -o is used or not (i.e. linker_output != NULL or not).

and not removed here:


  if (response_file && !save_temps)
    {
      unlink (response_file);
      response_file = NULL;
    }

and here:

          do_wait (new_argv[0], pex);
          maybe_unlink (makefile);
          makefile = NULL;


the code with the response_file is executed both in
lto-wrapper and collect2, but in collect2 only when
if is invoked from lto-wrapper, triggered by the @file
argument list.

Therefore I figured that the best possible
solution is just let lto-wrapper create a temp-file
for those problem cases, and use TMPDIR to have
all make_temp_file that follow use that to folder to
place the those response files and other stuff in
there.


So that is what I split out from the previous patch,
which focused on collect2.


Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-save-temp-leaking-lto-files-in-tmp.patch --]
[-- Type: text/x-patch; name="0001-Fix-save-temp-leaking-lto-files-in-tmp.patch", Size: 1490 bytes --]

From d6dc826c63dc881fe41dbf0c3a461008afdef8b3 Mon Sep 17 00:00:00 2001
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date: Mon, 17 Feb 2020 17:40:07 +0100
Subject: [PATCH] Fix -save-temp leaking lto files in /tmp

When linking with -flto and -save-temps, various
temporary files are created in /tmp.  They would normally
be deleted without -save-temps, but are retained
for debugging purposes, which is good.  So this just
creates a folder named as output-file.lto_tmpdir,
which makes this feature even more useful, as the
temporary files do not linger in the /tmp directoy
but instead are more easy to locate this way.

2020-02-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* lto-wrapper.c (run_gcc): Create an lto tmpdir
	and use it when -save-temps is used.
---
 gcc/lto-wrapper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index fe8f292..fdc9565 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1423,6 +1423,17 @@ run_gcc (unsigned argc, char *argv[])
       fputc ('\n', stderr);
     }
 
+  if (save_temps)
+    {
+      char *tmpdir = concat (linker_output ? linker_output : "a.out",
+			     ".lto_tmpdir", NULL);
+      /* Make directory if necessary, but expect no race here.  */
+      if (access (tmpdir, F_OK) == 0
+	  || mkdir (tmpdir, S_IRWXU | S_IRWXG | S_IRWXO) == 0)
+	setenv ("TMPDIR", tmpdir, 1);
+      free (tmpdir);
+    }
+
   if (linker_output_rel)
     no_partition = true;
 
-- 
1.9.1


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

* Re: [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-02-20 13:21 [PATCH] Fix -save-temp leaking lto files in /tmp Bernd Edlinger
@ 2020-02-20 13:34 ` Richard Biener
  2020-02-20 15:34   ` Bernd Edlinger
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Biener @ 2020-02-20 13:34 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches

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

On Thu, 20 Feb 2020, Bernd Edlinger wrote:

> Hi,
> 
> this is the remaining issue that happens when -flto and -save-temps
> is used together, it leaks several files in /tmp.
> 
> I try to give more background to how these temp files are
> created, and in all likelihood the leaking of these
> files is wanted, and certainly very helpful for debugging
> lto issues, that's for sure.  It is just not helpful
> that they need to be looked up in the /tmp folder, even
> if you want to debug something with lto.
> 
> The short story is...
> 
> They are created here:
> 
>       if (parallel)
>         {
>           makefile = make_temp_file (".mk");
>           mstream = fopen (makefile, "w");
> 
> and here:
> 
>       /* Note: we assume argv contains at least one element; this is
>          checked above.  */
> 
>       response_file = make_temp_file ("");
> 
>       f = fopen (response_file, "w");
> 
> And in a few other places as well, it depends a bit
> if -o is used or not (i.e. linker_output != NULL or not).
> 
> and not removed here:
> 
> 
>   if (response_file && !save_temps)
>     {
>       unlink (response_file);
>       response_file = NULL;
>     }
> 
> and here:
> 
>           do_wait (new_argv[0], pex);
>           maybe_unlink (makefile);
>           makefile = NULL;
> 
> 
> the code with the response_file is executed both in
> lto-wrapper and collect2, but in collect2 only when
> if is invoked from lto-wrapper, triggered by the @file
> argument list.
> 
> Therefore I figured that the best possible
> solution is just let lto-wrapper create a temp-file
> for those problem cases, and use TMPDIR to have
> all make_temp_file that follow use that to folder to
> place the those response files and other stuff in
> there.
> 
> 
> So that is what I split out from the previous patch,
> which focused on collect2.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?

I don't think this is an improvement.  The files still
will be (correctly) retained and now in addition to that
there's temporary directories piling up?

A better improvement would be to selectively decide
which files might not be needed to be preserved and/or
give them names in the build directory in more cases.

Richard.

> 
> Thanks
> Bernd.
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

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

* Re: [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-02-20 13:34 ` Richard Biener
@ 2020-02-20 15:34   ` Bernd Edlinger
  2020-02-20 16:09     ` Tobias Burnus
  2020-02-21  7:35     ` Richard Biener
  0 siblings, 2 replies; 9+ messages in thread
From: Bernd Edlinger @ 2020-02-20 15:34 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On 2/20/20 2:34 PM, Richard Biener wrote:
> On Thu, 20 Feb 2020, Bernd Edlinger wrote:
> 
>> Hi,
>>
>> this is the remaining issue that happens when -flto and -save-temps
>> is used together, it leaks several files in /tmp.
>>
>> I try to give more background to how these temp files are
>> created, and in all likelihood the leaking of these
>> files is wanted, and certainly very helpful for debugging
>> lto issues, that's for sure.  It is just not helpful
>> that they need to be looked up in the /tmp folder, even
>> if you want to debug something with lto.
>>
>> The short story is...
>>
>> They are created here:
>>
>>       if (parallel)
>>         {
>>           makefile = make_temp_file (".mk");
>>           mstream = fopen (makefile, "w");
>>
>> and here:
>>
>>       /* Note: we assume argv contains at least one element; this is
>>          checked above.  */
>>
>>       response_file = make_temp_file ("");
>>
>>       f = fopen (response_file, "w");
>>
>> And in a few other places as well, it depends a bit
>> if -o is used or not (i.e. linker_output != NULL or not).
>>
>> and not removed here:
>>
>>
>>   if (response_file && !save_temps)
>>     {
>>       unlink (response_file);
>>       response_file = NULL;
>>     }
>>
>> and here:
>>
>>           do_wait (new_argv[0], pex);
>>           maybe_unlink (makefile);
>>           makefile = NULL;
>>
>>
>> the code with the response_file is executed both in
>> lto-wrapper and collect2, but in collect2 only when
>> if is invoked from lto-wrapper, triggered by the @file
>> argument list.
>>
>> Therefore I figured that the best possible
>> solution is just let lto-wrapper create a temp-file
>> for those problem cases, and use TMPDIR to have
>> all make_temp_file that follow use that to folder to
>> place the those response files and other stuff in
>> there.
>>
>>
>> So that is what I split out from the previous patch,
>> which focused on collect2.
>>
>>
>> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
>> Is it OK for trunk?
> 
> I don't think this is an improvement.  The files still
> will be (correctly) retained and now in addition to that
> there's temporary directories piling up?
> 

Well, the temp. directory has a known name,
in case the command line is

gcc -save-temps -lto -o test test.c

there are those 4 in a *known* place, test.lto_tmpdir:

test.lto_tmpdir:
insgesamt 24
drwxrwxr-x 2 ed ed 4096 Feb 20 16:14 .
drwxrwxr-x 3 ed ed 4096 Feb 20 16:14 ..
-rw------- 1 ed ed   15 Feb 20 16:14 cc8FwPQ1
-rw------- 1 ed ed  237 Feb 20 16:14 cchROrdh
-rw------- 1 ed ed  197 Feb 20 16:14 cclbBAUp
-rw------- 1 ed ed    7 Feb 20 16:14 ccMlfh1g

plus
-rw-rw-r-- 1 ed ed   164 Feb 20 16:14 test.i
-rw-rw-r-- 1 ed ed    50 Feb 20 16:14 test.lto_wrapper_args
-rw-rw-r-- 1 ed ed    17 Feb 20 16:14 test.ltrans.out
-rw-rw-r-- 1 ed ed  1232 Feb 20 16:14 test.ltrans0.ltrans.o
-rw-rw-r-- 1 ed ed  2539 Feb 20 16:14 test.ltrans0.o
-rw-rw-r-- 1 ed ed   374 Feb 20 16:14 test.ltrans0.s
-rw-rw-r-- 1 ed ed    52 Feb 20 16:14 test.res
-rw-rw-r-- 1 ed ed  4267 Feb 20 16:14 test.s

if the command line is
gcc -save-temps -lto test.c

there are a few more but also in a *known* place, a.out.lto_tmpdir:

a.out.lto_tmpdir/
total 36
drwxrwxr-x 2 ed ed 4096 Feb 20 16:18 .
drwxrwxr-x 3 ed ed 4096 Feb 20 16:18 ..
-rw------- 1 ed ed    7 Feb 20 16:18 cc2hY8SH
-rw------- 1 ed ed  227 Feb 20 16:18 ccDafyit
-rw------- 1 ed ed  262 Feb 20 16:18 ccglzNAe
-rw------- 1 ed ed   36 Feb 20 16:18 ccnAU7NG
-rw------- 1 ed ed   38 Feb 20 16:18 ccoLFY2H.ltrans.out
-rw-rw-r-- 1 ed ed 1232 Feb 20 16:18 ccoLFY2H.ltrans0.ltrans.o
-rw-rw-r-- 1 ed ed 2560 Feb 20 16:18 ccoLFY2H.ltrans0.o

plus
-rw-rw-r--   1 ed ed    50 Feb 20 16:18 a.out.lto_wrapper_args
-rw-rw-r--   1 ed ed   160 Feb 20 16:18 test.i
-rw-rw-r--   1 ed ed  3104 Feb 20 16:18 test.o
-rw-rw-r--   1 ed ed    52 Feb 20 16:18 test.res
-rw-rw-r--   1 ed ed  4267 Feb 20 16:18 test.s


> A better improvement would be to selectively decide
> which files might not be needed to be preserved and/or
> give them names in the build directory in more cases.
> 

Ah, well, it just felt like that will probably need a
rather complicated patch which is probably not
worth it, since the are a lot of different
code pathes involved, (with -g or not, with -flto=jobserver
or not, flto_partition=none, or with offload or not, with -o
or not etc.) in two or more independent forked processes,
which will need to coordinate somehow, not to clobber each
other's tempfiles.


Bernd.


> Richard.
> 
>>
>> Thanks
>> Bernd.
>>
>>
> 

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

* Re: [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-02-20 15:34   ` Bernd Edlinger
@ 2020-02-20 16:09     ` Tobias Burnus
  2020-02-20 19:25       ` Bernd Edlinger
  2020-02-21  7:35     ` Richard Biener
  1 sibling, 1 reply; 9+ messages in thread
From: Tobias Burnus @ 2020-02-20 16:09 UTC (permalink / raw)
  To: Bernd Edlinger, Richard Biener; +Cc: gcc-patches

Hi Bernd, hi all,

note that you can get even more files: If you do offloading,
LTO is additionally run for each offloading target (there
can be more than one), cf. https://gcc.gnu.org/wiki/Offloading

Some of those files are probably also from mkoffload etc.
See below.

On 2/20/20 4:33 PM, Bernd Edlinger wrote:

> On 2/20/20 2:34 PM, Richard Biener wrote:
>> I don't think this is an improvement.  The files still
>> will be (correctly) retained and now in addition to that
>> there's temporary directories piling up?
> Well, the temp. directory has a known name,
> in case the command line is
>
> gcc -save-temps -lto -o test test.c
>
> there are those 4 in a *known* place, test.lto_tmpdir:

Here, with offloading (compiler only supports one
offloading target), I get for
    gfortran -fopenacc -save-temps -o test kernels-map-2.F90

(1) in the current directory:
kernels-map-2.f90
kernels-map-2.o
test.lto_wrapper_args
kernels-map-2.res
kernels-map-2.s
ccv97orQ.i
ccv97orQ.s

(2) in /tmp:
ccXtFBKP.ofldlist
cckm9TaT
cc1aPJVX
ccwnCSfQ
ccEwCVRX
ccv97orQ.c
ccgtnzbU.mkoffload
ccsZzs01
ccouoZqP.target.o
cc6o87mX.crtoffloadtable.o
test

And with "-flto" in addition:

(1) Current directory:
kernels-map-2.f90
kernels-map-2.o
test.lto_wrapper_args
kernels-map-2.res
kernels-map-2.s
ccdBFFxF.i
ccdBFFxF.s
test.ltrans0.o
test.ltrans.out
test.ltrans0.s
test.ltrans0.ltrans.o
test

(2) in /tmp:
ccX5EDTE.ofldlist
ccpAKbE7
ccxnuNsz
ccq5sdmF
ccWUsloz
ccZ5rev7.mkoffload
ccdBFFxF.c
cc3PGOK1
ccW4hTGF.target.o
ccWH1ft2
ccsKJG3z.crtoffloadtable.o
ccmE0bPK
ccB54fLv
cckO6O6c

Cheers,

Tobias

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

* Re: [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-02-20 16:09     ` Tobias Burnus
@ 2020-02-20 19:25       ` Bernd Edlinger
  0 siblings, 0 replies; 9+ messages in thread
From: Bernd Edlinger @ 2020-02-20 19:25 UTC (permalink / raw)
  To: Tobias Burnus, Richard Biener; +Cc: gcc-patches

Hi Tobias,

On 2/20/20 5:09 PM, Tobias Burnus wrote:
> Hi Bernd, hi all,
> 
> note that you can get even more files: If you do offloading,
> LTO is additionally run for each offloading target (there
> can be more than one), cf. https://gcc.gnu.org/wiki/Offloading
> 
> Some of those files are probably also from mkoffload etc.
> See below.
> 
> On 2/20/20 4:33 PM, Bernd Edlinger wrote:
> 
>> On 2/20/20 2:34 PM, Richard Biener wrote:
>>> I don't think this is an improvement.  The files still
>>> will be (correctly) retained and now in addition to that
>>> there's temporary directories piling up?
>> Well, the temp. directory has a known name,
>> in case the command line is
>>
>> gcc -save-temps -lto -o test test.c
>>
>> there are those 4 in a *known* place, test.lto_tmpdir:
> 
> Here, with offloading (compiler only supports one
> offloading target), I get for
>    gfortran -fopenacc -save-temps -o test kernels-map-2.F90
> 
> (1) in the current directory:
> kernels-map-2.f90
> kernels-map-2.o
> test.lto_wrapper_args
> kernels-map-2.res
> kernels-map-2.s
> ccv97orQ.i
> ccv97orQ.s
> 
> (2) in /tmp:
> ccXtFBKP.ofldlist
> cckm9TaT
> cc1aPJVX
> ccwnCSfQ
> ccEwCVRX
> ccv97orQ.c
> ccgtnzbU.mkoffload
> ccsZzs01
> ccouoZqP.target.o
> cc6o87mX.crtoffloadtable.o
> test
> 
> And with "-flto" in addition:
> 
> (1) Current directory:
> kernels-map-2.f90
> kernels-map-2.o
> test.lto_wrapper_args
> kernels-map-2.res
> kernels-map-2.s
> ccdBFFxF.i
> ccdBFFxF.s
> test.ltrans0.o
> test.ltrans.out
> test.ltrans0.s
> test.ltrans0.ltrans.o
> test
> 
> (2) in /tmp:
> ccX5EDTE.ofldlist
> ccpAKbE7
> ccxnuNsz
> ccq5sdmF
> ccWUsloz
> ccZ5rev7.mkoffload
> ccdBFFxF.c
> cc3PGOK1
> ccW4hTGF.target.o
> ccWH1ft2
> ccsKJG3z.crtoffloadtable.o
> ccmE0bPK
> ccB54fLv
> cckO6O6c
> 

I cannot test anything with offload, because that setup is out of my reach.
I believe this patch will improve the situation significantly, but I would
be curious to know if the temp files move away from /tmp if you
might give this patch a try.  It will not prevent the ccXXXXX.i/s
in the $PWD, unfortunately.


Thanks
Bernd.

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

* Re: [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-02-20 15:34   ` Bernd Edlinger
  2020-02-20 16:09     ` Tobias Burnus
@ 2020-02-21  7:35     ` Richard Biener
  2020-12-14 15:31       ` Bernd Edlinger
  1 sibling, 1 reply; 9+ messages in thread
From: Richard Biener @ 2020-02-21  7:35 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches

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

On Thu, 20 Feb 2020, Bernd Edlinger wrote:

> On 2/20/20 2:34 PM, Richard Biener wrote:
> > On Thu, 20 Feb 2020, Bernd Edlinger wrote:
> > 
> >> Hi,
> >>
> >> this is the remaining issue that happens when -flto and -save-temps
> >> is used together, it leaks several files in /tmp.
> >>
> >> I try to give more background to how these temp files are
> >> created, and in all likelihood the leaking of these
> >> files is wanted, and certainly very helpful for debugging
> >> lto issues, that's for sure.  It is just not helpful
> >> that they need to be looked up in the /tmp folder, even
> >> if you want to debug something with lto.
> >>
> >> The short story is...
> >>
> >> They are created here:
> >>
> >>       if (parallel)
> >>         {
> >>           makefile = make_temp_file (".mk");
> >>           mstream = fopen (makefile, "w");
> >>
> >> and here:
> >>
> >>       /* Note: we assume argv contains at least one element; this is
> >>          checked above.  */
> >>
> >>       response_file = make_temp_file ("");
> >>
> >>       f = fopen (response_file, "w");
> >>
> >> And in a few other places as well, it depends a bit
> >> if -o is used or not (i.e. linker_output != NULL or not).
> >>
> >> and not removed here:
> >>
> >>
> >>   if (response_file && !save_temps)
> >>     {
> >>       unlink (response_file);
> >>       response_file = NULL;
> >>     }
> >>
> >> and here:
> >>
> >>           do_wait (new_argv[0], pex);
> >>           maybe_unlink (makefile);
> >>           makefile = NULL;
> >>
> >>
> >> the code with the response_file is executed both in
> >> lto-wrapper and collect2, but in collect2 only when
> >> if is invoked from lto-wrapper, triggered by the @file
> >> argument list.
> >>
> >> Therefore I figured that the best possible
> >> solution is just let lto-wrapper create a temp-file
> >> for those problem cases, and use TMPDIR to have
> >> all make_temp_file that follow use that to folder to
> >> place the those response files and other stuff in
> >> there.
> >>
> >>
> >> So that is what I split out from the previous patch,
> >> which focused on collect2.
> >>
> >>
> >> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> >> Is it OK for trunk?
> > 
> > I don't think this is an improvement.  The files still
> > will be (correctly) retained and now in addition to that
> > there's temporary directories piling up?
> > 
> 
> Well, the temp. directory has a known name,
> in case the command line is
> 
> gcc -save-temps -lto -o test test.c
> 
> there are those 4 in a *known* place, test.lto_tmpdir:
> 
> test.lto_tmpdir:
> insgesamt 24
> drwxrwxr-x 2 ed ed 4096 Feb 20 16:14 .
> drwxrwxr-x 3 ed ed 4096 Feb 20 16:14 ..
> -rw------- 1 ed ed   15 Feb 20 16:14 cc8FwPQ1
> -rw------- 1 ed ed  237 Feb 20 16:14 cchROrdh
> -rw------- 1 ed ed  197 Feb 20 16:14 cclbBAUp
> -rw------- 1 ed ed    7 Feb 20 16:14 ccMlfh1g
> 
> plus
> -rw-rw-r-- 1 ed ed   164 Feb 20 16:14 test.i
> -rw-rw-r-- 1 ed ed    50 Feb 20 16:14 test.lto_wrapper_args
> -rw-rw-r-- 1 ed ed    17 Feb 20 16:14 test.ltrans.out
> -rw-rw-r-- 1 ed ed  1232 Feb 20 16:14 test.ltrans0.ltrans.o
> -rw-rw-r-- 1 ed ed  2539 Feb 20 16:14 test.ltrans0.o
> -rw-rw-r-- 1 ed ed   374 Feb 20 16:14 test.ltrans0.s
> -rw-rw-r-- 1 ed ed    52 Feb 20 16:14 test.res
> -rw-rw-r-- 1 ed ed  4267 Feb 20 16:14 test.s
> 
> if the command line is
> gcc -save-temps -lto test.c
> 
> there are a few more but also in a *known* place, a.out.lto_tmpdir:
> 
> a.out.lto_tmpdir/
> total 36
> drwxrwxr-x 2 ed ed 4096 Feb 20 16:18 .
> drwxrwxr-x 3 ed ed 4096 Feb 20 16:18 ..
> -rw------- 1 ed ed    7 Feb 20 16:18 cc2hY8SH
> -rw------- 1 ed ed  227 Feb 20 16:18 ccDafyit
> -rw------- 1 ed ed  262 Feb 20 16:18 ccglzNAe
> -rw------- 1 ed ed   36 Feb 20 16:18 ccnAU7NG
> -rw------- 1 ed ed   38 Feb 20 16:18 ccoLFY2H.ltrans.out
> -rw-rw-r-- 1 ed ed 1232 Feb 20 16:18 ccoLFY2H.ltrans0.ltrans.o
> -rw-rw-r-- 1 ed ed 2560 Feb 20 16:18 ccoLFY2H.ltrans0.o
> 
> plus
> -rw-rw-r--   1 ed ed    50 Feb 20 16:18 a.out.lto_wrapper_args
> -rw-rw-r--   1 ed ed   160 Feb 20 16:18 test.i
> -rw-rw-r--   1 ed ed  3104 Feb 20 16:18 test.o
> -rw-rw-r--   1 ed ed    52 Feb 20 16:18 test.res
> -rw-rw-r--   1 ed ed  4267 Feb 20 16:18 test.s
> 
> 
> > A better improvement would be to selectively decide
> > which files might not be needed to be preserved and/or
> > give them names in the build directory in more cases.
> > 
> 
> Ah, well, it just felt like that will probably need a
> rather complicated patch which is probably not
> worth it, since the are a lot of different
> code pathes involved, (with -g or not, with -flto=jobserver
> or not, flto_partition=none, or with offload or not, with -o
> or not etc.) in two or more independent forked processes,
> which will need to coordinate somehow, not to clobber each
> other's tempfiles.

IIRC this definitely clashes with Alex work to overhaul
-auxdir/-dumpdir queued for GCC 11 where some of the above
is improved.

So whatever we do we should do it for GCC 11 after Alex patches
land.

Richard.

> 
> Bernd.
> 
> 
> > Richard.
> > 
> >>
> >> Thanks
> >> Bernd.
> >>
> >>
> > 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

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

* Re: [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-02-21  7:35     ` Richard Biener
@ 2020-12-14 15:31       ` Bernd Edlinger
  2020-12-21 11:45         ` [PING] " Bernd Edlinger
  2021-01-04  7:58         ` Richard Biener
  0 siblings, 2 replies; 9+ messages in thread
From: Bernd Edlinger @ 2020-12-14 15:31 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

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

Hi,

On 2/21/20 8:35 AM, Richard Biener wrote:
> 
> IIRC this definitely clashes with Alex work to overhaul
> -auxdir/-dumpdir queued for GCC 11 where some of the above
> is improved.
> 
> So whatever we do we should do it for GCC 11 after Alex patches
> land.
> 
> Richard.
> 

Okay, I think this patch was applied in the mean time.
Just some 20-30 temp files are left from a full run of the testsuite.

So I rewrote my patch, and found this time it looks
feasible to avoid all remaining temp files with unpredictable
random names, so that is an improvement over the state earlier
this year.


Attached is my new patch, to clean up the rest of the -save-temps
files.  That consist just of a couple of @file parameters.

I added a few test cases, and the testsuite runs without any
temp files leaking.

Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-save-temp-leaking-lto-files-in-tmp.patch --]
[-- Type: text/x-patch; name="0001-Fix-save-temp-leaking-lto-files-in-tmp.patch", Size: 23239 bytes --]

From 5e07f814f102d6dabebcb6652a40f5a1b9716479 Mon Sep 17 00:00:00 2001
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date: Sun, 13 Dec 2020 08:24:57 +0100
Subject: [PATCH] Fix -save-temp leaking lto files in /tmp

When linking with -flto and -save-temps, various
temporary files are created in /tmp.
The same happens when invoking the driver with @file
parameter, and using -L or -I options.

2020-12-12  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* collect-utils.c (collect_execute): Check dumppfx.
	* collect2.c (maybe_run_lto_and_relink, do_link): Pass atsuffix
	to collect_execute.
	(do_link): Add new parameter atsuffix.
	(main): Handle -dumpdir option.  Skip one argument for
	-o, -isystem and -B options.
	* gcc.c (make_at_file): New helper function.
	(close_at_file): Use it.

gcc/testsuite:
2020-12-12  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gcc.misc-tests/outputs.exp: Adjust testcase.
---
 gcc/collect-utils.c                      |  2 +-
 gcc/collect2.c                           | 43 ++++++++++++++++++++------------
 gcc/gcc.c                                | 28 ++++++++++++++++++++-
 gcc/testsuite/gcc.misc-tests/outputs.exp | 31 ++++++++++++++---------
 4 files changed, 74 insertions(+), 30 deletions(-)

diff --git a/gcc/collect-utils.c b/gcc/collect-utils.c
index 095db8d..921bb34 100644
--- a/gcc/collect-utils.c
+++ b/gcc/collect-utils.c
@@ -127,7 +127,7 @@ collect_execute (const char *prog, char **argv, const char *outname,
       /* Note: we assume argv contains at least one element; this is
          checked above.  */
 
-      if (!save_temps || !atsuffix)
+      if (!save_temps || !atsuffix || !dumppfx)
 	response_file = make_temp_file ("");
       else
 	response_file = concat (dumppfx, atsuffix, NULL);
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 3a43a5a..3f097f9 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -644,7 +644,7 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
 
       /* Run the LTO back end.  */
       pex = collect_execute (prog, lto_c_argv, NULL, NULL, PEX_SEARCH,
-			     at_file_supplied, NULL);
+			     at_file_supplied, "lto_args");
       {
 	int c;
 	FILE *stream;
@@ -728,7 +728,7 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
       /* Run the linker again, this time replacing the object files
          optimized by the LTO with the temporary file generated by the LTO.  */
       fork_execute ("ld", out_lto_ld_argv, HAVE_GNU_LD && at_file_supplied,
-		    NULL);
+		    "ld_args");
       /* We assume that temp files were created, and therefore we need to take
          that into account (maybe run dsymutil).  */
       post_ld_pass (/*temp_file*/true);
@@ -740,7 +740,8 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
     {
       /* Our caller is relying on us to do the link
          even though there is no LTO back end work to be done.  */
-      fork_execute ("ld", lto_ld_argv, HAVE_GNU_LD && at_file_supplied, NULL);
+      fork_execute ("ld", lto_ld_argv, HAVE_GNU_LD && at_file_supplied,
+		    "ld_args");
       /* No LTO objects were found, so no new temp file.  */
       post_ld_pass (/*temp_file*/false);
     }
@@ -751,13 +752,13 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
    LD_ARGV is an array of arguments for the linker.  */
 
 static void
-do_link (char **ld_argv)
+do_link (char **ld_argv, const char *atsuffix)
 {
   struct pex_obj *pex;
   const char *prog = "ld";
   pex = collect_execute (prog, ld_argv, NULL, NULL,
 			 PEX_LAST | PEX_SEARCH,
-			 HAVE_GNU_LD && at_file_supplied, NULL);
+			 HAVE_GNU_LD && at_file_supplied, atsuffix);
   int ret = collect_wait (prog, pex);
   if (ret)
     {
@@ -973,10 +974,10 @@ main (int argc, char **argv)
 	  {
 	    /* Parse the output filename if it's given so that we can make
 	       meaningful temp filenames.  */
-	    if (argv[i][2] == '\0')
-	      output_file = argv[i+1];
-	    else
+	    if (argv[i][2] != '\0')
 	      output_file = &argv[i][2];
+	    else if (argv[i+1] != NULL)
+	      output_file = argv[++i];
 	  }
 
 #ifdef COLLECT_EXPORT_LIST
@@ -1022,6 +1023,12 @@ main (int argc, char **argv)
 	else if (strncmp (q, "-save-temps", 11) == 0)
 	  /* FIXME: Honour =obj.  */
 	  save_temps = true;
+	else if (strcmp (q, "-dumpdir") == 0)
+	  dumppfx = xstrdup (extract_string (&p));
+	else if (strcmp (q, "-o") == 0
+		 || strcmp (q, "-B") == 0
+		 || strcmp (q, "-isystem") == 0)
+	  (void) extract_string (&p);
     }
     obstack_free (&temporary_obstack, temporary_firstobj);
 
@@ -1241,6 +1248,10 @@ main (int argc, char **argv)
 	      *c_ptr++ = xstrdup (q);
 	    }
 	}
+      else if (strcmp (q, "-o") == 0
+	       || strcmp (q, "-dumpdir") == 0
+	       || strcmp (q, "-isystem") == 0)
+	(void) extract_string (&p);
 #ifdef COLLECT_EXPORT_LIST
       /* Detect any invocation with -fvisibility.  */
       if (strncmp (q, "-fvisibility", 12) == 0)
@@ -1415,10 +1426,10 @@ main (int argc, char **argv)
 #endif
 
 	    case 'o':
-	      if (arg[2] == '\0')
-		output_file = *ld1++ = *ld2++ = *++argv;
-	      else
+	      if (arg[2] != '\0')
 		output_file = &arg[2];
+	      else if (argv[1])
+		output_file = *ld1++ = *ld2++ = *++argv;
 	      break;
 
 	    case 'r':
@@ -1647,7 +1658,7 @@ main (int argc, char **argv)
        functions from precise cross reference insertions by the compiler.  */
 
     if (early_exit || ld1_filter != SCAN_NOTHING)
-      do_link (ld1_argv);
+      do_link (ld1_argv, "ld1_args");
 
     if (early_exit)
       {
@@ -1708,7 +1719,7 @@ main (int argc, char **argv)
       /* Do link without additional code generation now if we didn't
 	 do it earlier for scanning purposes.  */
       if (ld1_filter == SCAN_NOTHING)
-	do_link (ld1_argv);
+	do_link (ld1_argv, "ld1_args");
 
       if (lto_mode)
         maybe_run_lto_and_relink (ld1_argv, object_lst, object, false);
@@ -1806,10 +1817,10 @@ main (int argc, char **argv)
   /* Assemble the constructor and destructor tables.
      Link the tables in with the rest of the program.  */
 
-  fork_execute ("gcc",  c_argv, at_file_supplied, NULL);
+  fork_execute ("gcc",  c_argv, at_file_supplied, "gcc_args");
 #ifdef COLLECT_EXPORT_LIST
   /* On AIX we must call link because of possible templates resolution.  */
-  do_link (ld2_argv);
+  do_link (ld2_argv, "ld2_args");
 
   if (lto_mode)
     maybe_run_lto_and_relink (ld2_argv, object_lst, object, false);
@@ -1819,7 +1830,7 @@ main (int argc, char **argv)
     maybe_run_lto_and_relink (ld2_argv, object_lst, object, true);
   else
     {
-      fork_execute ("ld", ld2_argv, HAVE_GNU_LD && at_file_supplied, NULL);
+      fork_execute ("ld", ld2_argv, HAVE_GNU_LD && at_file_supplied, "ld_args");
       post_ld_pass (/*temp_file*/false);
     }
 
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 1d32375..cbe948d 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -2195,6 +2195,32 @@ open_at_file (void)
      in_at_file = true;
 }
 
+/* Create a temporary @file name.  */
+
+static char *make_at_file (void)
+{
+  static int fileno = 0;
+  char filename[20];
+  const char *base, *ext;
+
+  if (!save_temps_flag)
+    return make_temp_file ("");
+
+  base = dumpbase;
+  if (!(base && *base))
+    base = dumpdir;
+  if (!(base && *base))
+    base = "a";
+
+  sprintf (filename, ".args.%d", fileno++);
+  ext = filename;
+
+  if (base == dumpdir && dumpdir_trailing_dash_added)
+    ext++;
+
+  return concat (base, ext, NULL);
+}
+
 /* Close the temporary @file and add @file to the argument list.  */
 
 static void
@@ -2210,7 +2236,7 @@ close_at_file (void)
     return;
 
   char **argv = (char **) alloca (sizeof (char *) * (n_args + 1));
-  char *temp_file = make_temp_file ("");
+  char *temp_file = make_at_file ();
   char *at_argument = concat ("@", temp_file, NULL);
   FILE *f = fopen (temp_file, "w");
   int status;
diff --git a/gcc/testsuite/gcc.misc-tests/outputs.exp b/gcc/testsuite/gcc.misc-tests/outputs.exp
index 1fdd61a..0324d1a 100644
--- a/gcc/testsuite/gcc.misc-tests/outputs.exp
+++ b/gcc/testsuite/gcc.misc-tests/outputs.exp
@@ -284,6 +284,12 @@ outest "$b exe savetmp named0" $sing "-o $b-0.exe -save-temps" {} {{-0.i -0.s -0
 outest "$b exe savetmp namedb" $sing "-o $b.exe -save-temps" {} {{--0.i --0.s --0.o .exe}}
 outest "$b exe savetmp named2" $mult "-o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .exe}}
 
+# Additional files are created when an @file is used
+outest "$b exe savetmp namedb" $sing "@/dev/null -o $b.exe -save-temps" {} {{--0.i --0.s --0.o .args.0 .ld1_args .exe}}
+outest "$b exe savetmp named2" $mult "@/dev/null -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .args.0 .ld1_args .exe}}
+outest "$b exe savetmp named2" $mult "@/dev/null -I dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 .ld1_args .exe}}
+outest "$b exe savetmp named2" $mult "@/dev/null -I dummy -L dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 .args.3 .ld1_args .exe}}
+
 # Setting the main output to a dir selects it as the default aux&dump
 # location.
 outest "$b cpp savetmp namedir0" $sing "-E -o o/$b-0.i -save-temps" {o/} {{-0.i} {}}
@@ -638,6 +644,7 @@ outest "$b lto sing named" $sing "-o $b.exe -O2 -flto -fno-use-linker-plugin -fl
 outest "$b lto mult named" $mult "-o $b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {} {{--1.c.???i.icf --1.c.???r.final --2.c.???i.icf --2.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe}}
 outest "$b lto sing nameddir" $sing "-o dir/$b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--0.c.???i.icf --0.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe} {}}
 outest "$b lto mult nameddir" $mult "-o dir/$b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--1.c.???i.icf --1.c.???r.final --2.c.???i.icf --2.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe} {}}
+outest "$b lto sing unnamed" $sing "@/dev/null -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage -save-temps $oaout" {} {{a--0.c.???i.icf a--0.c.???r.final a.wpa.???i.icf a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a--0.o a--0.s a--0.i a.ltrans0.o a.ltrans.out a.ltrans0.ltrans.o a.ltrans0.ltrans_args a.args.0 a.ltrans0.ltrans.s a.wpa.args.0 a.lto_args a.ld1_args a.ltrans_args a.ltrans0.ltrans.args.0 a.ld_args $aout}}
 }
 
 # -dumpbase without -dumpdir.  The trailing dumppfx dash after it is
@@ -703,20 +710,20 @@ outest "$b lto sing empty dumpdir empty dumpbase namedb" $sing "-dumpdir \"\" -d
 outest "$b lto mult empty dumpdir empty dumpbase namedb" $mult "-dumpdir \"\" -dumpbase \"\" -o dir/$b.exe -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{.exe} {-1.c.???i.icf !$ltop -1.c.???r.final !0 -2.c.???i.icf !$ltop -2.c.???r.final !0 .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su}}
 
 # Now -flto with -save-temps, not exhaustive.
-outest "$b lto st sing empty dumpbase unnamed" $sing "-dumpbase \"\" -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{-0.i -0.s -0.o -0.c.???i.icf !$ltop -0.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args $aout}}
-outest "$b lto st mult empty dumpbase unnamed" $mult "-dumpbase \"\" -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{-1.i -1.s -1.o -1.c.???i.icf !$ltop -1.c.???r.final !0 -2.i -2.s -2.o -2.c.???i.icf !$ltop -2.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args $aout}}
-outest "$b lto st sing dumpdir empty dumpbase named" $sing "-dumpdir dir/ -dumpbase \"\" -o $b-0.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-0.i -0.s -0.o -0.c.???i.icf !$ltop -0.c.???r.final !!$ltop -0.lto_wrapper_args !0 -0.wpa.???i.icf -0.ltrans.out -0.ltrans_args !!$ltop -0.res !0 -0.ltrans0.o -0.ltrans0.ltrans.???r.final -0.ltrans0.ltrans.su -0.ltrans0.ltrans.s -0.ltrans0.ltrans.o -0.ltrans0.ltrans_args} {-0.exe}}
-outest "$b lto st mult dumpdir empty dumpbase named" $mult "-dumpdir dir/ -dumpbase \"\" -o $b-1.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-1.i -1.s -1.o -1.c.???i.icf !$ltop -1.c.???r.final !0 -2.i -2.s -2.o -2.c.???i.icf !$ltop -2.c.???r.final !!$ltop -1.lto_wrapper_args !0 -1.wpa.???i.icf -1.ltrans.out -1.ltrans_args !!$ltop -1.res !0 -1.ltrans0.o -1.ltrans0.ltrans.???r.final -1.ltrans0.ltrans.su -1.ltrans0.ltrans.s -1.ltrans0.ltrans.o -1.ltrans0.ltrans_args} {-1.exe}}
-outest "$b lto st sing empty dumpbase namedb" $sing "-dumpbase \"\" -o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-0.i -0.s -0.o -0.c.???i.icf !$ltop -0.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .exe} {}}
-outest "$b lto st mult empty dumpbase namedb" $mult "-dumpbase \"\" -o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-1.i -1.s -1.o -1.c.???i.icf !$ltop -1.c.???r.final !0 -2.i -2.s -2.o -2.c.???i.icf !$ltop -2.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .exe} {}}
+outest "$b lto st sing empty dumpbase unnamed" $sing "-dumpbase \"\" -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{-0.i -0.s -0.o -0.c.???i.icf !$ltop -0.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args a.ltrans0.ltrans.args.0 a.wpa.args.0 $aout}}
+outest "$b lto st mult empty dumpbase unnamed" $mult "-dumpbase \"\" -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{-1.i -1.s -1.o -1.c.???i.icf !$ltop -1.c.???r.final !0 -2.i -2.s -2.o -2.c.???i.icf !$ltop -2.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args a.ltrans0.ltrans.args.0 a.wpa.args.0 $aout}}
+outest "$b lto st sing dumpdir empty dumpbase named" $sing "-dumpdir dir/ -dumpbase \"\" -o $b-0.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-0.i -0.s -0.o -0.c.???i.icf !$ltop -0.c.???r.final !!$ltop -0.lto_wrapper_args !0 -0.wpa.???i.icf -0.ltrans.out -0.ltrans_args !!$ltop -0.res !0 -0.ltrans0.o -0.ltrans0.ltrans.???r.final -0.ltrans0.ltrans.su -0.ltrans0.ltrans.s -0.ltrans0.ltrans.o -0.ltrans0.ltrans_args -0.ltrans0.ltrans.args.0 -0.wpa.args.0} {-0.exe}}
+outest "$b lto st mult dumpdir empty dumpbase named" $mult "-dumpdir dir/ -dumpbase \"\" -o $b-1.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-1.i -1.s -1.o -1.c.???i.icf !$ltop -1.c.???r.final !0 -2.i -2.s -2.o -2.c.???i.icf !$ltop -2.c.???r.final !!$ltop -1.lto_wrapper_args !0 -1.wpa.???i.icf -1.ltrans.out -1.ltrans_args !!$ltop -1.res !0 -1.ltrans0.o -1.ltrans0.ltrans.???r.final -1.ltrans0.ltrans.su -1.ltrans0.ltrans.s -1.ltrans0.ltrans.o -1.ltrans0.ltrans_args -1.ltrans0.ltrans.args.0 -1.wpa.args.0} {-1.exe}}
+outest "$b lto st sing empty dumpbase namedb" $sing "-dumpbase \"\" -o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-0.i -0.s -0.o -0.c.???i.icf !$ltop -0.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .ltrans0.ltrans.args.0 .wpa.args.0 .exe} {}}
+outest "$b lto st mult empty dumpbase namedb" $mult "-dumpbase \"\" -o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{-1.i -1.s -1.o -1.c.???i.icf !$ltop -1.c.???r.final !0 -2.i -2.s -2.o -2.c.???i.icf !$ltop -2.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .ltrans0.ltrans.args.0 .wpa.args.0 .exe} {}}
 
 # lto save-temps without -dumpbase.
-outest "$b lto st sing unnamed" $sing "-save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{a--0.i a--0.s a--0.o a--0.c.???i.icf !$ltop a--0.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args $aout}}
-outest "$b lto st mult unnamed" $mult "-save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{a--1.i a--1.s a--1.o a--1.c.???i.icf !$ltop a--1.c.???r.final !0 a--2.i a--2.s a--2.o a--2.c.???i.icf !$ltop a--2.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args $aout}}
-outest "$b lto st sing dumpdir named" $sing "-dumpdir dir/$b- -o $b-0.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--0.i --0.s --0.o --0.c.???i.icf !$ltop --0.c.???r.final !!$ltop -lto_wrapper_args !0 -wpa.???i.icf -ltrans.out -ltrans_args !!$ltop -res !0 -ltrans0.o -ltrans0.ltrans.???r.final -ltrans0.ltrans.su -ltrans0.ltrans.s -ltrans0.ltrans.o -ltrans0.ltrans_args} {-0.exe}}
-outest "$b lto st mult dumpdir named" $mult "-dumpdir dir/$b- -o $b-1.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--1.i --1.s --1.o --1.c.???i.icf !$ltop --1.c.???r.final !0 --2.i --2.s --2.o --2.c.???i.icf !$ltop --2.c.???r.final !!$ltop -lto_wrapper_args !0 -wpa.???i.icf -ltrans.out -ltrans_args !!$ltop -res !0 -ltrans0.o -ltrans0.ltrans.???r.final -ltrans0.ltrans.su -ltrans0.ltrans.s -ltrans0.ltrans.o -ltrans0.ltrans_args} {-1.exe}}
-outest "$b lto st sing namedb" $sing "-o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--0.i --0.s --0.o --0.c.???i.icf !$ltop --0.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .exe} {}}
-outest "$b lto st mult namedb" $mult "-o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--1.i --1.s --1.o --1.c.???i.icf !$ltop --1.c.???r.final !0 --2.i --2.s --2.o --2.c.???i.icf !$ltop --2.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .exe} {}}
+outest "$b lto st sing unnamed" $sing "-save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{a--0.i a--0.s a--0.o a--0.c.???i.icf !$ltop a--0.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args a.ltrans0.ltrans.args.0 a.wpa.args.0 $aout}}
+outest "$b lto st mult unnamed" $mult "-save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage $oaout" {} {{a--1.i a--1.s a--1.o a--1.c.???i.icf !$ltop a--1.c.???r.final !0 a--2.i a--2.s a--2.o a--2.c.???i.icf !$ltop a--2.c.???r.final !!$ltop a.lto_wrapper_args !0 a.wpa.???i.icf a.ltrans.out a.ltrans_args !!$ltop a.res !0 a.ltrans0.o a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a.ltrans0.ltrans.s a.ltrans0.ltrans.o a.ltrans0.ltrans_args a.ltrans0.ltrans.args.0 a.wpa.args.0 $aout}}
+outest "$b lto st sing dumpdir named" $sing "-dumpdir dir/$b- -o $b-0.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--0.i --0.s --0.o --0.c.???i.icf !$ltop --0.c.???r.final !!$ltop -lto_wrapper_args !0 -wpa.???i.icf -ltrans.out -ltrans_args !!$ltop -res !0 -ltrans0.o -ltrans0.ltrans.???r.final -ltrans0.ltrans.su -ltrans0.ltrans.s -ltrans0.ltrans.o -ltrans0.ltrans_args -ltrans0.ltrans.args.0 -wpa.args.0} {-0.exe}}
+outest "$b lto st mult dumpdir named" $mult "-dumpdir dir/$b- -o $b-1.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--1.i --1.s --1.o --1.c.???i.icf !$ltop --1.c.???r.final !0 --2.i --2.s --2.o --2.c.???i.icf !$ltop --2.c.???r.final !!$ltop -lto_wrapper_args !0 -wpa.???i.icf -ltrans.out -ltrans_args !!$ltop -res !0 -ltrans0.o -ltrans0.ltrans.???r.final -ltrans0.ltrans.su -ltrans0.ltrans.s -ltrans0.ltrans.o -ltrans0.ltrans_args -ltrans0.ltrans.args.0 -wpa.args.0} {-1.exe}}
+outest "$b lto st sing namedb" $sing "-o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--0.i --0.s --0.o --0.c.???i.icf !$ltop --0.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .ltrans0.ltrans.args.0 .wpa.args.0 .exe} {}}
+outest "$b lto st mult namedb" $mult "-o dir/$b.exe -save-temps -O2 -flto -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--1.i --1.s --1.o --1.c.???i.icf !$ltop --1.c.???r.final !0 --2.i --2.s --2.o --2.c.???i.icf !$ltop --2.c.???r.final !!$ltop .lto_wrapper_args !0 .wpa.???i.icf .ltrans.out .ltrans_args !!$ltop .res !0 .ltrans0.o .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .ltrans0.ltrans.s .ltrans0.ltrans.o .ltrans0.ltrans_args .ltrans0.ltrans.args.0 .wpa.args.0 .exe} {}}
 
 # !$skip_lto
 }
-- 
1.9.1


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

* [PING] [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-12-14 15:31       ` Bernd Edlinger
@ 2020-12-21 11:45         ` Bernd Edlinger
  2021-01-04  7:58         ` Richard Biener
  1 sibling, 0 replies; 9+ messages in thread
From: Bernd Edlinger @ 2020-12-21 11:45 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi,

I'd like to ping for this patch below:
https://gcc.gnu.org/pipermail/gcc-patches/2020-December/561811.html

Thanks
Bernd.

On 12/14/20 4:31 PM, Bernd Edlinger wrote:
> Hi,
> 
> On 2/21/20 8:35 AM, Richard Biener wrote:
>>
>> IIRC this definitely clashes with Alex work to overhaul
>> -auxdir/-dumpdir queued for GCC 11 where some of the above
>> is improved.
>>
>> So whatever we do we should do it for GCC 11 after Alex patches
>> land.
>>
>> Richard.
>>
> 
> Okay, I think this patch was applied in the mean time.
> Just some 20-30 temp files are left from a full run of the testsuite.
> 
> So I rewrote my patch, and found this time it looks
> feasible to avoid all remaining temp files with unpredictable
> random names, so that is an improvement over the state earlier
> this year.
> 
> 
> Attached is my new patch, to clean up the rest of the -save-temps
> files.  That consist just of a couple of @file parameters.
> 
> I added a few test cases, and the testsuite runs without any
> temp files leaking.
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.
> 

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

* Re: [PATCH] Fix -save-temp leaking lto files in /tmp
  2020-12-14 15:31       ` Bernd Edlinger
  2020-12-21 11:45         ` [PING] " Bernd Edlinger
@ 2021-01-04  7:58         ` Richard Biener
  1 sibling, 0 replies; 9+ messages in thread
From: Richard Biener @ 2021-01-04  7:58 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches

On Mon, 14 Dec 2020, Bernd Edlinger wrote:

> Hi,
> 
> On 2/21/20 8:35 AM, Richard Biener wrote:
> > 
> > IIRC this definitely clashes with Alex work to overhaul
> > -auxdir/-dumpdir queued for GCC 11 where some of the above
> > is improved.
> > 
> > So whatever we do we should do it for GCC 11 after Alex patches
> > land.
> > 
> > Richard.
> > 
> 
> Okay, I think this patch was applied in the mean time.
> Just some 20-30 temp files are left from a full run of the testsuite.
> 
> So I rewrote my patch, and found this time it looks
> feasible to avoid all remaining temp files with unpredictable
> random names, so that is an improvement over the state earlier
> this year.
> 
> 
> Attached is my new patch, to clean up the rest of the -save-temps
> files.  That consist just of a couple of @file parameters.
> 
> I added a few test cases, and the testsuite runs without any
> temp files leaking.
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?

OK.

Thanks,
Richard.

> 
> Thanks
> Bernd.
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

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

end of thread, other threads:[~2021-01-04  7:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 13:21 [PATCH] Fix -save-temp leaking lto files in /tmp Bernd Edlinger
2020-02-20 13:34 ` Richard Biener
2020-02-20 15:34   ` Bernd Edlinger
2020-02-20 16:09     ` Tobias Burnus
2020-02-20 19:25       ` Bernd Edlinger
2020-02-21  7:35     ` Richard Biener
2020-12-14 15:31       ` Bernd Edlinger
2020-12-21 11:45         ` [PING] " Bernd Edlinger
2021-01-04  7:58         ` Richard Biener

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).