summaryrefslogtreecommitdiff
path: root/gcc/collect2.c
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2018-12-23 10:28:51 +0000
committerIain Sandoe <iains@gcc.gnu.org>2018-12-23 10:28:51 +0000
commitf67eeb79e18366528daf855648abb4e6069f8238 (patch)
tree21edc059a38f46830baa8bf2975ff8a8e92367ba /gcc/collect2.c
parent0652a1512130cfda8a7ffb192f47bf19c9be2525 (diff)
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
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r--gcc/collect2.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 6463ff7b645..2fc4ad18c9b 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -981,13 +981,14 @@ main (int argc, char **argv)
object = CONST_CAST2 (const char **, char **, object_lst);
#ifdef DEBUG
- debug = 1;
+ debug = true;
#endif
- /* Parse command line early for instances of -debug. This allows
- the debug flag to be set before functions like find_a_file()
- are called. We also look for the -flto or -flto-partition=none flag to know
- what LTO mode we are in. */
+ save_temps = false;
+ verbose = false;
+ /* Parse command line / environment for flags we want early.
+ This allows the debug flag to be set before functions like find_a_file()
+ are called. */
{
bool no_partition = false;
@@ -995,8 +996,6 @@ main (int argc, char **argv)
{
if (! strcmp (argv[i], "-debug"))
debug = true;
- else if (! strcmp (argv[i], "-flto-partition=none"))
- no_partition = true;
else if (!strncmp (argv[i], "-fno-lto", 8))
lto_mode = LTO_MODE_NONE;
else if (! strcmp (argv[i], "-plugin"))
@@ -1031,13 +1030,6 @@ main (int argc, char **argv)
aixlazy_flag = 1;
#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
output_file = "a.out";
@@ -1045,20 +1037,37 @@ main (int argc, char **argv)
output_file = DEFAULT_A_OUT_NAME;
#endif
- obstack_begin (&temporary_obstack, 0);
- temporary_firstobj = (char *) obstack_alloc (&temporary_obstack, 0);
+ obstack_begin (&temporary_obstack, 0);
+ temporary_firstobj = (char *) obstack_alloc (&temporary_obstack, 0);
#ifndef HAVE_LD_DEMANGLE
current_demangling_style = auto_demangling;
#endif
- p = getenv ("COLLECT_GCC_OPTIONS");
- while (p && *p)
- {
- const char *q = extract_string (&p);
- if (*q == '-' && (q[1] == 'm' || q[1] == 'f'))
- num_c_args++;
+
+ /* Now pick up any flags we want early from COLLECT_GCC_OPTIONS
+ The LTO options are passed here as are other options that might
+ be unsuitable for ld (e.g. -save-temps). */
+ p = getenv ("COLLECT_GCC_OPTIONS");
+ 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-exceptions -w -fno-whole-program */