diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-09 13:24:59 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-09 13:24:59 +0000 |
commit | c515f146bfe0899799cbce1a797ca9e8ab86287f (patch) | |
tree | df79584a59c59cc699aebb0953c8a12388d08091 /gcc/lto-wrapper.c | |
parent | 0780673fc12eed6a345e4a1784dc27f7f0d8335f (diff) | |
download | gcc-c515f146bfe0899799cbce1a797ca9e8ab86287f.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152588 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto-wrapper.c')
-rw-r--r-- | gcc/lto-wrapper.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 228a0a4bb10..cddd4156a35 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -55,6 +55,26 @@ enum lto_mode_d { /* 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))) @@ -68,7 +88,7 @@ fatal (const char * cmsgid, ...) fprintf (stderr, "\n"); va_end (ap); - exit (FATAL_EXIT_CODE); + lto_wrapper_exit (FATAL_EXIT_CODE); } @@ -86,7 +106,7 @@ fatal_perror (const char *cmsgid, ...) fprintf (stderr, ": %s\n", xstrerror (e)); va_end (ap); - exit (FATAL_EXIT_CODE); + lto_wrapper_exit (FATAL_EXIT_CODE); } @@ -190,11 +210,13 @@ fork_execute (char **argv) { 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"); + 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); @@ -213,7 +235,6 @@ fork_execute (char **argv) collect_wait (new_argv[0], pex); maybe_unlink_file (args_name); - free (args_name); free (at_args); } @@ -227,8 +248,6 @@ run_gcc (unsigned argc, char *argv[]) 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; @@ -320,7 +339,6 @@ run_gcc (unsigned argc, char *argv[]) putc (c, stdout); fclose (stream); maybe_unlink_file (ltrans_output_file); - free (ltrans_output_file); free (list_option_full); } else |