Commit 5f0ad6a5 by Bernd Schmidt Committed by Bernd Schmidt

Part 2 of the collect-utils library, now also used for collect2.

        * Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
        (LTO_WRAPPER_OBJS): New variable.
        (lto-wrapper$(exeext)): Use it.
        * collect2.c: Include "collect-utils.h".
        (verbose, debug): Remove variables.
        (at_file_supplied): No longer static.
        (tool_name): New variable.
        (do_wait, fork_execute, maybe_unlink): Don't declare.
        (tool_cleanup): No longer static.
        (notice): Remove function.
        (maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
        fork_execute calls.
        (collect_wait, do_wait, collect_execute): Remove functions.
        (maybe_unlink): No longer static.
        * collect2.h (verbose, debug): Don't declare.
        (at_file_supplied): Declare.
        * collect-utils.c (utils_cleanup): New arg from_signal.  All callers
        changed.
        (collect_execute): Replace with implementation from collect2, plus a
        new arg use_atfile.  All callers changed.
        (collect_wait): Replace with implementation from collect2.
        (maybe_unlink_file): Remove function.
        (fork_execute): Replace with implementation from collect2, plus a
        new arg use_atfile.  All callers changed.
        (do_wait): Add call to utils_cleanup to the error path.
        * collect-utils.h (collect_execute, fork_execute, utils_cleanup,
        tool_cleanup): Adjust declarations.
        * lto-wrapper.c (tool_cleanup): Add unused bool argument.
        * tlink.c: Include "collect-utils.h".
        (tlink_execute): New arg use_atfile.  All callers changed.
        (tlink_init, tlink_execute): Remove declarations.

From-SVN: r212020
parent 608508a6
2014-06-26 Bernd Schmidt <bernds@codesourcery.com> 2014-06-26 Bernd Schmidt <bernds@codesourcery.com>
* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
(LTO_WRAPPER_OBJS): New variable.
(lto-wrapper$(exeext)): Use it.
* collect2.c: Include "collect-utils.h".
(verbose, debug): Remove variables.
(at_file_supplied): No longer static.
(tool_name): New variable.
(do_wait, fork_execute, maybe_unlink): Don't declare.
(tool_cleanup): No longer static.
(notice): Remove function.
(maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
fork_execute calls.
(collect_wait, do_wait, collect_execute): Remove functions.
(maybe_unlink): No longer static.
* collect2.h (verbose, debug): Don't declare.
(at_file_supplied): Declare.
* collect-utils.c (utils_cleanup): New arg from_signal. All callers
changed.
(collect_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(collect_wait): Replace with implementation from collect2.
(maybe_unlink_file): Remove function.
(fork_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(do_wait): Add call to utils_cleanup to the error path.
* collect-utils.h (collect_execute, fork_execute, utils_cleanup)
(tool_cleanup): Adjust declarations.
* lto-wrapper.c (tool_cleanup): Add unused bool argument.
* tlink.c: Include "collect-utils.h".
(tlink_execute): New arg use_atfile. All callers changed.
(tlink_init, tlink_execute): Remove declarations.
* collect-utils.c (save_temps): New variable. * collect-utils.c (save_temps): New variable.
(do_wait): Use it instead of debug. Use fatal_error. (do_wait): Use it instead of debug. Use fatal_error.
* collect-utils.h (save_temps): Declare. * collect-utils.h (save_temps): Declare.
......
...@@ -1899,7 +1899,8 @@ gcc-ranlib.c: gcc-ar.c ...@@ -1899,7 +1899,8 @@ gcc-ranlib.c: gcc-ar.c
gcc-nm.c: gcc-ar.c gcc-nm.c: gcc-ar.c
cp $^ $@ cp $^ $@
COLLECT2_OBJS = collect2.o collect2-aix.o tlink.o vec.o ggc-none.o file-find.o COLLECT2_OBJS = collect2.o collect2-aix.o tlink.o vec.o ggc-none.o \
collect-utils.o file-find.o
COLLECT2_LIBS = @COLLECT2_LIBS@ COLLECT2_LIBS = @COLLECT2_LIBS@
collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS) collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
# Don't try modifying collect2 (aka ld) in place--it might be linking this. # Don't try modifying collect2 (aka ld) in place--it might be linking this.
......
...@@ -35,24 +35,6 @@ bool debug; ...@@ -35,24 +35,6 @@ bool debug;
bool verbose; bool verbose;
bool save_temps; bool save_temps;
/* Delete tempfiles. */
void
utils_cleanup (void)
{
static bool cleanup_done = false;
if (cleanup_done)
return;
/* Setting cleanup_done prevents an infinite loop if one of the
calls to maybe_unlink fails. */
cleanup_done = true;
if (response_file)
maybe_unlink (response_file);
tool_cleanup ();
}
/* Notify user of a non-error. */ /* Notify user of a non-error. */
void void
...@@ -69,62 +51,13 @@ void ...@@ -69,62 +51,13 @@ void
fatal_signal (int signum) fatal_signal (int signum)
{ {
signal (signum, SIG_DFL); signal (signum, SIG_DFL);
utils_cleanup (); utils_cleanup (true);
/* Get the same signal again, this time not handled, /* Get the same signal again, this time not handled,
so its normal effect occurs. */ so its normal effect occurs. */
kill (getpid (), signum); kill (getpid (), signum);
} }
/* Execute a program, and wait for the reply. ARGV are the arguments. The /* Wait for a process to finish, and exit if a nonzero status is found. */
last one must be NULL. */
struct pex_obj *
collect_execute (char **argv)
{
struct pex_obj *pex;
const char *errmsg;
int err;
if (verbose)
{
char **p_argv;
const char *str;
for (p_argv = argv; (str = *p_argv) != (char *) 0; p_argv++)
fprintf (stderr, " %s", str);
fprintf (stderr, "\n");
}
fflush (stdout);
fflush (stderr);
pex = pex_init (0, tool_name, NULL);
if (pex == NULL)
fatal_error ("pex_init failed: %m");
/* Do not use PEX_LAST here, we use our stdout for communicating with
collect2 or the linker-plugin. Any output from the sub-process
will confuse that. */
errmsg = pex_run (pex, PEX_SEARCH, argv[0], argv, NULL,
NULL, &err);
if (errmsg != NULL)
{
if (err != 0)
{
errno = err;
fatal_error ("%s: %m", _(errmsg));
}
else
fatal_error (errmsg);
}
return pex;
}
/* Wait for a process to finish, and exit if a nonzero status is found.
PROG is the program name. PEX is the process we should wait for. */
int int
collect_wait (const char *prog, struct pex_obj *pex) collect_wait (const char *prog, struct pex_obj *pex)
...@@ -140,18 +73,14 @@ collect_wait (const char *prog, struct pex_obj *pex) ...@@ -140,18 +73,14 @@ collect_wait (const char *prog, struct pex_obj *pex)
if (WIFSIGNALED (status)) if (WIFSIGNALED (status))
{ {
int sig = WTERMSIG (status); int sig = WTERMSIG (status);
if (WCOREDUMP (status)) fatal_error ("%s terminated with signal %d [%s]%s",
fatal_error ("%s terminated with signal %d [%s], core dumped", prog, sig, strsignal (sig),
prog, sig, strsignal (sig)); WCOREDUMP (status) ? ", core dumped" : "");
else
fatal_error ("%s terminated with signal %d [%s]",
prog, sig, strsignal (sig));
} }
if (WIFEXITED (status)) if (WIFEXITED (status))
fatal_error ("%s returned %d exit status", prog, WEXITSTATUS (status)); return WEXITSTATUS (status);
} }
return 0; return 0;
} }
...@@ -169,52 +98,130 @@ do_wait (const char *prog, struct pex_obj *pex) ...@@ -169,52 +98,130 @@ do_wait (const char *prog, struct pex_obj *pex)
} }
} }
/* Unlink a temporary LTRANS file unless requested otherwise. */
/* Execute a program, and wait for the reply. */
void struct pex_obj *
maybe_unlink_file (const char *file) collect_execute (const char *prog, char **argv, const char *outname,
const char *errname, int flags, bool use_atfile)
{ {
if (!debug) struct pex_obj *pex;
const char *errmsg;
int err;
char *response_arg = NULL;
char *response_argv[3];
if (use_atfile && argv[0] != NULL)
{ {
if (unlink_if_ordinary (file) /* If using @file arguments, create a temporary file and put the
&& errno != ENOENT) contents of argv into it. Then change argv to an array corresponding
fatal_error ("deleting file %s: %m", file); to a single argument @FILE, where FILE is the temporary filename. */
char **current_argv = argv + 1;
char *argv0 = argv[0];
int status;
FILE *f;
/* Note: we assume argv contains at least one element; this is
checked above. */
response_file = make_temp_file ("");
f = fopen (response_file, "w");
if (f == NULL)
fatal_error ("could not open response file %s", response_file);
status = writeargv (current_argv, f);
if (status)
fatal_error ("could not write to response file %s", response_file);
status = fclose (f);
if (EOF == status)
fatal_error ("could not close response file %s", response_file);
response_arg = concat ("@", response_file, NULL);
response_argv[0] = argv0;
response_argv[1] = response_arg;
response_argv[2] = NULL;
argv = response_argv;
} }
else
fprintf (stderr, "[Leaving %s]\n", file);
}
if (verbose || debug)
{
char **p_argv;
const char *str;
if (argv[0])
fprintf (stderr, "%s", argv[0]);
else
notice ("[cannot find %s]", prog);
for (p_argv = &argv[1]; (str = *p_argv) != (char *) 0; p_argv++)
fprintf (stderr, " %s", str);
fprintf (stderr, "\n");
}
fflush (stdout);
fflush (stderr);
/* If we cannot find a program we need, complain error. Do this here
since we might not end up needing something that we could not find. */
if (argv[0] == 0)
fatal_error ("cannot find '%s'", prog);
pex = pex_init (0, "collect2", NULL);
if (pex == NULL)
fatal_error ("pex_init failed: %m");
errmsg = pex_run (pex, flags, argv[0], argv, outname,
errname, &err);
if (errmsg != NULL)
{
if (err != 0)
{
errno = err;
fatal_error ("%s: %m", _(errmsg));
}
else
fatal_error (errmsg);
}
/* Execute program ARGV[0] with arguments ARGV. Wait for it to finish. */ free (response_arg);
return pex;
}
void void
fork_execute (char **argv) fork_execute (const char *prog, char **argv, bool use_atfile)
{ {
struct pex_obj *pex; struct pex_obj *pex;
char *new_argv[3];
char *at_args;
FILE *args;
int status;
response_file = make_temp_file (".args");
at_args = concat ("@", response_file, NULL);
args = fopen (response_file, "w");
if (args == NULL)
fatal_error ("failed to open %s", response_file);
status = writeargv (&argv[1], args); pex = collect_execute (prog, argv, NULL, NULL,
PEX_LAST | PEX_SEARCH, use_atfile);
do_wait (prog, pex);
}
if (status) /* Delete tempfiles. */
fatal_error ("could not write to temporary file %s", response_file);
fclose (args); void
utils_cleanup (bool from_signal)
{
static bool cleanup_done = false;
new_argv[0] = argv[0]; if (cleanup_done)
new_argv[1] = at_args; return;
new_argv[2] = NULL;
pex = collect_execute (new_argv); /* Setting cleanup_done prevents an infinite loop if one of the
do_wait (new_argv[0], pex); calls to maybe_unlink fails. */
cleanup_done = true;
free (at_args); if (response_file)
maybe_unlink (response_file);
tool_cleanup (from_signal);
} }
...@@ -22,11 +22,14 @@ extern void notice (const char *, ...) ...@@ -22,11 +22,14 @@ extern void notice (const char *, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));
extern void fatal_signal (int); extern void fatal_signal (int);
extern struct pex_obj *collect_execute (char **); extern struct pex_obj *collect_execute (const char *, char **,
const char *, const char *,
int, bool);
extern int collect_wait (const char *, struct pex_obj *); extern int collect_wait (const char *, struct pex_obj *);
extern void do_wait (const char *, struct pex_obj *); extern void do_wait (const char *, struct pex_obj *);
extern void fork_execute (char **); extern void fork_execute (const char *, char **, bool);
extern void utils_cleanup (void); extern void utils_cleanup (bool);
extern bool debug; extern bool debug;
extern bool verbose; extern bool verbose;
...@@ -37,5 +40,5 @@ extern bool save_temps; ...@@ -37,5 +40,5 @@ extern bool save_temps;
/* The name of the tool, printed in error messages. */ /* The name of the tool, printed in error messages. */
extern const char tool_name[]; extern const char tool_name[];
/* Called by utils_cleanup. */ /* Called by utils_cleanup. */
extern void tool_cleanup (void); extern void tool_cleanup (bool);
extern void maybe_unlink (const char *); extern void maybe_unlink (const char *);
...@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see
#include "collect2.h" #include "collect2.h"
#include "collect2-aix.h" #include "collect2-aix.h"
#include "collect-utils.h"
#include "diagnostic.h" #include "diagnostic.h"
#include "demangle.h" #include "demangle.h"
#include "obstack.h" #include "obstack.h"
...@@ -175,7 +176,6 @@ struct head ...@@ -175,7 +176,6 @@ struct head
int number; int number;
}; };
bool verbose; /* true if -v or --version */
static int rflag; /* true if -r */ static int rflag; /* true if -r */
static int strip_flag; /* true if -s */ static int strip_flag; /* true if -s */
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
...@@ -198,7 +198,6 @@ static enum lto_mode_d lto_mode = LTO_MODE_WHOPR; ...@@ -198,7 +198,6 @@ static enum lto_mode_d lto_mode = LTO_MODE_WHOPR;
static enum lto_mode_d lto_mode = LTO_MODE_NONE; static enum lto_mode_d lto_mode = LTO_MODE_NONE;
#endif #endif
bool debug; /* true if -debug */
bool helpflag; /* true if --help */ bool helpflag; /* true if --help */
static int shared_obj; /* true if -shared */ static int shared_obj; /* true if -shared */
...@@ -234,8 +233,7 @@ static struct head exports; /* list of exported symbols */ ...@@ -234,8 +233,7 @@ static struct head exports; /* list of exported symbols */
#endif #endif
static struct head frame_tables; /* list of frame unwind info tables */ static struct head frame_tables; /* list of frame unwind info tables */
static bool at_file_supplied; /* Whether to use @file arguments */ bool at_file_supplied; /* Whether to use @file arguments */
static char *response_file; /* Name of any current response file */
struct obstack temporary_obstack; struct obstack temporary_obstack;
char * temporary_firstobj; char * temporary_firstobj;
...@@ -296,12 +294,11 @@ typedef enum { ...@@ -296,12 +294,11 @@ typedef enum {
SYM_AIXD = 7 SYM_AIXD = 7
} symkind; } symkind;
const char tool_name[] = "collect2";
static symkind is_ctor_dtor (const char *); static symkind is_ctor_dtor (const char *);
static void handler (int); static void handler (int);
static void do_wait (const char *, struct pex_obj *);
static void fork_execute (const char *, char **);
static void maybe_unlink (const char *);
static void maybe_unlink_list (char **); static void maybe_unlink_list (char **);
static void add_to_list (struct head *, const char *); static void add_to_list (struct head *, const char *);
static int extract_init_priority (const char *); static int extract_init_priority (const char *);
...@@ -382,7 +379,7 @@ static void scan_prog_file (const char *, scanpass, scanfilter); ...@@ -382,7 +379,7 @@ static void scan_prog_file (const char *, scanpass, scanfilter);
/* Delete tempfiles and exit function. */ /* Delete tempfiles and exit function. */
static void void
tool_cleanup (bool from_signal) tool_cleanup (bool from_signal)
{ {
if (c_file != 0 && c_file[0]) if (c_file != 0 && c_file[0])
...@@ -428,18 +425,6 @@ handler (int signo) ...@@ -428,18 +425,6 @@ handler (int signo)
signal (signo, SIG_DFL); signal (signo, SIG_DFL);
raise (signo); raise (signo);
} }
/* Notify user of a non-error. */
void
notice (const char *cmsgid, ...)
{
va_list ap;
va_start (ap, cmsgid);
vfprintf (stderr, _(cmsgid), ap);
va_end (ap);
}
/* Notify user of a non-error, without translating the format string. */ /* Notify user of a non-error, without translating the format string. */
void void
notice_translated (const char *cmsgid, ...) notice_translated (const char *cmsgid, ...)
...@@ -737,7 +722,8 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst, ...@@ -737,7 +722,8 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
*lto_c_ptr = NULL; *lto_c_ptr = NULL;
/* Run the LTO back end. */ /* Run the LTO back end. */
pex = collect_execute (prog, lto_c_argv, NULL, NULL, PEX_SEARCH); pex = collect_execute (prog, lto_c_argv, NULL, NULL, PEX_SEARCH,
at_file_supplied);
{ {
int c; int c;
FILE *stream; FILE *stream;
...@@ -817,7 +803,7 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst, ...@@ -817,7 +803,7 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
/* Run the linker again, this time replacing the object files /* Run the linker again, this time replacing the object files
optimized by the LTO with the temporary file generated by the LTO. */ optimized by the LTO with the temporary file generated by the LTO. */
fork_execute ("ld", out_lto_ld_argv); fork_execute ("ld", out_lto_ld_argv, HAVE_GNU_LD && at_file_supplied);
post_ld_pass (true); post_ld_pass (true);
free (lto_ld_argv); free (lto_ld_argv);
...@@ -827,7 +813,7 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst, ...@@ -827,7 +813,7 @@ maybe_run_lto_and_relink (char **lto_ld_argv, char **object_lst,
{ {
/* Our caller is relying on us to do the link /* Our caller is relying on us to do the link
even though there is no LTO back end work to be done. */ even though there is no LTO back end work to be done. */
fork_execute ("ld", lto_ld_argv); fork_execute ("ld", lto_ld_argv, HAVE_GNU_LD && at_file_supplied);
post_ld_pass (false); post_ld_pass (false);
} }
else else
...@@ -1713,7 +1699,7 @@ main (int argc, char **argv) ...@@ -1713,7 +1699,7 @@ main (int argc, char **argv)
strip_argv[0] = strip_file_name; strip_argv[0] = strip_file_name;
strip_argv[1] = output_file; strip_argv[1] = output_file;
strip_argv[2] = (char *) 0; strip_argv[2] = (char *) 0;
fork_execute ("strip", real_strip_argv); fork_execute ("strip", real_strip_argv, false);
} }
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
...@@ -1799,7 +1785,7 @@ main (int argc, char **argv) ...@@ -1799,7 +1785,7 @@ main (int argc, char **argv)
/* Assemble the constructor and destructor tables. /* Assemble the constructor and destructor tables.
Link the tables in with the rest of the program. */ Link the tables in with the rest of the program. */
fork_execute ("gcc", c_argv); fork_execute ("gcc", c_argv, at_file_supplied);
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
/* On AIX we must call tlink because of possible templates resolution. */ /* On AIX we must call tlink because of possible templates resolution. */
do_tlink (ld2_argv, object_lst); do_tlink (ld2_argv, object_lst);
...@@ -1812,7 +1798,7 @@ main (int argc, char **argv) ...@@ -1812,7 +1798,7 @@ main (int argc, char **argv)
maybe_run_lto_and_relink (ld2_argv, object_lst, object, true); maybe_run_lto_and_relink (ld2_argv, object_lst, object, true);
else else
{ {
fork_execute ("ld", ld2_argv); fork_execute ("ld", ld2_argv, HAVE_GNU_LD && at_file_supplied);
post_ld_pass (false); post_ld_pass (false);
} }
...@@ -1832,163 +1818,10 @@ main (int argc, char **argv) ...@@ -1832,163 +1818,10 @@ main (int argc, char **argv)
} }
/* Wait for a process to finish, and exit if a nonzero status is found. */
int
collect_wait (const char *prog, struct pex_obj *pex)
{
int status;
if (!pex_get_status (pex, 1, &status))
fatal_error ("can't get program status: %m");
pex_free (pex);
if (status)
{
if (WIFSIGNALED (status))
{
int sig = WTERMSIG (status);
error ("%s terminated with signal %d [%s]%s",
prog, sig, strsignal (sig),
WCOREDUMP (status) ? ", core dumped" : "");
exit (FATAL_EXIT_CODE);
}
if (WIFEXITED (status))
return WEXITSTATUS (status);
}
return 0;
}
static void
do_wait (const char *prog, struct pex_obj *pex)
{
int ret = collect_wait (prog, pex);
if (ret != 0)
{
error ("%s returned %d exit status", prog, ret);
exit (ret);
}
if (response_file)
{
unlink (response_file);
response_file = NULL;
}
}
/* Execute a program, and wait for the reply. */
struct pex_obj *
collect_execute (const char *prog, char **argv, const char *outname,
const char *errname, int flags)
{
struct pex_obj *pex;
const char *errmsg;
int err;
char *response_arg = NULL;
char *response_argv[3] ATTRIBUTE_UNUSED;
if (HAVE_GNU_LD && at_file_supplied && argv[0] != NULL)
{
/* If using @file arguments, create a temporary file and put the
contents of argv into it. Then change argv to an array corresponding
to a single argument @FILE, where FILE is the temporary filename. */
char **current_argv = argv + 1;
char *argv0 = argv[0];
int status;
FILE *f;
/* Note: we assume argv contains at least one element; this is
checked above. */
response_file = make_temp_file ("");
f = fopen (response_file, "w");
if (f == NULL)
fatal_error ("could not open response file %s", response_file);
status = writeargv (current_argv, f);
if (status)
fatal_error ("could not write to response file %s", response_file);
status = fclose (f);
if (EOF == status)
fatal_error ("could not close response file %s", response_file);
response_arg = concat ("@", response_file, NULL);
response_argv[0] = argv0;
response_argv[1] = response_arg;
response_argv[2] = NULL;
argv = response_argv;
}
if (verbose || debug)
{
char **p_argv;
const char *str;
if (argv[0])
fprintf (stderr, "%s", argv[0]);
else
notice ("[cannot find %s]", prog);
for (p_argv = &argv[1]; (str = *p_argv) != (char *) 0; p_argv++)
fprintf (stderr, " %s", str);
fprintf (stderr, "\n");
}
fflush (stdout);
fflush (stderr);
/* If we cannot find a program we need, complain error. Do this here
since we might not end up needing something that we could not find. */
if (argv[0] == 0)
fatal_error ("cannot find '%s'", prog);
pex = pex_init (0, "collect2", NULL);
if (pex == NULL)
fatal_error ("pex_init failed: %m");
errmsg = pex_run (pex, flags, argv[0], argv, outname,
errname, &err);
if (errmsg != NULL)
{
if (err != 0)
{
errno = err;
fatal_error ("%s: %m", _(errmsg));
}
else
fatal_error (errmsg);
}
free (response_arg);
return pex;
}
static void
fork_execute (const char *prog, char **argv)
{
struct pex_obj *pex;
pex = collect_execute (prog, argv, NULL, NULL, PEX_LAST | PEX_SEARCH);
do_wait (prog, pex);
}
/* Unlink FILE unless we are debugging or this is the output_file /* Unlink FILE unless we are debugging or this is the output_file
and we may not unlink it. */ and we may not unlink it. */
static void void
maybe_unlink (const char *file) maybe_unlink (const char *file)
{ {
if (debug) if (debug)
...@@ -3177,7 +3010,8 @@ do_dsymutil (const char *output_file) { ...@@ -3177,7 +3010,8 @@ do_dsymutil (const char *output_file) {
argv[1] = output_file; argv[1] = output_file;
argv[2] = (char *) 0; argv[2] = (char *) 0;
pex = collect_execute (dsymutil, real_argv, NULL, NULL, PEX_LAST | PEX_SEARCH); pex = collect_execute (dsymutil, real_argv, NULL, NULL,
PEX_LAST | PEX_SEARCH, false);
do_wait (dsymutil, pex); do_wait (dsymutil, pex);
} }
......
...@@ -36,10 +36,10 @@ extern const char *lderrout; ...@@ -36,10 +36,10 @@ 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;
extern bool verbose, debug;
extern bool may_unlink_output_file; extern bool may_unlink_output_file;
extern void notice_translated (const char *, ...) ATTRIBUTE_PRINTF_1; extern void notice_translated (const char *, ...) ATTRIBUTE_PRINTF_1;
extern void notice (const char *, ...) ATTRIBUTE_PRINTF_1; extern void notice (const char *, ...) ATTRIBUTE_PRINTF_1;
extern bool at_file_supplied;
#endif /* ! GCC_COLLECT2_H */ #endif /* ! GCC_COLLECT2_H */
...@@ -70,7 +70,7 @@ const char tool_name[] = "lto-wrapper"; ...@@ -70,7 +70,7 @@ const char tool_name[] = "lto-wrapper";
/* Delete tempfiles. Called from utils_cleanup. */ /* Delete tempfiles. Called from utils_cleanup. */
void void
tool_cleanup (void) tool_cleanup (bool)
{ {
unsigned int i; unsigned int i;
...@@ -91,7 +91,7 @@ tool_cleanup (void) ...@@ -91,7 +91,7 @@ tool_cleanup (void)
static void static void
lto_wrapper_cleanup (void) lto_wrapper_cleanup (void)
{ {
utils_cleanup (); utils_cleanup (false);
} }
/* Unlink a temporary LTRANS file unless requested otherwise. */ /* Unlink a temporary LTRANS file unless requested otherwise. */
...@@ -684,7 +684,7 @@ run_gcc (unsigned argc, char *argv[]) ...@@ -684,7 +684,7 @@ run_gcc (unsigned argc, char *argv[])
new_argv = XOBFINISH (&argv_obstack, const char **); new_argv = XOBFINISH (&argv_obstack, const char **);
argv_ptr = &new_argv[new_head_argc]; argv_ptr = &new_argv[new_head_argc];
fork_execute (CONST_CAST (char **, new_argv)); fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true);
if (lto_mode == LTO_MODE_LTO) if (lto_mode == LTO_MODE_LTO)
{ {
...@@ -792,7 +792,8 @@ cont: ...@@ -792,7 +792,8 @@ cont:
} }
else else
{ {
fork_execute (CONST_CAST (char **, new_argv)); fork_execute (new_argv[0], CONST_CAST (char **, new_argv),
true);
maybe_unlink (input_name); maybe_unlink (input_name);
} }
...@@ -828,8 +829,9 @@ cont: ...@@ -828,8 +829,9 @@ cont:
} }
new_argv[i++] = "all"; new_argv[i++] = "all";
new_argv[i++] = NULL; new_argv[i++] = NULL;
pex = collect_execute (CONST_CAST (char **, new_argv)); pex = collect_execute (new_argv[0], CONST_CAST (char **, new_argv),
collect_wait (new_argv[0], pex); NULL, NULL, PEX_SEARCH, false);
do_wait (new_argv[0], pex);
maybe_unlink (makefile); maybe_unlink (makefile);
makefile = NULL; makefile = NULL;
for (i = 0; i < nr; ++i) for (i = 0; i < nr; ++i)
......
...@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "hashtab.h" #include "hashtab.h"
#include "demangle.h" #include "demangle.h"
#include "collect2.h" #include "collect2.h"
#include "collect-utils.h"
#include "filenames.h" #include "filenames.h"
#include "diagnostic-core.h" #include "diagnostic-core.h"
#include "vec.h" #include "vec.h"
...@@ -104,8 +105,6 @@ static void symbol_push (symbol *); ...@@ -104,8 +105,6 @@ static void symbol_push (symbol *);
static symbol * symbol_pop (void); 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 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 *);
...@@ -286,11 +285,12 @@ tlink_init (void) ...@@ -286,11 +285,12 @@ tlink_init (void)
static int static int
tlink_execute (const char *prog, char **argv, const char *outname, tlink_execute (const char *prog, char **argv, const char *outname,
const char *errname) const char *errname, bool use_atfile)
{ {
struct pex_obj *pex; struct pex_obj *pex;
pex = collect_execute (prog, argv, outname, errname, PEX_LAST | PEX_SEARCH); pex = collect_execute (prog, argv, outname, errname,
PEX_LAST | PEX_SEARCH, use_atfile);
return collect_wait (prog, pex); return collect_wait (prog, pex);
} }
...@@ -545,7 +545,7 @@ recompile_files (void) ...@@ -545,7 +545,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, NULL) != 0 || tlink_execute (c_file_name, argv, NULL, NULL, false) != 0
|| chdir (initial_cwd) != 0) || chdir (initial_cwd) != 0)
return 0; return 0;
...@@ -817,7 +817,8 @@ scan_linker_output (const char *fname) ...@@ -817,7 +817,8 @@ 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 ret = tlink_execute ("ld", ld_argv, ldout, lderrout); int ret = tlink_execute ("ld", ld_argv, ldout, lderrout,
HAVE_GNU_LD && at_file_supplied);
tlink_init (); tlink_init ();
...@@ -843,7 +844,8 @@ do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED) ...@@ -843,7 +844,8 @@ do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED)
break; break;
if (tlink_verbose) if (tlink_verbose)
fprintf (stderr, _("collect: relinking\n")); fprintf (stderr, _("collect: relinking\n"));
ret = tlink_execute ("ld", ld_argv, ldout, lderrout); ret = tlink_execute ("ld", ld_argv, ldout, lderrout,
HAVE_GNU_LD && at_file_supplied);
} }
} }
......
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