public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548).
@ 2018-07-26 10:55 Martin Liška
  2018-07-26 11:35 ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Liška @ 2018-07-26 10:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka

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

Hi.

As requested in the PR, now we produce prefixes for temp files in LTO:

Example:
$ gcc -flto main.o a.o --save-temps -o mybinary

generates:
$ ls /tmp/mybinary*
/tmp/mybinary  /tmp/mybinary.ltrans0.o  /tmp/mybinary.ltrans0.s  /tmp/mybinary.ltrans.out

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2018-07-26  Martin Liska  <mliska@suse.cz>

        PR lto/86548
	* lto-wrapper.c: Add linker_output as prefix
        for ltrans_output_file.

include/ChangeLog:

2018-07-26  Martin Liska  <mliska@suse.cz>

        PR lto/86548
	* libiberty.h (make_temp_file_with_prefix): New function.

libiberty/ChangeLog:

2018-07-26  Martin Liska  <mliska@suse.cz>

        PR lto/86548
	* make-temp-file.c (TEMP_FILE): Remove leading 'cc'.
	(make_temp_file): Call make_temp_file_with_prefix with
        first argument set to NULL.
	(make_temp_file_with_prefix): Support also prefix.
---
 gcc/lto-wrapper.c          | 14 +++++++++++++-
 include/libiberty.h        |  5 +++++
 libiberty/make-temp-file.c | 24 ++++++++++++++++++------
 3 files changed, 36 insertions(+), 7 deletions(-)



[-- Attachment #2: 0001-Add-linker_output-as-prefix-for-LTO-temps-PR-lto-865.patch --]
[-- Type: text/x-patch, Size: 3131 bytes --]

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index c3eb00dc0c2..cf4a8c659e0 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1373,7 +1373,19 @@ cont1:
 	  strcat (ltrans_output_file, ".ltrans.out");
 	}
       else
-	ltrans_output_file = make_temp_file (".ltrans.out");
+	{
+	  char *prefix = NULL;
+	  if (linker_output)
+	    {
+	      prefix = (char *) xmalloc (strlen (linker_output) + 2);
+	      strcpy (prefix, linker_output);
+	      strcat (prefix, ".");
+	    }
+
+	  ltrans_output_file = make_temp_file_with_prefix (prefix,
+							   ".ltrans.out");
+	  free (prefix);
+	}
       list_option_full = (char *) xmalloc (sizeof (char) *
 		         (strlen (ltrans_output_file) + list_option_len + 1));
       tmp = list_option_full;
diff --git a/include/libiberty.h b/include/libiberty.h
index dc09e791e41..0823614c00e 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -239,6 +239,11 @@ extern char *choose_temp_base (void) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
 
 extern char *make_temp_file (const char *) ATTRIBUTE_MALLOC;
 
+/* Return a temporary file name with given PREFIX and SUFFIX
+   or NULL if unable to create one.  */
+
+extern char *make_temp_file_with_prefix (const char *, const char *) ATTRIBUTE_MALLOC;
+
 /* Remove a link to a file unless it is special. */
 
 extern int unlink_if_ordinary (const char *);
diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c
index 89faed7f09e..21b05457542 100644
--- a/libiberty/make-temp-file.c
+++ b/libiberty/make-temp-file.c
@@ -56,7 +56,7 @@ extern int mkstemps (char *, int);
 
 /* Name of temporary file.
    mktemp requires 6 trailing X's.  */
-#define TEMP_FILE "ccXXXXXX"
+#define TEMP_FILE "XXXXXX"
 #define TEMP_FILE_LEN (sizeof(TEMP_FILE) - 1)
 
 #if !defined(_WIN32) || defined(__CYGWIN__)
@@ -181,25 +181,31 @@ string is @code{malloc}ed, and the temporary file has been created.
 */
 
 char *
-make_temp_file (const char *suffix)
+make_temp_file_with_prefix (const char *prefix, const char *suffix)
 {
   const char *base = choose_tmpdir ();
   char *temp_filename;
-  int base_len, suffix_len;
+  int base_len, suffix_len, prefix_len;
   int fd;
 
+  if (prefix == 0)
+    prefix = "cc";
+
   if (suffix == 0)
     suffix = "";
 
   base_len = strlen (base);
+  prefix_len = strlen (prefix);
   suffix_len = strlen (suffix);
 
   temp_filename = XNEWVEC (char, base_len
 			   + TEMP_FILE_LEN
-			   + suffix_len + 1);
+			   + suffix_len
+			   + prefix_len + 1);
   strcpy (temp_filename, base);
-  strcpy (temp_filename + base_len, TEMP_FILE);
-  strcpy (temp_filename + base_len + TEMP_FILE_LEN, suffix);
+  strcpy (temp_filename + base_len, prefix);
+  strcpy (temp_filename + base_len + prefix_len, TEMP_FILE);
+  strcpy (temp_filename + base_len + prefix_len + TEMP_FILE_LEN, suffix);
 
   fd = mkstemps (temp_filename, suffix_len);
   /* Mkstemps failed.  It may be EPERM, ENOSPC etc.  */
@@ -214,3 +220,9 @@ make_temp_file (const char *suffix)
     abort ();
   return temp_filename;
 }
+
+char *
+make_temp_file (const char *suffix)
+{
+  return make_temp_file_with_prefix (NULL, suffix);
+}


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

* Re: [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548).
  2018-07-26 10:55 [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548) Martin Liška
@ 2018-07-26 11:35 ` Richard Biener
  2018-07-26 12:12   ` Martin Liška
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2018-07-26 11:35 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches, Jan Hubicka

On Thu, Jul 26, 2018 at 12:55 PM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> As requested in the PR, now we produce prefixes for temp files in LTO:
>
> Example:
> $ gcc -flto main.o a.o --save-temps -o mybinary
>
> generates:
> $ ls /tmp/mybinary*
> /tmp/mybinary  /tmp/mybinary.ltrans0.o  /tmp/mybinary.ltrans0.s  /tmp/mybinary.ltrans.out

It will be /tmp/mybinary.abc421.ltrans0.o
/tmp/mybinary.abc421.ltrans1.o, etc., correct?

Otherwise there's the chance to trash user files which isn't good.

> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?

OK if the above is correct.

Thanks,
Richard.

> Martin
>
> gcc/ChangeLog:
>
> 2018-07-26  Martin Liska  <mliska@suse.cz>
>
>         PR lto/86548
>         * lto-wrapper.c: Add linker_output as prefix
>         for ltrans_output_file.
>
> include/ChangeLog:
>
> 2018-07-26  Martin Liska  <mliska@suse.cz>
>
>         PR lto/86548
>         * libiberty.h (make_temp_file_with_prefix): New function.
>
> libiberty/ChangeLog:
>
> 2018-07-26  Martin Liska  <mliska@suse.cz>
>
>         PR lto/86548
>         * make-temp-file.c (TEMP_FILE): Remove leading 'cc'.
>         (make_temp_file): Call make_temp_file_with_prefix with
>         first argument set to NULL.
>         (make_temp_file_with_prefix): Support also prefix.
> ---
>  gcc/lto-wrapper.c          | 14 +++++++++++++-
>  include/libiberty.h        |  5 +++++
>  libiberty/make-temp-file.c | 24 ++++++++++++++++++------
>  3 files changed, 36 insertions(+), 7 deletions(-)
>
>

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

* Re: [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548).
  2018-07-26 11:35 ` Richard Biener
@ 2018-07-26 12:12   ` Martin Liška
  2018-07-26 12:27     ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Liška @ 2018-07-26 12:12 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches, Jan Hubicka

On 07/26/2018 01:34 PM, Richard Biener wrote:
> On Thu, Jul 26, 2018 at 12:55 PM Martin Liška <mliska@suse.cz> wrote:
>>
>> Hi.
>>
>> As requested in the PR, now we produce prefixes for temp files in LTO:
>>
>> Example:
>> $ gcc -flto main.o a.o --save-temps -o mybinary
>>
>> generates:
>> $ ls /tmp/mybinary*
>> /tmp/mybinary  /tmp/mybinary.ltrans0.o  /tmp/mybinary.ltrans0.s  /tmp/mybinary.ltrans.out
> 
> It will be /tmp/mybinary.abc421.ltrans0.o
> /tmp/mybinary.abc421.ltrans1.o, etc., correct?

Yes, --save-temps changes which file names are used. Before patch:

$ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep ltrans
[pid 23926] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", "-fno-openmp", "-fno-openacc", "-fltrans-output-list=/tmp/ccPVzNR6.ltrans.out", "-fwpa", "-fresolution=/tmp/ccuocrhY.res", "-flinker-output=exec", "@/tmp/ccHQA575"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
[pid 23928] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/ccssDdS8", "-o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
[pid 23929] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 23929] execve("/home/marxin/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 23929] execve("/usr/local/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 23929] execve("/usr/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>

after:

$ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep ltrans
[pid 16379] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", "-fno-openmp", "-fno-openacc", "-fltrans-output-list=/tmp/mybinary.VkVmXd.ltrans.out", "-fwpa", "-fresolution=/tmp/ccnQ6e55.res", "-flinker-output=exec", "@/tmp/cc0Sv5Fe"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
[pid 16381] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/ccDY6Ojf", "-o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
[pid 16382] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 16382] execve("/home/marxin/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 16382] execve("/usr/local/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 16382] execve("/usr/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>


> 
> Otherwise there's the chance to trash user files which isn't good.

Sure, the patch behaves fine. I'll install it.

Martin

> 
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
> 
> OK if the above is correct.
> 
> Thanks,
> Richard.
> 
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2018-07-26  Martin Liska  <mliska@suse.cz>
>>
>>         PR lto/86548
>>         * lto-wrapper.c: Add linker_output as prefix
>>         for ltrans_output_file.
>>
>> include/ChangeLog:
>>
>> 2018-07-26  Martin Liska  <mliska@suse.cz>
>>
>>         PR lto/86548
>>         * libiberty.h (make_temp_file_with_prefix): New function.
>>
>> libiberty/ChangeLog:
>>
>> 2018-07-26  Martin Liska  <mliska@suse.cz>
>>
>>         PR lto/86548
>>         * make-temp-file.c (TEMP_FILE): Remove leading 'cc'.
>>         (make_temp_file): Call make_temp_file_with_prefix with
>>         first argument set to NULL.
>>         (make_temp_file_with_prefix): Support also prefix.
>> ---
>>  gcc/lto-wrapper.c          | 14 +++++++++++++-
>>  include/libiberty.h        |  5 +++++
>>  libiberty/make-temp-file.c | 24 ++++++++++++++++++------
>>  3 files changed, 36 insertions(+), 7 deletions(-)
>>
>>

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

* Re: [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548).
  2018-07-26 12:12   ` Martin Liška
@ 2018-07-26 12:27     ` Richard Biener
  2018-07-26 13:53       ` Martin Liška
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2018-07-26 12:27 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches, Jan Hubicka

On Thu, Jul 26, 2018 at 2:12 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 07/26/2018 01:34 PM, Richard Biener wrote:
> > On Thu, Jul 26, 2018 at 12:55 PM Martin Liška <mliska@suse.cz> wrote:
> >>
> >> Hi.
> >>
> >> As requested in the PR, now we produce prefixes for temp files in LTO:
> >>
> >> Example:
> >> $ gcc -flto main.o a.o --save-temps -o mybinary
> >>
> >> generates:
> >> $ ls /tmp/mybinary*
> >> /tmp/mybinary  /tmp/mybinary.ltrans0.o  /tmp/mybinary.ltrans0.s  /tmp/mybinary.ltrans.out
> >
> > It will be /tmp/mybinary.abc421.ltrans0.o
> > /tmp/mybinary.abc421.ltrans1.o, etc., correct?
>
> Yes, --save-temps changes which file names are used. Before patch:
>
> $ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep ltrans
> [pid 23926] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", "-fno-openmp", "-fno-openacc", "-fltrans-output-list=/tmp/ccPVzNR6.ltrans.out", "-fwpa", "-fresolution=/tmp/ccuocrhY.res", "-flinker-output=exec", "@/tmp/ccHQA575"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
> [pid 23928] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/ccssDdS8", "-o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
> [pid 23929] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
> [pid 23929] execve("/home/marxin/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
> [pid 23929] execve("/usr/local/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
> [pid 23929] execve("/usr/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>
> after:
>
> $ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep ltrans
> [pid 16379] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", "-fno-openmp", "-fno-openacc", "-fltrans-output-list=/tmp/mybinary.VkVmXd.ltrans.out", "-fwpa", "-fresolution=/tmp/ccnQ6e55.res", "-flinker-output=exec", "@/tmp/cc0Sv5Fe"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
> [pid 16381] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/ccDY6Ojf", "-o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
> [pid 16382] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
> [pid 16382] execve("/home/marxin/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
> [pid 16382] execve("/usr/local/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
> [pid 16382] execve("/usr/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>
>
> >
> > Otherwise there's the chance to trash user files which isn't good.
>
> Sure, the patch behaves fine. I'll install it.

Btw, it would be more natural if with -save-temps those files were in
the same directory as the output (see how we handle
-fresolution= for example) and be named without abcd1234 stuff.  That
also avoids $tmp creep if you use -save-temps
multiple times...

Richard.

> Martin
>
> >
> >> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> >>
> >> Ready to be installed?
> >
> > OK if the above is correct.
> >
> > Thanks,
> > Richard.
> >
> >> Martin
> >>
> >> gcc/ChangeLog:
> >>
> >> 2018-07-26  Martin Liska  <mliska@suse.cz>
> >>
> >>         PR lto/86548
> >>         * lto-wrapper.c: Add linker_output as prefix
> >>         for ltrans_output_file.
> >>
> >> include/ChangeLog:
> >>
> >> 2018-07-26  Martin Liska  <mliska@suse.cz>
> >>
> >>         PR lto/86548
> >>         * libiberty.h (make_temp_file_with_prefix): New function.
> >>
> >> libiberty/ChangeLog:
> >>
> >> 2018-07-26  Martin Liska  <mliska@suse.cz>
> >>
> >>         PR lto/86548
> >>         * make-temp-file.c (TEMP_FILE): Remove leading 'cc'.
> >>         (make_temp_file): Call make_temp_file_with_prefix with
> >>         first argument set to NULL.
> >>         (make_temp_file_with_prefix): Support also prefix.
> >> ---
> >>  gcc/lto-wrapper.c          | 14 +++++++++++++-
> >>  include/libiberty.h        |  5 +++++
> >>  libiberty/make-temp-file.c | 24 ++++++++++++++++++------
> >>  3 files changed, 36 insertions(+), 7 deletions(-)
> >>
> >>
>

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

* Re: [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548).
  2018-07-26 12:27     ` Richard Biener
@ 2018-07-26 13:53       ` Martin Liška
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Liška @ 2018-07-26 13:53 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches, Jan Hubicka

On 07/26/2018 02:26 PM, Richard Biener wrote:
> On Thu, Jul 26, 2018 at 2:12 PM Martin Liška <mliska@suse.cz> wrote:
>>
>> On 07/26/2018 01:34 PM, Richard Biener wrote:
>>> On Thu, Jul 26, 2018 at 12:55 PM Martin Liška <mliska@suse.cz> wrote:
>>>>
>>>> Hi.
>>>>
>>>> As requested in the PR, now we produce prefixes for temp files in LTO:
>>>>
>>>> Example:
>>>> $ gcc -flto main.o a.o --save-temps -o mybinary
>>>>
>>>> generates:
>>>> $ ls /tmp/mybinary*
>>>> /tmp/mybinary  /tmp/mybinary.ltrans0.o  /tmp/mybinary.ltrans0.s  /tmp/mybinary.ltrans.out
>>>
>>> It will be /tmp/mybinary.abc421.ltrans0.o
>>> /tmp/mybinary.abc421.ltrans1.o, etc., correct?
>>
>> Yes, --save-temps changes which file names are used. Before patch:
>>
>> $ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep ltrans
>> [pid 23926] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", "-fno-openmp", "-fno-openacc", "-fltrans-output-list=/tmp/ccPVzNR6.ltrans.out", "-fwpa", "-fresolution=/tmp/ccuocrhY.res", "-flinker-output=exec", "@/tmp/ccHQA575"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>> [pid 23928] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/ccssDdS8", "-o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>> [pid 23929] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
>> [pid 23929] execve("/home/marxin/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
>> [pid 23929] execve("/usr/local/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
>> [pid 23929] execve("/usr/bin/as", ["as", "--64", "-o", "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>>
>> after:
>>
>> $ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep ltrans
>> [pid 16379] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", "-fno-openmp", "-fno-openacc", "-fltrans-output-list=/tmp/mybinary.VkVmXd.ltrans.out", "-fwpa", "-fresolution=/tmp/ccnQ6e55.res", "-flinker-output=exec", "@/tmp/cc0Sv5Fe"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>> [pid 16381] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/ccDY6Ojf", "-o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>> [pid 16382] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
>> [pid 16382] execve("/home/marxin/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
>> [pid 16382] execve("/usr/local/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */) = -1 ENOENT (No such file or directory)
>> [pid 16382] execve("/usr/bin/as", ["as", "--64", "-o", "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 vars */ <unfinished ...>
>>
>>
>>>
>>> Otherwise there's the chance to trash user files which isn't good.
>>
>> Sure, the patch behaves fine. I'll install it.
> 
> Btw, it would be more natural if with -save-temps those files were in
> the same directory as the output (see how we handle
> -fresolution= for example) and be named without abcd1234 stuff.  That
> also avoids $tmp creep if you use -save-temps
> multiple times...

If I see correctly they are:

$ strace -f -s512 gcc -flto a.o main.o -o mybinary --save-temps 2>&1 | grep execv | grep ltrans
[pid 11343] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", "-fno-openmp", "-fno-openacc", "-fltrans-output-list=mybinary.ltrans.out", "-fwpa", "-fresolution=main.res", "-flinker-output=exec", "@/tmp/ccofC8gO"], 0x7fffffffd940 /* 105 vars */ <unfinished ...>
[pid 11345] execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", "mybinary.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/cc8GLrIR", "-o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */ <unfinished ...>
[pid 11346] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 11346] execve("/home/marxin/bin/as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 11346] execve("/usr/local/bin/as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */) = -1 ENOENT (No such file or directory)
[pid 11346] execve("/usr/bin/as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */ <unfinished ...>

Martin

> 
> Richard.
> 
>> Martin
>>
>>>
>>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>>
>>>> Ready to be installed?
>>>
>>> OK if the above is correct.
>>>
>>> Thanks,
>>> Richard.
>>>
>>>> Martin
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>> 2018-07-26  Martin Liska  <mliska@suse.cz>
>>>>
>>>>         PR lto/86548
>>>>         * lto-wrapper.c: Add linker_output as prefix
>>>>         for ltrans_output_file.
>>>>
>>>> include/ChangeLog:
>>>>
>>>> 2018-07-26  Martin Liska  <mliska@suse.cz>
>>>>
>>>>         PR lto/86548
>>>>         * libiberty.h (make_temp_file_with_prefix): New function.
>>>>
>>>> libiberty/ChangeLog:
>>>>
>>>> 2018-07-26  Martin Liska  <mliska@suse.cz>
>>>>
>>>>         PR lto/86548
>>>>         * make-temp-file.c (TEMP_FILE): Remove leading 'cc'.
>>>>         (make_temp_file): Call make_temp_file_with_prefix with
>>>>         first argument set to NULL.
>>>>         (make_temp_file_with_prefix): Support also prefix.
>>>> ---
>>>>  gcc/lto-wrapper.c          | 14 +++++++++++++-
>>>>  include/libiberty.h        |  5 +++++
>>>>  libiberty/make-temp-file.c | 24 ++++++++++++++++++------
>>>>  3 files changed, 36 insertions(+), 7 deletions(-)
>>>>
>>>>
>>

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

end of thread, other threads:[~2018-07-26 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 10:55 [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548) Martin Liška
2018-07-26 11:35 ` Richard Biener
2018-07-26 12:12   ` Martin Liška
2018-07-26 12:27     ` Richard Biener
2018-07-26 13:53       ` Martin Liška

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