Commit b1b07c92 by Richard Guenther Committed by Richard Biener

re PR driver/41637 (testsuite (-flto/-fwhopr) leaves does not clean up in /tmp)

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.

From-SVN: r152588
parent 9f3f7d13
2009-10-09 Richard Guenther <rguenther@suse.de> 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.
2009-10-09 Richard Guenther <rguenther@suse.de>
* cgraph.c (cgraph_create_edge): Check for NULL call_stmt * cgraph.c (cgraph_create_edge): Check for NULL call_stmt
before calling stmt_can_throw_external. before calling stmt_can_throw_external.
...@@ -806,10 +806,6 @@ extern void lto_check_version (int, int); ...@@ -806,10 +806,6 @@ extern void lto_check_version (int, int);
/* In lto-streamer-in.c */ /* 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_input_cgraph (struct lto_file_decl_data *, const char *);
extern void lto_init_reader (void); extern void lto_init_reader (void);
extern tree lto_input_tree (struct lto_input_block *, struct data_in *); extern tree lto_input_tree (struct lto_input_block *, struct data_in *);
......
...@@ -55,6 +55,26 @@ enum lto_mode_d { ...@@ -55,6 +55,26 @@ enum lto_mode_d {
/* Current LTO mode. */ /* Current LTO mode. */
static enum lto_mode_d lto_mode = LTO_MODE_NONE; 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. */ /* Just die. CMSGID is the error message. */
static void __attribute__ ((format (printf, 1, 2))) static void __attribute__ ((format (printf, 1, 2)))
...@@ -68,7 +88,7 @@ fatal (const char * cmsgid, ...) ...@@ -68,7 +88,7 @@ fatal (const char * cmsgid, ...)
fprintf (stderr, "\n"); fprintf (stderr, "\n");
va_end (ap); va_end (ap);
exit (FATAL_EXIT_CODE); lto_wrapper_exit (FATAL_EXIT_CODE);
} }
...@@ -86,7 +106,7 @@ fatal_perror (const char *cmsgid, ...) ...@@ -86,7 +106,7 @@ fatal_perror (const char *cmsgid, ...)
fprintf (stderr, ": %s\n", xstrerror (e)); fprintf (stderr, ": %s\n", xstrerror (e));
va_end (ap); va_end (ap);
exit (FATAL_EXIT_CODE); lto_wrapper_exit (FATAL_EXIT_CODE);
} }
...@@ -190,11 +210,13 @@ fork_execute (char **argv) ...@@ -190,11 +210,13 @@ fork_execute (char **argv)
{ {
struct pex_obj *pex; struct pex_obj *pex;
char *new_argv[3]; char *new_argv[3];
char *args_name = make_temp_file (".args"); char *at_args;
char *at_args = concat ("@", args_name, NULL); FILE *args;
FILE *args = fopen (args_name, "w");
int status; int status;
args_name = make_temp_file (".args");
at_args = concat ("@", args_name, NULL);
args = fopen (args_name, "w");
if (args == NULL) if (args == NULL)
fatal ("failed to open %s", args_name); fatal ("failed to open %s", args_name);
...@@ -213,7 +235,6 @@ fork_execute (char **argv) ...@@ -213,7 +235,6 @@ fork_execute (char **argv)
collect_wait (new_argv[0], pex); collect_wait (new_argv[0], pex);
maybe_unlink_file (args_name); maybe_unlink_file (args_name);
free (args_name);
free (at_args); free (at_args);
} }
...@@ -227,8 +248,6 @@ run_gcc (unsigned argc, char *argv[]) ...@@ -227,8 +248,6 @@ run_gcc (unsigned argc, char *argv[])
unsigned new_argc = argc; unsigned new_argc = argc;
const char **new_argv; const char **new_argv;
const char **argv_ptr; const char **argv_ptr;
char *ltrans_output_file = NULL;
char *flto_out = NULL;
char *list_option_full = NULL; char *list_option_full = NULL;
new_argc += 8; new_argc += 8;
...@@ -320,7 +339,6 @@ run_gcc (unsigned argc, char *argv[]) ...@@ -320,7 +339,6 @@ run_gcc (unsigned argc, char *argv[])
putc (c, stdout); putc (c, stdout);
fclose (stream); fclose (stream);
maybe_unlink_file (ltrans_output_file); maybe_unlink_file (ltrans_output_file);
free (ltrans_output_file);
free (list_option_full); free (list_option_full);
} }
else else
......
2009-10-09 Richard Guenther <rguenther@suse.de>
PR lto/41635
PR lto/41636
* 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.
2009-10-08 Joseph Myers <joseph@codesourcery.com> 2009-10-08 Joseph Myers <joseph@codesourcery.com>
* lto-elf.c (init_shdr##BITS, lto_elf_begin_section_with_type, * lto-elf.c (init_shdr##BITS, lto_elf_begin_section_with_type,
......
...@@ -235,7 +235,12 @@ init_shdr##BITS (Elf_Scn *scn, size_t sh_name, size_t sh_type) \ ...@@ -235,7 +235,12 @@ init_shdr##BITS (Elf_Scn *scn, size_t sh_name, size_t sh_type) \
\ \
shdr = elf##BITS##_getshdr (scn); \ shdr = elf##BITS##_getshdr (scn); \
if (!shdr) \ if (!shdr) \
fatal_error ("elf"#BITS"_getshdr() failed: %s", elf_errmsg (-1));\ { \
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_name = sh_name; \
shdr->sh_type = sh_type; \ shdr->sh_type = sh_type; \
...@@ -486,7 +491,12 @@ init_ehdr##BITS (lto_elf_file *elf_file) \ ...@@ -486,7 +491,12 @@ init_ehdr##BITS (lto_elf_file *elf_file) \
\ \
ehdr = elf##BITS##_newehdr (elf_file->elf); \ ehdr = elf##BITS##_newehdr (elf_file->elf); \
if (!ehdr) \ if (!ehdr) \
fatal_error ("elf"#BITS"_newehdr() failed: %s", elf_errmsg (-1));\ { \
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, \ memcpy (ehdr->e_ident, cached_file_attrs.elf_ident, \
sizeof cached_file_attrs.elf_ident); \ sizeof cached_file_attrs.elf_ident); \
......
...@@ -1779,7 +1779,10 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) ...@@ -1779,7 +1779,10 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
unsigned num_objects; unsigned num_objects;
resolution = fopen (resolution_file_name, "r"); resolution = fopen (resolution_file_name, "r");
gcc_assert (resolution != NULL); if (resolution == NULL)
fatal_error ("could not open symbol resolution file: %s",
xstrerror (errno));
t = fscanf (resolution, "%u", &num_objects); t = fscanf (resolution, "%u", &num_objects);
gcc_assert (t == 1); gcc_assert (t == 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment