2014-06-26 Bernd Schmidt <bernds@codesourcery.com>
+ * collect-utils.c (save_temps): New variable.
+ (do_wait): Use it instead of debug. Use fatal_error.
+ * collect-utils.h (save_temps): Declare.
+ * collect2.c (verbose): Rename from vflag. All uses changed.
+ (tool_cleanup): New function, copied from collect_atexit.
+ (collect_atexit, handler): Just call it.
+ * collect2.h (verbose): Declaration renamed from vflag.
+ * lto-wrapper.c (maybe_unlink, run_gcc): Use save_temps instead of
+ debug.
+
* Makefile.in (ALL_HOST_BACKEND_OBJS): Add collect-utils.o.
(lto-wrapper$(exeext)): Link with collect-utils.o.
* collect-utils.c: New file.
int number;
};
-bool vflag; /* true if -v or --version */
+bool verbose; /* true if -v or --version */
static int rflag; /* true if -r */
static int strip_flag; /* true if -s */
#ifdef COLLECT_EXPORT_LIST
/* Delete tempfiles and exit function. */
static void
-collect_atexit (void)
+tool_cleanup (bool from_signal)
{
if (c_file != 0 && c_file[0])
maybe_unlink (c_file);
if (ldout != 0 && ldout[0])
{
- dump_ld_file (ldout, stdout);
+ if (!from_signal)
+ dump_ld_file (ldout, stdout);
maybe_unlink (ldout);
}
if (lderrout != 0 && lderrout[0])
{
- dump_ld_file (lderrout, stderr);
+ if (!from_signal)
+ dump_ld_file (lderrout, stderr);
maybe_unlink (lderrout);
}
+}
- if (response_file)
- maybe_unlink (response_file);
+static void
+collect_atexit (void)
+{
+ tool_cleanup (false);
}
+static void
+handler (int signo)
+{
+ tool_cleanup (true);
+
+ signal (signo, SIG_DFL);
+ raise (signo);
+}
\f
/* Notify user of a non-error. */
void
va_end (ap);
}
\f
-static void
-handler (int signo)
-{
- if (c_file != 0 && c_file[0])
- maybe_unlink (c_file);
-
- if (o_file != 0 && o_file[0])
- maybe_unlink (o_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);
-#endif
-
- if (lto_o_files)
- maybe_unlink_list (lto_o_files);
-
- if (response_file)
- maybe_unlink (response_file);
-
- signal (signo, SIG_DFL);
- raise (signo);
-}
-
-\f
int
file_exists (const char *name)
{
aixlazy_flag = 1;
#endif
}
- vflag = debug;
+ verbose = debug;
find_file_set_debug (debug);
if (use_plugin)
lto_mode = LTO_MODE_NONE;
case 'v':
if (arg[2] == '\0')
- vflag = true;
+ verbose = true;
break;
case '-':
else if (strncmp (arg, "--sysroot=", 10) == 0)
target_system_root = arg + 10;
else if (strcmp (arg, "--version") == 0)
- vflag = true;
+ verbose = true;
else if (strcmp (arg, "--help") == 0)
helpflag = true;
break;
*c_ptr++ = c_file;
*c_ptr = *ld1 = *object = (char *) 0;
- if (vflag)
+ if (verbose)
notice ("collect2 version %s\n", version_string);
if (helpflag)
argv = response_argv;
}
- if (vflag || debug)
+ if (verbose || debug)
{
char **p_argv;
const char *str;
nm_argv[argc++] = (char *) 0;
/* Trace if needed. */
- if (vflag)
+ if (verbose)
{
const char **p_argv;
const char *str;
ldd_argv[argc++] = (char *) 0;
/* Trace if needed. */
- if (vflag)
+ if (verbose)
{
const char **p_argv;
const char *str;
extern const char *c_file_name;
extern struct obstack temporary_obstack;
extern char *temporary_firstobj;
-extern bool vflag, debug;
+extern bool verbose, debug;
extern bool may_unlink_output_file;
extern void notice_translated (const char *, ...) ATTRIBUTE_PRINTF_1;
void
maybe_unlink (const char *file)
{
- if (! debug)
+ if (!save_temps)
{
if (unlink_if_ordinary (file)
&& errno != ENOENT)
continue;
case OPT_save_temps:
- debug = 1;
+ save_temps = 1;
break;
case OPT_v:
obstack_ptr_grow (&argv_obstack, dumpbase);
}
- if (linker_output && debug)
+ if (linker_output && save_temps)
{
ltrans_output_file = (char *) xmalloc (strlen (linker_output)
+ sizeof (".ltrans.out") + 1);
/* If we are not preserving the ltrans input files then
truncate them as soon as we have processed it. This
reduces temporary disk-space usage. */
- if (! debug)
+ if (! save_temps)
fprintf (mstream, "\t@-touch -r %s %s.tem > /dev/null 2>&1 "
"&& mv %s.tem %s\n",
input_name, input_name, input_name, input_name);