Commit d6b5203d authored by ian's avatar ian
Browse files

* 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
parent 24cf2fd3
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> 2005-03-31 Olivier Hainque <hainque@adacore.com>
* dwarf2out.c (dwarf2out_frame_finish): Honor DWARF2_FRAME_INFO * dwarf2out.c (dwarf2out_frame_finish): Honor DWARF2_FRAME_INFO
......
...@@ -184,7 +184,8 @@ static const char *o_file; /* <xxx>.o for constructor/destructor list. */ ...@@ -184,7 +184,8 @@ static const char *o_file; /* <xxx>.o for constructor/destructor list. */
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
static const char *export_file; /* <xxx>.x for AIX export list. */ static const char *export_file; /* <xxx>.x for AIX export list. */
#endif #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 *output_file; /* Output file for ld. */
static const char *nm_file_name; /* pathname of nm */ static const char *nm_file_name; /* pathname of nm */
#ifdef LDD_SUFFIX #ifdef LDD_SUFFIX
...@@ -308,10 +309,16 @@ collect_exit (int status) ...@@ -308,10 +309,16 @@ collect_exit (int status)
if (ldout != 0 && ldout[0]) if (ldout != 0 && ldout[0])
{ {
dump_file (ldout); dump_file (ldout, stdout);
maybe_unlink (ldout); maybe_unlink (ldout);
} }
if (lderrout != 0 && lderrout[0])
{
dump_file (lderrout, stderr);
maybe_unlink (lderrout);
}
if (status != 0 && output_file != 0 && output_file[0]) if (status != 0 && output_file != 0 && output_file[0])
maybe_unlink (output_file); maybe_unlink (output_file);
...@@ -398,6 +405,9 @@ handler (int signo) ...@@ -398,6 +405,9 @@ handler (int signo)
if (ldout != 0 && ldout[0]) if (ldout != 0 && ldout[0])
maybe_unlink (ldout); maybe_unlink (ldout);
if (lderrout != 0 && lderrout[0])
maybe_unlink (lderrout);
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
if (export_file != 0 && export_file[0]) if (export_file != 0 && export_file[0])
maybe_unlink (export_file); maybe_unlink (export_file);
...@@ -447,7 +457,7 @@ extract_string (const char **pp) ...@@ -447,7 +457,7 @@ extract_string (const char **pp)
} }
void void
dump_file (const char *name) dump_file (const char *name, FILE *to)
{ {
FILE *stream = fopen (name, "r"); FILE *stream = fopen (name, "r");
...@@ -467,7 +477,7 @@ dump_file (const char *name) ...@@ -467,7 +477,7 @@ dump_file (const char *name)
word = obstack_finish (&temporary_obstack); word = obstack_finish (&temporary_obstack);
if (*word == '.') if (*word == '.')
++word, putc ('.', stderr); ++word, putc ('.', to);
p = word; p = word;
if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX))) if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)))
p += strlen (USER_LABEL_PREFIX); p += strlen (USER_LABEL_PREFIX);
...@@ -484,25 +494,25 @@ dump_file (const char *name) ...@@ -484,25 +494,25 @@ dump_file (const char *name)
if (result) if (result)
{ {
int diff; int diff;
fputs (result, stderr); fputs (result, to);
diff = strlen (word) - strlen (result); diff = strlen (word) - strlen (result);
while (diff > 0 && c == ' ') while (diff > 0 && c == ' ')
--diff, putc (' ', stderr); --diff, putc (' ', to);
while (diff < 0 && c == ' ') while (diff < 0 && c == ' ')
++diff, c = getc (stream); ++diff, c = getc (stream);
free (result); free (result);
} }
else else
fputs (word, stderr); fputs (word, to);
fflush (stderr); fflush (to);
obstack_free (&temporary_obstack, temporary_firstobj); obstack_free (&temporary_obstack, temporary_firstobj);
} }
if (c == EOF) if (c == EOF)
break; break;
putc (c, stderr); putc (c, to);
} }
fclose (stream); fclose (stream);
} }
...@@ -990,6 +1000,7 @@ main (int argc, char **argv) ...@@ -990,6 +1000,7 @@ main (int argc, char **argv)
export_file = make_temp_file (".x"); export_file = make_temp_file (".x");
#endif #endif
ldout = make_temp_file (".ld"); ldout = make_temp_file (".ld");
lderrout = make_temp_file (".le");
*c_ptr++ = c_file_name; *c_ptr++ = c_file_name;
*c_ptr++ = "-x"; *c_ptr++ = "-x";
*c_ptr++ = "c"; *c_ptr++ = "c";
...@@ -1525,7 +1536,8 @@ do_wait (const char *prog, struct pex_obj *pex) ...@@ -1525,7 +1536,8 @@ do_wait (const char *prog, struct pex_obj *pex)
/* Execute a program, and wait for the reply. */ /* Execute a program, and wait for the reply. */
struct pex_obj * 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; struct pex_obj *pex;
const char *errmsg; const char *errmsg;
...@@ -1560,10 +1572,8 @@ collect_execute (const char *prog, char **argv, const char *redir) ...@@ -1560,10 +1572,8 @@ collect_execute (const char *prog, char **argv, const char *redir)
if (pex == NULL) if (pex == NULL)
fatal_perror ("pex_init failed"); fatal_perror ("pex_init failed");
errmsg = pex_run (pex, errmsg = pex_run (pex, PEX_LAST | PEX_SEARCH, argv[0], argv, outname,
(PEX_LAST | PEX_SEARCH errname, &err);
| (redir ? PEX_STDERR_TO_STDOUT : 0)),
argv[0], argv, redir, NULL, &err);
if (errmsg != NULL) if (errmsg != NULL)
{ {
if (err != 0) if (err != 0)
...@@ -1583,7 +1593,7 @@ fork_execute (const char *prog, char **argv) ...@@ -1583,7 +1593,7 @@ fork_execute (const char *prog, char **argv)
{ {
struct pex_obj *pex; struct pex_obj *pex;
pex = collect_execute (prog, argv, NULL); pex = collect_execute (prog, argv, NULL, NULL);
do_wait (prog, pex); do_wait (prog, pex);
} }
......
...@@ -23,17 +23,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -23,17 +23,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
extern void do_tlink (char **, char **); 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 void collect_exit (int) ATTRIBUTE_NORETURN;
extern int collect_wait (const char *, struct pex_obj *); 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 int file_exists (const char *);
extern const char *ldout; extern const char *ldout;
extern const char *lderrout;
extern const char *c_file_name; extern const char *c_file_name;
extern struct obstack temporary_obstack; extern struct obstack temporary_obstack;
extern char *temporary_firstobj; extern char *temporary_firstobj;
......
...@@ -98,7 +98,7 @@ static symbol * symbol_pop (void); ...@@ -98,7 +98,7 @@ static symbol * symbol_pop (void);
static void file_push (file *); static void file_push (file *);
static file * file_pop (void); static file * file_pop (void);
static void tlink_init (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 * frob_extension (const char *, const char *);
static char * obstack_fgets (FILE *, struct obstack *); static char * obstack_fgets (FILE *, struct obstack *);
static char * tfgets (FILE *); static char * tfgets (FILE *);
...@@ -279,11 +279,12 @@ tlink_init (void) ...@@ -279,11 +279,12 @@ tlink_init (void)
} }
static int 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; struct pex_obj *pex;
pex = collect_execute (prog, argv, redir); pex = collect_execute (prog, argv, outname, errname);
return collect_wait (prog, pex); return collect_wait (prog, pex);
} }
...@@ -533,7 +534,7 @@ recompile_files (void) ...@@ -533,7 +534,7 @@ recompile_files (void)
fprintf (stderr, _("collect: recompiling %s\n"), f->main); fprintf (stderr, _("collect: recompiling %s\n"), f->main);
if (chdir (f->dir) != 0 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) || chdir (initial_cwd) != 0)
return 0; return 0;
...@@ -735,7 +736,7 @@ scan_linker_output (const char *fname) ...@@ -735,7 +736,7 @@ scan_linker_output (const char *fname)
void void
do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED) 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 (); tlink_init ();
...@@ -749,20 +750,26 @@ do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED) ...@@ -749,20 +750,26 @@ do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED)
while (exit && i++ < MAX_ITERATIONS) while (exit && i++ < MAX_ITERATIONS)
{ {
if (tlink_verbose >= 3) if (tlink_verbose >= 3)
dump_file (ldout); {
dump_file (ldout, stdout);
dump_file (lderrout, stderr);
}
demangle_new_symbols (); demangle_new_symbols ();
if (! scan_linker_output (ldout)) if (! scan_linker_output (ldout)
&& ! scan_linker_output (lderrout))
break; break;
if (! recompile_files ()) if (! recompile_files ())
break; break;
if (tlink_verbose) if (tlink_verbose)
fprintf (stderr, _("collect: relinking\n")); 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); unlink (ldout);
dump_file (lderrout, stderr);
unlink (lderrout);
if (exit) if (exit)
{ {
error ("ld returned %d exit status", exit); error ("ld returned %d exit status", exit);
......
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