aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-05-12 11:59:17 +0200
committerMartin Liska <mliska@suse.cz>2021-05-12 12:00:20 +0200
commit3835aa0eb90292d652dd6b200f302f3cac7e643f (patch)
treeb8ebb71e86bc15061c4ec89e5a3f594f1fe72487
parent7d7d925d0d799eb9dda4a6bd6162af0a7db9c98b (diff)
downloadgcc-3835aa0eb90292d652dd6b200f302f3cac7e643f.zip
gcc-3835aa0eb90292d652dd6b200f302f3cac7e643f.tar.gz
gcc-3835aa0eb90292d652dd6b200f302f3cac7e643f.tar.bz2
LTO: merge -flto=arg from object files.
gcc/ChangeLog: * lto-wrapper.c (merge_and_complain): Merge -flto=arg options. (run_gcc): Use -flto argument detection for merged fdecoded_options.
-rw-r--r--gcc/lto-wrapper.c77
1 files changed, 57 insertions, 20 deletions
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 7931ae3..a71d614 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -425,6 +425,31 @@ merge_and_complain (vec<cl_decoded_option> decoded_options,
case OPT_foffload_:
decoded_options.safe_push (*foption);
break;
+
+ case OPT_flto_:
+ if (existing_opt == -1)
+ decoded_options.safe_push (*foption);
+ else
+ {
+ if (strcmp (foption->arg, decoded_options[existing_opt].arg) != 0)
+ {
+ /* -flto=auto is preferred. */
+ if (strcmp (decoded_options[existing_opt].arg, "auto") == 0)
+ ;
+ else if (strcmp (foption->arg, "auto") == 0
+ || strcmp (foption->arg, "jobserver") == 0)
+ decoded_options[existing_opt].arg = foption->arg;
+ else if (strcmp (decoded_options[existing_opt].arg,
+ "jobserver") != 0)
+ {
+ int n = atoi (foption->arg);
+ int original_n = atoi (decoded_options[existing_opt].arg);
+ if (n > original_n)
+ decoded_options[existing_opt].arg = foption->arg;
+ }
+ }
+ }
+ break;
}
}
@@ -1490,6 +1515,37 @@ run_gcc (unsigned argc, char *argv[])
append_compiler_options (&argv_obstack, fdecoded_options);
append_linker_options (&argv_obstack, decoded_options);
+ /* Process LTO-related options on merged options. */
+ for (j = 1; j < fdecoded_options.length (); ++j)
+ {
+ cl_decoded_option *option = &fdecoded_options[j];
+ switch (option->opt_index)
+ {
+ case OPT_flto_:
+ if (strcmp (option->arg, "jobserver") == 0)
+ {
+ parallel = 1;
+ jobserver = 1;
+ }
+ else if (strcmp (option->arg, "auto") == 0)
+ {
+ parallel = 1;
+ auto_parallel = 1;
+ }
+ else
+ {
+ parallel = atoi (option->arg);
+ if (parallel <= 1)
+ parallel = 0;
+ }
+ /* Fallthru. */
+
+ case OPT_flto:
+ lto_mode = LTO_MODE_WHOPR;
+ break;
+ }
+ }
+
/* Scan linker driver arguments for things that are of relevance to us. */
for (j = 1; j < decoded_options.length (); ++j)
{
@@ -1519,26 +1575,7 @@ run_gcc (unsigned argc, char *argv[])
case OPT_flto_:
if (strcmp (option->arg, "jobserver") == 0)
- {
- parallel = 1;
- jobserver = 1;
- jobserver_requested = true;
- }
- else if (strcmp (option->arg, "auto") == 0)
- {
- parallel = 1;
- auto_parallel = 1;
- }
- else
- {
- parallel = atoi (option->arg);
- if (parallel <= 1)
- parallel = 0;
- }
- /* Fallthru. */
-
- case OPT_flto:
- lto_mode = LTO_MODE_WHOPR;
+ jobserver_requested = true;
break;
case OPT_flinker_output_: