* 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
+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
#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
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);
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);
}
\f
void
-dump_file (const char *name)
+dump_file (const char *name, FILE *to)
{
FILE *stream = fopen (name, "r");
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);
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);
}
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";
/* 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;
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)
{
struct pex_obj *pex;
- pex = collect_execute (prog, argv, NULL);
+ pex = collect_execute (prog, argv, NULL, NULL);
do_wait (prog, pex);
}
\f
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;
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 *);
}
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);
}
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;
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 ();
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);