This is the mail archive of the gcc-patches@gcc.gnu.org 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][LTO] Fix a couple of post-merge review bits


Bootstrapped on x86_64-unknown-linux-gnu, ok?

Thanks,
Richard.

2009-10-09  Richard Guenther  <rguenther@suse.de>

	PR driver/41637
	* lto-wrapper.c (ltrans_output_file, flto_out, args_name): New
	globals.
	(lto_wrapper_exit): New function.
	(fatal): Use it.
	(fatal_perror): Likewise.
	(fork_execute): Use global args_name, do not free it.
	(run_gcc): Use global ltrans_output_file, flto_out, do not free them.
	* lto-streamer.h: Remove duplicate prototypes.

	PR lto/41635
	PR lto/41636
	lto/
	* lto.c (read_cgraph_and_symbols): Do not assert we can open
	a file.
	* lto-elf.c (init_shdr##BITS): Fix i18n problems.
	(init_ehdr##BITS): Likewise.

Index: gcc/lto-wrapper.c
===================================================================
*** gcc/lto-wrapper.c	(revision 152584)
--- gcc/lto-wrapper.c	(working copy)
*************** enum lto_mode_d {
*** 55,60 ****
--- 55,80 ----
  /* Current LTO mode.  */
  static enum lto_mode_d lto_mode = LTO_MODE_NONE;
  
+ static char *ltrans_output_file;
+ static char *flto_out;
+ static char *args_name;
+ 
+ static void maybe_unlink_file (const char *);
+ 
+ /* Delete tempfiles and exit function.  */
+ 
+ static void
+ lto_wrapper_exit (int status)
+ {
+   if (ltrans_output_file)
+     maybe_unlink_file (ltrans_output_file);
+   if (flto_out)
+     maybe_unlink_file (flto_out);
+   if (args_name)
+     maybe_unlink_file (args_name);
+   exit (status);
+ }
+ 
  /* Just die. CMSGID is the error message. */
  
  static void __attribute__ ((format (printf, 1, 2)))
*************** fatal (const char * cmsgid, ...)
*** 68,74 ****
    fprintf (stderr, "\n");
    va_end (ap);
  
!   exit (FATAL_EXIT_CODE);
  }
  
  
--- 88,94 ----
    fprintf (stderr, "\n");
    va_end (ap);
  
!   lto_wrapper_exit (FATAL_EXIT_CODE);
  }
  
  
*************** fatal_perror (const char *cmsgid, ...)
*** 86,92 ****
    fprintf (stderr, ": %s\n", xstrerror (e));
    va_end (ap);
  
!   exit (FATAL_EXIT_CODE);
  }
  
  
--- 106,112 ----
    fprintf (stderr, ": %s\n", xstrerror (e));
    va_end (ap);
  
!   lto_wrapper_exit (FATAL_EXIT_CODE);
  }
  
  
*************** fork_execute (char **argv)
*** 190,200 ****
  {
    struct pex_obj *pex;
    char *new_argv[3];
!   char *args_name = make_temp_file (".args");
!   char *at_args = concat ("@", args_name, NULL);
!   FILE *args = fopen (args_name, "w");
    int status;
  
    if (args == NULL)
      fatal ("failed to open %s", args_name);
  
--- 210,222 ----
  {
    struct pex_obj *pex;
    char *new_argv[3];
!   char *at_args;
!   FILE *args;
    int status;
  
+   args_name = make_temp_file (".args");
+   at_args = concat ("@", args_name, NULL);
+   args = fopen (args_name, "w");
    if (args == NULL)
      fatal ("failed to open %s", args_name);
  
*************** fork_execute (char **argv)
*** 213,219 ****
    collect_wait (new_argv[0], pex);
  
    maybe_unlink_file (args_name);
-   free (args_name);
    free (at_args);
  }
  
--- 235,240 ----
*************** run_gcc (unsigned argc, char *argv[])
*** 227,234 ****
    unsigned new_argc = argc;
    const char **new_argv;
    const char **argv_ptr;
-   char *ltrans_output_file = NULL;
-   char *flto_out = NULL;
    char *list_option_full = NULL;
  
    new_argc += 8;
--- 248,253 ----
*************** run_gcc (unsigned argc, char *argv[])
*** 320,326 ****
  	putc (c, stdout);
        fclose (stream);
        maybe_unlink_file (ltrans_output_file);
-       free (ltrans_output_file);
        free (list_option_full);
      }
    else
--- 339,344 ----
Index: gcc/lto/lto.c
===================================================================
*** gcc/lto/lto.c	(revision 152584)
--- gcc/lto/lto.c	(working copy)
*************** read_cgraph_and_symbols (unsigned nfiles
*** 1779,1785 ****
        unsigned num_objects;
  
        resolution = fopen (resolution_file_name, "r");
!       gcc_assert (resolution != NULL);
        t = fscanf (resolution, "%u", &num_objects);
        gcc_assert (t == 1);
  
--- 1779,1788 ----
        unsigned num_objects;
  
        resolution = fopen (resolution_file_name, "r");
!       if (resolution == NULL)
! 	fatal_error ("could not open symbol resolution file: %s",
! 		     xstrerror (errno));
! 
        t = fscanf (resolution, "%u", &num_objects);
        gcc_assert (t == 1);
  
Index: gcc/lto/lto-elf.c
===================================================================
*** gcc/lto/lto-elf.c	(revision 152584)
--- gcc/lto/lto-elf.c	(working copy)
*************** init_shdr##BITS (Elf_Scn *scn, size_t sh
*** 235,241 ****
  								      \
    shdr = elf##BITS##_getshdr (scn);				      \
    if (!shdr)							      \
!     fatal_error ("elf"#BITS"_getshdr() failed: %s", elf_errmsg (-1));\
  								      \
    shdr->sh_name = sh_name;					      \
    shdr->sh_type = sh_type;					      \
--- 235,246 ----
  								      \
    shdr = elf##BITS##_getshdr (scn);				      \
    if (!shdr)							      \
!     {								      \
!       if (BITS == 32)						      \
! 	fatal_error ("elf32_getshdr() failed: %s", elf_errmsg (-1));  \
!       else							      \
! 	fatal_error ("elf64_getshdr() failed: %s", elf_errmsg (-1));  \
!     }								      \
  								      \
    shdr->sh_name = sh_name;					      \
    shdr->sh_type = sh_type;					      \
*************** init_ehdr##BITS (lto_elf_file *elf_file)
*** 486,492 ****
  								      \
    ehdr = elf##BITS##_newehdr (elf_file->elf);			      \
    if (!ehdr)							      \
!     fatal_error ("elf"#BITS"_newehdr() failed: %s", elf_errmsg (-1));\
  								      \
    memcpy (ehdr->e_ident, cached_file_attrs.elf_ident,		      \
  	  sizeof cached_file_attrs.elf_ident);			      \
--- 491,502 ----
  								      \
    ehdr = elf##BITS##_newehdr (elf_file->elf);			      \
    if (!ehdr)							      \
!     {								      \
!       if (BITS == 32)						      \
! 	fatal_error ("elf32_newehdr() failed: %s", elf_errmsg (-1));  \
!       else							      \
! 	fatal_error ("elf64_newehdr() failed: %s", elf_errmsg (-1));  \
!     }								      \
  								      \
    memcpy (ehdr->e_ident, cached_file_attrs.elf_ident,		      \
  	  sizeof cached_file_attrs.elf_ident);			      \
Index: gcc/lto-streamer.h
===================================================================
*** gcc/lto-streamer.h	(revision 152584)
--- gcc/lto-streamer.h	(working copy)
*************** extern void lto_check_version (int, int)
*** 806,815 ****
  
  
  /* In lto-streamer-in.c */
- extern void lto_input_function_body (struct lto_file_decl_data *, tree,
- 				     const char *);
- extern void lto_input_constructors_and_inits (struct lto_file_decl_data *,
- 					      const char *);
  extern void lto_input_cgraph (struct lto_file_decl_data *, const char *);
  extern void lto_init_reader (void);
  extern tree lto_input_tree (struct lto_input_block *, struct data_in *);
--- 806,811 ----


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