Commit f67eeb79 by Iain Sandoe Committed by Iain Sandoe

Ensure collect2 responds to intended commmand line options.

To ensure compatibility with the flags consumed by ld, some of the flags
needed by collect2 come from the command line and some are passed
in the COLLECT_GCC_OPTIONS.

Here we combine initial parses of both and then set the LTO mode accordingly.

2018-12-23  Iain Sandoe  <iain@sandoe.co.uk>

	* collect2.c (main): Combine flags from both the command line and
	COLLECT_GCC_OPTIONS to determine the set in force

From-SVN: r267369
parent 0652a151
2018-12-23 Iain Sandoe <iain@sandoe.co.uk>
* collect2.c (main): Combine flags from both the command line and
COLLECT_GCC_OPTIONS to determine the set in force
2018-12-21 Jan Hubicka <hubicka@ucw.cz> 2018-12-21 Jan Hubicka <hubicka@ucw.cz>
* ipa-utils.c (ipa_merge_profiles): Recompute summaries. * ipa-utils.c (ipa_merge_profiles): Recompute summaries.
...@@ -981,13 +981,14 @@ main (int argc, char **argv) ...@@ -981,13 +981,14 @@ main (int argc, char **argv)
object = CONST_CAST2 (const char **, char **, object_lst); object = CONST_CAST2 (const char **, char **, object_lst);
#ifdef DEBUG #ifdef DEBUG
debug = 1; debug = true;
#endif #endif
/* Parse command line early for instances of -debug. This allows save_temps = false;
the debug flag to be set before functions like find_a_file() verbose = false;
are called. We also look for the -flto or -flto-partition=none flag to know /* Parse command line / environment for flags we want early.
what LTO mode we are in. */ This allows the debug flag to be set before functions like find_a_file()
are called. */
{ {
bool no_partition = false; bool no_partition = false;
...@@ -995,8 +996,6 @@ main (int argc, char **argv) ...@@ -995,8 +996,6 @@ main (int argc, char **argv)
{ {
if (! strcmp (argv[i], "-debug")) if (! strcmp (argv[i], "-debug"))
debug = true; debug = true;
else if (! strcmp (argv[i], "-flto-partition=none"))
no_partition = true;
else if (!strncmp (argv[i], "-fno-lto", 8)) else if (!strncmp (argv[i], "-fno-lto", 8))
lto_mode = LTO_MODE_NONE; lto_mode = LTO_MODE_NONE;
else if (! strcmp (argv[i], "-plugin")) else if (! strcmp (argv[i], "-plugin"))
...@@ -1031,13 +1030,6 @@ main (int argc, char **argv) ...@@ -1031,13 +1030,6 @@ main (int argc, char **argv)
aixlazy_flag = 1; aixlazy_flag = 1;
#endif #endif
} }
verbose = debug;
find_file_set_debug (debug);
if (use_plugin)
lto_mode = LTO_MODE_NONE;
if (no_partition && lto_mode == LTO_MODE_WHOPR)
lto_mode = LTO_MODE_LTO;
}
#ifndef DEFAULT_A_OUT_NAME #ifndef DEFAULT_A_OUT_NAME
output_file = "a.out"; output_file = "a.out";
...@@ -1045,20 +1037,37 @@ main (int argc, char **argv) ...@@ -1045,20 +1037,37 @@ main (int argc, char **argv)
output_file = DEFAULT_A_OUT_NAME; output_file = DEFAULT_A_OUT_NAME;
#endif #endif
obstack_begin (&temporary_obstack, 0); obstack_begin (&temporary_obstack, 0);
temporary_firstobj = (char *) obstack_alloc (&temporary_obstack, 0); temporary_firstobj = (char *) obstack_alloc (&temporary_obstack, 0);
#ifndef HAVE_LD_DEMANGLE #ifndef HAVE_LD_DEMANGLE
current_demangling_style = auto_demangling; current_demangling_style = auto_demangling;
#endif #endif
p = getenv ("COLLECT_GCC_OPTIONS");
while (p && *p) /* Now pick up any flags we want early from COLLECT_GCC_OPTIONS
{ The LTO options are passed here as are other options that might
const char *q = extract_string (&p); be unsuitable for ld (e.g. -save-temps). */
if (*q == '-' && (q[1] == 'm' || q[1] == 'f')) p = getenv ("COLLECT_GCC_OPTIONS");
num_c_args++; while (p && *p)
{
const char *q = extract_string (&p);
if (*q == '-' && (q[1] == 'm' || q[1] == 'f'))
num_c_args++;
if (strncmp (q, "-flto-partition=none", 20) == 0)
no_partition = true;
else if (strncmp (q, "-fno-lto", 8) == 0)
lto_mode = LTO_MODE_NONE;
} }
obstack_free (&temporary_obstack, temporary_firstobj); obstack_free (&temporary_obstack, temporary_firstobj);
verbose = verbose || debug;
save_temps = save_temps || debug;
find_file_set_debug (debug);
if (use_plugin)
lto_mode = LTO_MODE_NONE;
if (no_partition && lto_mode == LTO_MODE_WHOPR)
lto_mode = LTO_MODE_LTO;
}
/* -fno-profile-arcs -fno-test-coverage -fno-branch-probabilities /* -fno-profile-arcs -fno-test-coverage -fno-branch-probabilities
-fno-exceptions -w -fno-whole-program */ -fno-exceptions -w -fno-whole-program */
......
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