diff options
author | Ian Lance Taylor <ian@airs.com> | 2005-03-31 14:53:17 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2005-03-31 14:53:17 +0000 |
commit | 68ec3111c0ff30d2dc2f172897379cc891ae180d (patch) | |
tree | e6f523f2e9436b46ac2af93fec13e0d9253901a7 /gcc | |
parent | 0992247bffbe06f3bab081ca27fa3699950a28f8 (diff) | |
download | gcc-68ec3111c0ff30d2dc2f172897379cc891ae180d.zip gcc-68ec3111c0ff30d2dc2f172897379cc891ae180d.tar.gz gcc-68ec3111c0ff30d2dc2f172897379cc891ae180d.tar.bz2 |
collect2.c (lderrout): New variable.
* collect2.c (lderrout): New variable.
(collect_exit): Dump ldout to stdout. Dump and unlink lderrout,
if it is set, to stderr.
(handler): Unlink lderrout if it is set.
(dump_file): Add "to" parameter. Change all callers.
(main): Initialize lderrout.
(collect_execute): Add errname parameter. Change all callers.
Rename redir parameter to outname. Never pass
PEX_STDERR_TO_STDOUT to pex_run.
* collect2.h (collect_execute, dump_file): Update declarations.
* tlink.c (tlink_execute): Add errname parameter. Change all
callers.
(do_tlink): Check lderrout as well as ldout.
From-SVN: r97321
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/collect2.c | 40 | ||||
-rw-r--r-- | gcc/collect2.h | 6 | ||||
-rw-r--r-- | gcc/tlink.c | 25 |
4 files changed, 61 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5468303..c651077 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2005-03-31 Ian Lance Taylor <ian@airs.com> + + * collect2.c (lderrout): New variable. + (collect_exit): Dump ldout to stdout. Dump and unlink lderrout, + if it is set, to stderr. + (handler): Unlink lderrout if it is set. + (dump_file): Add "to" parameter. Change all callers. + (main): Initialize lderrout. + (collect_execute): Add errname parameter. Change all callers. + Rename redir parameter to outname. Never pass + PEX_STDERR_TO_STDOUT to pex_run. + * collect2.h (collect_execute, dump_file): Update declarations. + * tlink.c (tlink_execute): Add errname parameter. Change all + callers. + (do_tlink): Check lderrout as well as ldout. + 2005-03-31 Olivier Hainque <hainque@adacore.com> * dwarf2out.c (dwarf2out_frame_finish): Honor DWARF2_FRAME_INFO diff --git a/gcc/collect2.c b/gcc/collect2.c index 063cb9f..f95fe4d 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -184,7 +184,8 @@ static const char *o_file; /* <xxx>.o for constructor/destructor list. */ #ifdef COLLECT_EXPORT_LIST static const char *export_file; /* <xxx>.x for AIX export list. */ #endif -const char *ldout; /* File for ld errors. */ +const char *ldout; /* File for ld stdout. */ +const char *lderrout; /* File for ld stderr. */ static const char *output_file; /* Output file for ld. */ static const char *nm_file_name; /* pathname of nm */ #ifdef LDD_SUFFIX @@ -308,10 +309,16 @@ collect_exit (int status) if (ldout != 0 && ldout[0]) { - dump_file (ldout); + dump_file (ldout, stdout); maybe_unlink (ldout); } + if (lderrout != 0 && lderrout[0]) + { + dump_file (lderrout, stderr); + maybe_unlink (lderrout); + } + if (status != 0 && output_file != 0 && output_file[0]) maybe_unlink (output_file); @@ -398,6 +405,9 @@ handler (int signo) if (ldout != 0 && ldout[0]) maybe_unlink (ldout); + if (lderrout != 0 && lderrout[0]) + maybe_unlink (lderrout); + #ifdef COLLECT_EXPORT_LIST if (export_file != 0 && export_file[0]) maybe_unlink (export_file); @@ -447,7 +457,7 @@ extract_string (const char **pp) } void -dump_file (const char *name) +dump_file (const char *name, FILE *to) { FILE *stream = fopen (name, "r"); @@ -467,7 +477,7 @@ dump_file (const char *name) word = obstack_finish (&temporary_obstack); if (*word == '.') - ++word, putc ('.', stderr); + ++word, putc ('.', to); p = word; if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX))) p += strlen (USER_LABEL_PREFIX); @@ -484,25 +494,25 @@ dump_file (const char *name) if (result) { int diff; - fputs (result, stderr); + fputs (result, to); diff = strlen (word) - strlen (result); while (diff > 0 && c == ' ') - --diff, putc (' ', stderr); + --diff, putc (' ', to); while (diff < 0 && c == ' ') ++diff, c = getc (stream); free (result); } else - fputs (word, stderr); + fputs (word, to); - fflush (stderr); + fflush (to); obstack_free (&temporary_obstack, temporary_firstobj); } if (c == EOF) break; - putc (c, stderr); + putc (c, to); } fclose (stream); } @@ -990,6 +1000,7 @@ main (int argc, char **argv) export_file = make_temp_file (".x"); #endif ldout = make_temp_file (".ld"); + lderrout = make_temp_file (".le"); *c_ptr++ = c_file_name; *c_ptr++ = "-x"; *c_ptr++ = "c"; @@ -1525,7 +1536,8 @@ do_wait (const char *prog, struct pex_obj *pex) /* Execute a program, and wait for the reply. */ struct pex_obj * -collect_execute (const char *prog, char **argv, const char *redir) +collect_execute (const char *prog, char **argv, const char *outname, + const char *errname) { struct pex_obj *pex; const char *errmsg; @@ -1560,10 +1572,8 @@ collect_execute (const char *prog, char **argv, const char *redir) if (pex == NULL) fatal_perror ("pex_init failed"); - errmsg = pex_run (pex, - (PEX_LAST | PEX_SEARCH - | (redir ? PEX_STDERR_TO_STDOUT : 0)), - argv[0], argv, redir, NULL, &err); + errmsg = pex_run (pex, PEX_LAST | PEX_SEARCH, argv[0], argv, outname, + errname, &err); if (errmsg != NULL) { if (err != 0) @@ -1583,7 +1593,7 @@ fork_execute (const char *prog, char **argv) { struct pex_obj *pex; - pex = collect_execute (prog, argv, NULL); + pex = collect_execute (prog, argv, NULL, NULL); do_wait (prog, pex); } diff --git a/gcc/collect2.h b/gcc/collect2.h index 9eabc63..7a8f51c 100644 --- a/gcc/collect2.h +++ b/gcc/collect2.h @@ -23,17 +23,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA extern void do_tlink (char **, char **); -extern struct pex_obj *collect_execute (const char *, char **, const char *); +extern struct pex_obj *collect_execute (const char *, char **, const char *, + const char *); extern void collect_exit (int) ATTRIBUTE_NORETURN; extern int collect_wait (const char *, struct pex_obj *); -extern void dump_file (const char *); +extern void dump_file (const char *, FILE *); extern int file_exists (const char *); extern const char *ldout; +extern const char *lderrout; extern const char *c_file_name; extern struct obstack temporary_obstack; extern char *temporary_firstobj; diff --git a/gcc/tlink.c b/gcc/tlink.c index 3fe531a..44e516b 100644 --- a/gcc/tlink.c +++ b/gcc/tlink.c @@ -98,7 +98,7 @@ static symbol * symbol_pop (void); static void file_push (file *); static file * file_pop (void); static void tlink_init (void); -static int tlink_execute (const char *, char **, const char *); +static int tlink_execute (const char *, char **, const char *, const char *); static char * frob_extension (const char *, const char *); static char * obstack_fgets (FILE *, struct obstack *); static char * tfgets (FILE *); @@ -279,11 +279,12 @@ tlink_init (void) } static int -tlink_execute (const char *prog, char **argv, const char *redir) +tlink_execute (const char *prog, char **argv, const char *outname, + const char *errname) { struct pex_obj *pex; - pex = collect_execute (prog, argv, redir); + pex = collect_execute (prog, argv, outname, errname); return collect_wait (prog, pex); } @@ -533,7 +534,7 @@ recompile_files (void) fprintf (stderr, _("collect: recompiling %s\n"), f->main); if (chdir (f->dir) != 0 - || tlink_execute (c_file_name, argv, NULL) != 0 + || tlink_execute (c_file_name, argv, NULL, NULL) != 0 || chdir (initial_cwd) != 0) return 0; @@ -735,7 +736,7 @@ scan_linker_output (const char *fname) void do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED) { - int exit = tlink_execute ("ld", ld_argv, ldout); + int exit = tlink_execute ("ld", ld_argv, ldout, lderrout); tlink_init (); @@ -749,20 +750,26 @@ do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED) while (exit && i++ < MAX_ITERATIONS) { if (tlink_verbose >= 3) - dump_file (ldout); + { + dump_file (ldout, stdout); + dump_file (lderrout, stderr); + } demangle_new_symbols (); - if (! scan_linker_output (ldout)) + if (! scan_linker_output (ldout) + && ! scan_linker_output (lderrout)) break; if (! recompile_files ()) break; if (tlink_verbose) fprintf (stderr, _("collect: relinking\n")); - exit = tlink_execute ("ld", ld_argv, ldout); + exit = tlink_execute ("ld", ld_argv, ldout, lderrout); } } - dump_file (ldout); + dump_file (ldout, stdout); unlink (ldout); + dump_file (lderrout, stderr); + unlink (lderrout); if (exit) { error ("ld returned %d exit status", exit); |