Richard Guenther <richard.guent...@gmail.com> writes: > I think we should do the linker version checks which relate to linker-plugin > use on the plugin-linker instead. So if I specify a separate but known > buggy linker I don't want it to be used by default.
Here's a patch that does this. I'm not at all happy with the patch since it partially duplicates the logic to determine linker version numbers. While this could (and probably should) be generalized along the lines of gcc_GAS_CHECK_FEATURE and gcc_GAS_VERSION_GTE_IFELSE, even that wouldn't help immediately since such autoconf macros would still $gcc_cv_ld. As far as I can see, all those linker checks could massively benefit from an overhaul to use gcc_LD_CHECK_FEATURE etc.macros, but that's not something I want to attack. It's especially messy that there are two sets of version variables for in-tree and external linkers. Probably fodder for the build maintainers. Anyway, here's what I've got. Tested by configuring with * no --with-ld arg (i.e. /usr/ccs/bin/ld) * --with-ld=/path/to/gld-2.21 --with-gnu-ld * --with-plugin-ld=/path/to/gld-2.21 * --with-ld=/path/to/gld-2.21 --with-gnu-ld --with-plugin-ld=/usr/ccs/bin/ld and checking HAVE_LTO_PLUGIN in auto-host.h (0, 2, 2, 0). I haven't found if there are provisions for in-tree gold, though, and still cannot test that. Ok for mainline? Could the whole bunch eventually be backported to the 4.6 branch? http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00759.html http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01890.html http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01250.html and this one? Thanks. Rainer 2011-04-02 Rainer Orth <r...@cebitec.uni-bielefeld.de> * configure.ac (gcc_cv_lto_plugin): Determine lto plugin support from plugin linker. * configure: Regenerate. diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3192,14 +3192,40 @@ fi AC_MSG_CHECKING(linker plugin support) gcc_cv_lto_plugin=0 if test -f liblto_plugin.la; then + save_ld_ver="$ld_ver" + save_ld_vers_major="$ld_vers_major" + save_ld_vers_minor="$ld_vers_minor" + save_ld_is_gold="$ld_is_gold" + + ld_is_gold=no + if test $in_tree_ld = yes -a x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" = x"$gcc_cv_ld"; then - if 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=2 - elif test "$ld_is_gold" = yes -a "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -eq 20; then - gcc_cv_lto_plugin=1 - + ld_ver="GNU ld" + # FIXME: ld_is_gold? + ld_vers_major="$gcc_cv_gld_major_version" + ld_vers_minor="$gcc_cv_gld_minor_version" + else + # Determine plugin linker version. + # FIXME: Partial duplicate from above, generalize. +changequote(,)dnl + ld_ver=`$ORIGINAL_PLUGIN_LD_FOR_TARGET --version 2>/dev/null | sed 1q` + if echo "$ld_ver" | grep GNU > /dev/null; then + if echo "$ld_ver" | grep "GNU gold" > /dev/null; then + ld_is_gold=yes + ld_vers=`echo $ld_ver | sed -n \ + -e 's,^[^)]*[ ]\([0-9][0-9]*\.[0-9][0-9]*[^)]*\)) .*$,\1,p'` + else + ld_vers=`echo $ld_ver | sed -n \ + -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'` + fi + ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'` + ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'` fi - elif test x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" = x"$gcc_cv_ld" && echo "$ld_ver" | grep GNU > /dev/null; then +changequote([,])dnl + fi + + # Determine plugin support. + if echo "$ld_ver" | grep GNU > /dev/null; then # Require GNU ld or gold 2.21+ for plugin support by default. if test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -ge 21; then gcc_cv_lto_plugin=2 @@ -3207,11 +3233,12 @@ if test -f liblto_plugin.la; then elif test "$ld_is_gold" = yes -a "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -eq 20; then gcc_cv_lto_plugin=1 fi - elif test x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" != x"$gcc_cv_ld"; then - # Allow -fuse-linker-plugin if plugin linker differs from - # default/specified linker. - gcc_cv_lto_plugin=1 fi + + ld_ver="$save_ld_ver" + ld_vers_major="$save_ld_vers_major" + ld_vers_minor="$save_ld_vers_minor" + ld_is_gold="$save_ld_is_gold" fi AC_DEFINE_UNQUOTED(HAVE_LTO_PLUGIN, $gcc_cv_lto_plugin, [Define to the level of your linker's plugin support.]) -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University