diff options
author | Jan Hubicka <jh@suse.cz> | 2011-01-08 02:37:00 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2011-01-08 01:37:00 +0000 |
commit | 96bdf9b4035f9628ee214b9d773c313b065e36bf (patch) | |
tree | 6f419805e71a133ecdcbe5137da91c38f6dab263 /gcc | |
parent | f35cafc9ff3898a2205a2089f315f19640da1041 (diff) | |
download | gcc-96bdf9b4035f9628ee214b9d773c313b065e36bf.zip gcc-96bdf9b4035f9628ee214b9d773c313b065e36bf.tar.gz gcc-96bdf9b4035f9628ee214b9d773c313b065e36bf.tar.bz2 |
Makefile.in: Regenerate.
* Makefile.in: Regenerate.
* Makefile.def (gcc host module) and soft dependency on lto-plugin
and configure dependency on lto-plugin configure.
(lto-plugin module): Remove dependency on GCC; add dependency on
liniberty.
* doc/invoke.texi: (-flto, -fuse-linker-plugin): Update defaults
and no longer claim that gold is required for linker plugin.
* configure: Regenerate.
* gcc.c (PLUGIN_COND): New macro.
(LINK_COMMAND_SPEC): Use it.
(main): Default to plugin enabled with HAVE_LTO_PLUGIN is set.
* config.in (HAVE_LTO_PLUGIN): New.
* configure.ac (--with-lto-plugin): New parameter; autodetect
HAVE_LTO_PLUGIN.
From-SVN: r168593
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/config.in | 4 | ||||
-rwxr-xr-x | gcc/configure | 23 | ||||
-rw-r--r-- | gcc/configure.ac | 20 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 37 | ||||
-rw-r--r-- | gcc/gcc.c | 18 |
6 files changed, 97 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3624c0d..24a4367 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,17 @@ 2011-01-07 Jan Hubicka <jh@suse.cz> + * doc/invoke.texi: (-flto, -fuse-linker-plugin): Update defaults + and no longer claim that gold is required for linker plugin. + * configure: Regenerate. + * gcc.c (PLUGIN_COND): New macro. + (LINK_COMMAND_SPEC): Use it. + (main): Default to plugin enabled with HAVE_LTO_PLUGIN is set. + * config.in (HAVE_LTO_PLUGIN): New. + * configure.ac (--with-lto-plugin): New parameter; autodetect + HAVE_LTO_PLUGIN. + +2011-01-07 Jan Hubicka <jh@suse.cz> + PR tree-optimization/46367 * ipa-inline.c (cgraph_clone_inlined_nodes): Use original function only when we can update original. diff --git a/gcc/config.in b/gcc/config.in index f129f3d..9df41a1 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1142,6 +1142,10 @@ #undef HAVE_LDFCN_H #endif +/* Define if your linker supports plugin. */ +#ifndef USED_FOR_TARGET +#undef HAVE_LTO_PLUGIN +#endif /* Define if your linker supports --as-needed and --no-as-needed options. */ #ifndef USED_FOR_TARGET diff --git a/gcc/configure b/gcc/configure index d1a68a8..46c5285 100755 --- a/gcc/configure +++ b/gcc/configure @@ -23093,6 +23093,29 @@ $as_echo "#define HAVE_LD_DEMANGLE 1" >>confdefs.h $as_echo "$gcc_cv_ld_demangle" >&6; } fi +if test -f ../lto-plugin/Makefile ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker plugin support" >&5 +$as_echo_n "checking linker plugin support... " >&6; } + gcc_cv_lto_plugin=no + if test $in_tree_ld = yes -a x"$ORIGINAL_PLUGIN_LD_FOR_TARGET=" = x"$gcc_cv_ld"; then + if test x"$ld_is_gold" = xyes; then + gcc_cv_lto_plugin=yes + elif test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2; then \ + gcc_cv_lto_plugin=yes + fi + # Check if the linker supports --plugin-opt option + elif $ORIGINAL_PLUGIN_LD_FOR_TARGET --help 2>/dev/null | grep plugin-opt > /dev/null; then + gcc_cv_lto_plugin=yes + fi + if test x"$gcc_cv_lto_plugin" = xyes; then + +$as_echo "#define HAVE_LTO_PLUGIN 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_lto_plugin" >&5 +$as_echo "$gcc_cv_lto_plugin" >&6; } +fi + case "$target" in # All TARGET_ABI_OSF targets. alpha*-*-osf* | alpha*-*-linux* | alpha*-*-*bsd*) diff --git a/gcc/configure.ac b/gcc/configure.ac index 4e7ace4..776c71f 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3149,6 +3149,26 @@ if test x"$demangler_in_ld" = xyes; then AC_MSG_RESULT($gcc_cv_ld_demangle) fi +AC_MSG_CHECKING(linker plugin support) +gcc_cv_lto_plugin=no +if test -f ../lto-plugin/Makefile ; then + if test $in_tree_ld = yes -a x"$ORIGINAL_PLUGIN_LD_FOR_TARGET=" = x"$gcc_cv_ld"; then + if test x"$ld_is_gold" = xyes; then + gcc_cv_lto_plugin=yes + elif test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2; then \ + gcc_cv_lto_plugin=yes + fi + # Check if the linker supports --plugin-opt option + elif $ORIGINAL_PLUGIN_LD_FOR_TARGET --help 2>/dev/null | grep plugin-opt > /dev/null; then + gcc_cv_lto_plugin=yes + fi +fi +if test x"$gcc_cv_lto_plugin" = xyes; then + AC_DEFINE(HAVE_LTO_PLUGIN, 1, +[Define if your linker supports plugin.]) +fi +AC_MSG_RESULT($gcc_cv_lto_plugin) + case "$target" in # All TARGET_ABI_OSF targets. alpha*-*-osf* | alpha*-*-linux* | alpha*-*-*bsd*) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 8d67e96..800c592 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -7587,23 +7587,21 @@ types in separate translation units to be linked together (undefined behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be issued. The behavior is still undefined at runtime. -If object files containing GIMPLE bytecode are stored in a library -archive, say @file{libfoo.a}, it is possible to extract and use them -in an LTO link if you are using @command{gold} as the linker (which, -in turn requires GCC to be configured with @option{--enable-gold}). -To enable this feature, use the flag @option{-fuse-linker-plugin} at -link-time: +If object files containing GIMPLE bytecode are stored in a library archive, say +@file{libfoo.a}, it is possible to extract and use them in an LTO link if you +are using a linker with linker plugin support. To enable this feature, use +the flag @option{-fuse-linker-plugin} at link-time: @smallexample gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo @end smallexample -With the linker plugin enabled, @command{gold} will extract the needed +With the linker plugin enabled, the linker will extract the needed GIMPLE files from @file{libfoo.a} and pass them on to the running GCC to make them part of the aggregated GIMPLE image to be optimized. -If you are not using @command{gold} and/or do not specify -@option{-fuse-linker-plugin} then the objects inside @file{libfoo.a} +If you are not using a linker with linker plugin support and/or do not +enable linker plugin then the objects inside @file{libfoo.a} will be extracted and linked as usual, but they will not participate in the LTO optimization process. @@ -7667,13 +7665,20 @@ files in LTO mode (via @option{-flto}). Disabled by default. @item -fuse-linker-plugin -Enables the extraction of objects with GIMPLE bytecode information -from library archives. This option relies on features available only -in @command{gold}, so to use this you must configure GCC with -@option{--enable-gold}. See @option{-flto} for a description on the -effect of this flag and how to use it. - -Disabled by default. +Enables the use of linker plugin during link time optimization. This option +relies on the linker plugin support in linker that is available in @code{gold} +or in GNU ld 2.21.51 or newer.. + +This option enables the extraction of object files with GIMPLE bytecode out of +library archives. This improves the quality of optimization by exposing more +code the the link time optimizer. This information specify what symbols +can be accessed externally (by non-LTO object or during dynamic linking). +Resulting code quality improvements on binaries (and shared libaries that do +use hidden visibility) is similar to @code{-fwhole-program}. See +@option{-flto} for a description on the effect of this flag and how to use it. + +Enabled by default when LTO support in GCC is enabled and GCC was compiled +with linker supporting plugins (GNU ld or @code{gold}). @item -fcprop-registers @opindex fcprop-registers @@ -621,6 +621,13 @@ proper position among the other output files. */ # endif #endif +/* Conditional to test whether plugin is used or not. */ +#ifdef HAVE_LTO_PLUGIN +#define PLUGIN_COND "!fno-use-linker-plugin" +#else +#define PLUGIN_COND "fuse-linker-plugin" +#endif + /* -u* was put back because both BSD and SysV seem to support it. */ /* %{static:} simply prevents an error message if the target machine @@ -634,7 +641,7 @@ proper position among the other output files. */ #define LINK_COMMAND_SPEC "\ %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ %(linker) \ - %{fuse-linker-plugin: \ + %{"PLUGIN_COND": \ -plugin %(linker_plugin_file) \ -plugin-opt=%(lto_wrapper) \ -plugin-opt=-fresolution=%u.res \ @@ -6779,7 +6786,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" if (num_linker_inputs > 0 && !seen_error () && print_subprocess_help < 2) { int tmp = execution_count; +#ifdef HAVE_LTO_PLUGIN + const char *fno_use_linker_plugin = "fno-use-linker-plugin"; +#else const char *fuse_linker_plugin = "fuse-linker-plugin"; +#endif /* We'll use ld if we can't find collect2. */ if (! strcmp (linker_name_spec, "collect2")) @@ -6789,8 +6800,13 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" linker_name_spec = "ld"; } +#ifdef HAVE_LTO_PLUGIN + if (!switch_matches (fno_use_linker_plugin, + fno_use_linker_plugin + strlen (fno_use_linker_plugin), 0)) +#else if (switch_matches (fuse_linker_plugin, fuse_linker_plugin + strlen (fuse_linker_plugin), 0)) +#endif { linker_plugin_file_spec = find_a_file (&exec_prefixes, LTOPLUGINSONAME, R_OK, |