aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/gcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/gcc.c')
-rw-r--r--gcc-4.9/gcc/gcc.c87
1 files changed, 78 insertions, 9 deletions
diff --git a/gcc-4.9/gcc/gcc.c b/gcc-4.9/gcc/gcc.c
index 4becac64a..efca49bfb 100644
--- a/gcc-4.9/gcc/gcc.c
+++ b/gcc-4.9/gcc/gcc.c
@@ -759,6 +759,9 @@ proper position among the other output files. */
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
%(linker) " \
LINK_PLUGIN_SPEC \
+ "%{freorder-functions=*: \
+ -plugin %(func_reorder_linker_plugin_file) \
+ -plugin-opt=%(func_reorder_linker_plugin_opt)}" \
"%{flto|flto=*:%<fcompare-debug*} \
%{flto} %{flto=*} %l " LINK_PIE_SPEC \
"%{fuse-ld=*:-fuse-ld=%*}\
@@ -811,6 +814,8 @@ static const char *endfile_spec = ENDFILE_SPEC;
static const char *startfile_spec = STARTFILE_SPEC;
static const char *linker_name_spec = LINKER_NAME;
static const char *linker_plugin_file_spec = "";
+static const char *func_reorder_linker_plugin_file_spec = "";
+static const char *func_reorder_linker_plugin_opt = "";
static const char *lto_wrapper_spec = "";
static const char *lto_gcc_spec = "";
static const char *link_command_spec = LINK_COMMAND_SPEC;
@@ -876,7 +881,7 @@ static const char *cc1_options =
%{-help=*:--help=%*}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
%{fsyntax-only:-o %j} %{-param*}\
- %{coverage:-fprofile-arcs -ftest-coverage}";
+ %{coverage:-fprofile-arcs -ftest-coverage -fno-early-inlining}";
static const char *asm_options =
"%{-target-help:%:print-asm-header()} "
@@ -1309,6 +1314,10 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("multilib_reuse", &multilib_reuse),
INIT_STATIC_SPEC ("linker", &linker_name_spec),
INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec),
+ INIT_STATIC_SPEC ("func_reorder_linker_plugin_file",
+ &func_reorder_linker_plugin_file_spec),
+ INIT_STATIC_SPEC ("func_reorder_linker_plugin_opt",
+ &func_reorder_linker_plugin_opt),
INIT_STATIC_SPEC ("lto_wrapper", &lto_wrapper_spec),
INIT_STATIC_SPEC ("lto_gcc", &lto_gcc_spec),
INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec),
@@ -3105,10 +3114,11 @@ display_help (void)
fputs (_(" -Xassembler <arg> Pass <arg> on to the assembler\n"), stdout);
fputs (_(" -Xpreprocessor <arg> Pass <arg> on to the preprocessor\n"), stdout);
fputs (_(" -Xlinker <arg> Pass <arg> on to the linker\n"), stdout);
+ fputs (_(" -Xclang-only=<arg> Ignore <arg>\n"), stdout);
fputs (_(" -save-temps Do not delete intermediate files\n"), stdout);
fputs (_(" -save-temps=<arg> Do not delete intermediate files\n"), stdout);
fputs (_("\
- -no-canonical-prefixes Do not canonicalize paths when building relative\n\
+ -[no-]canonical-prefixes Specify the path canonicalization for relative\n\
prefixes to other gcc components\n"), stdout);
fputs (_(" -pipe Use pipes rather than intermediate files\n"), stdout);
fputs (_(" -time Time the execution of each subprocess\n"), stdout);
@@ -3542,6 +3552,7 @@ driver_handle_option (struct gcc_options *opts,
decoded->orig_option_with_args_text);
break;
+ case OPT_canonical_prefixes:
case OPT_no_canonical_prefixes:
/* Already handled as a special case, so ignored here. */
do_save = false;
@@ -3726,20 +3737,25 @@ process_command (unsigned int decoded_options_count,
}
}
- /* Handle any -no-canonical-prefixes flag early, to assign the function
+ /* Handle any -[no-]canonical-prefixes flags early, to assign the function
that builds relative prefixes. This function creates default search
paths that are needed later in normal option handling. */
for (j = 1; j < decoded_options_count; j++)
{
- if (decoded_options[j].opt_index == OPT_no_canonical_prefixes)
- {
- get_relative_prefix = make_relative_prefix_ignore_links;
- break;
- }
+ if (decoded_options[j].opt_index == OPT_canonical_prefixes)
+ get_relative_prefix = make_relative_prefix;
+ else if (decoded_options[j].opt_index == OPT_no_canonical_prefixes)
+ get_relative_prefix = make_relative_prefix_ignore_links;
}
if (! get_relative_prefix)
- get_relative_prefix = make_relative_prefix;
+ {
+#ifdef ENABLE_CANONICAL_PREFIXES
+ get_relative_prefix = make_relative_prefix;
+#else
+ get_relative_prefix = make_relative_prefix_ignore_links;
+#endif
+ }
/* Set up the default search paths. If there is no GCC_EXEC_PREFIX,
see if we can create it from the pathname specified in
@@ -6310,6 +6326,51 @@ compare_files (char *cmpfile[])
return ret;
}
+/* Set func_reorder_linker_plugin_file_spec and func_reorder_linker_plugin_opt
+ here. This is the linker plugin to do global function reordering and is
+ enabled with -freorder-functions=*. */
+
+static void
+set_func_reorder_linker_plugin_spec (void)
+{
+ int i;
+ const char *plugin_opt_none = "group=none";
+ const char *plugin_opt_callgraph = "group=callgraph";
+
+ /* Find the linker plugin that does function ordering. */
+ func_reorder_linker_plugin_file_spec = find_a_file (&exec_prefixes,
+ FRPLUGINSONAME, R_OK, false);
+
+ if (!func_reorder_linker_plugin_file_spec)
+ fatal_error ("-freorder-functions=*, but "
+ FRPLUGINSONAME " file not found");
+
+ func_reorder_linker_plugin_opt = plugin_opt_none;
+
+ /* Set linker plugin options here. Option ordering is also checked here.
+ -fno-reorder-functions or -freorder-functions should disable any
+ previous -freorder-functions=*. */
+ for (i = 0; (int) i < n_switches; i++)
+ {
+ /* Check for match with "-freorder-functions=callgraph". */
+ if (func_reorder_linker_plugin_opt != plugin_opt_callgraph
+ && !strcmp (switches[i].part1, "freorder-functions=callgraph"))
+ {
+ func_reorder_linker_plugin_opt = plugin_opt_callgraph;
+ continue;
+ }
+ /* Set option to none if it matches -fno-reorder-functions
+ or -freorder-functions */
+ if (func_reorder_linker_plugin_opt != plugin_opt_none
+ && (!strcmp (switches[i].part1, "fno-reorder-functions")
+ || !strcmp (switches[i].part1, "freorder-functions")))
+ {
+ func_reorder_linker_plugin_opt = plugin_opt_none;
+ continue;
+ }
+ }
+}
+
extern int main (int, char **);
int
@@ -7116,6 +7177,8 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
#endif
#endif
+ const char *freorder_functions_ = "freorder-functions=";
+
/* We'll use ld if we can't find collect2. */
if (! strcmp (linker_name_spec, "collect2"))
{
@@ -7145,6 +7208,12 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
}
#endif
lto_gcc_spec = argv[0];
+
+ /* The function reordering linker plugin will be loaded if the option
+ -freorder-functions= is present in the command-line. */
+ if (switch_matches (freorder_functions_,
+ freorder_functions_ + strlen (freorder_functions_), 1))
+ set_func_reorder_linker_plugin_spec ();
}
/* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables