diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-31 14:53:17 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-31 14:53:17 +0000 |
commit | d6b5203d8dbe5fffec8c3aea15a308aa64faebd5 (patch) | |
tree | e6f523f2e9436b46ac2af93fec13e0d9253901a7 /gcc/collect2.c | |
parent | 24cf2fd3090d7dd5dbd5542437959e01f26d9cac (diff) | |
download | gcc-d6b5203d8dbe5fffec8c3aea15a308aa64faebd5.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97321 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r-- | gcc/collect2.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c index 063cb9fbde1..f95fe4dbbf4 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); } |