]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add linker_output as prefix for LTO temps (PR lto/86548).
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Jul 2018 12:13:14 +0000 (12:13 +0000)
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Jul 2018 12:13:14 +0000 (12:13 +0000)
2018-07-26  Martin Liska  <mliska@suse.cz>

        PR lto/86548
* lto-wrapper.c: Add linker_output as prefix
        for ltrans_output_file.
2018-07-26  Martin Liska  <mliska@suse.cz>

        PR lto/86548
* libiberty.h (make_temp_file_with_prefix): New function.
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262999 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/lto-wrapper.c
include/ChangeLog
include/libiberty.h
libiberty/ChangeLog
libiberty/make-temp-file.c

index 3518ecfc376b8927f5ab84ea56c9527403df33e1..d9e8e1083312e964355e36b76284ed0c22d32376 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-26  Martin Liska  <mliska@suse.cz>
+
+        PR lto/86548
+       * lto-wrapper.c: Add linker_output as prefix
+        for ltrans_output_file.
+
 2018-07-26  Segher Boessenkool  <segher@kernel.crashing.org>
 
        PR rtl-optimization/85805
index c3eb00dc0c2dc9e3dadf37569accb1213d1b9a52..cf4a8c659e08bbc58dda2050152d1ff421c9f42f 100644 (file)
@@ -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;
index 7a8022b67c094b706f23341399623c4cd3ac5e1e..6d04fa14a677aad494f8ce51cc542564b184fc7b 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-26  Martin Liska  <mliska@suse.cz>
+
+        PR lto/86548
+       * libiberty.h (make_temp_file_with_prefix): New function.
+
 2018-05-30  Jan Hubicka  <hubicka@ucw.cz>
 
        * simple-object.h (simple_object_copy_lto_debug_sections): Add rename
index dc09e791e415e242d0ed00f5ad9afd866a376665..0823614c00e1ff8a0700349d0331afecc1ff3dee 100644 (file)
@@ -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 *);
index 398d0306d8c4e4879719ce258ac0a60063d2a83a..dc5d9971f68e0c5a7339aefe856c8a29161768d0 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 2018-07-19  Eli Zaretskii  <eliz@gnu.org>
 
        * simple-object-elf.c (ENOTSUP): If not defined by errno.h, redirect
index 89faed7f09ec53bdddb62d97bf14cf08e0d4e533..21b0545754245e5371ed4e5758b0b7870861a002 100644 (file)
@@ -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);
+}