Hi,

we ran into a problem with plugin-enabled LTO and a cross-native build of the 
compiler for Windows: collect2.c isn't able to find the linker in LTO mode.
The reason is that, at configure time, PLUGIN_LD is set to the $gcc_cv_ld, but 
the machinery in collect2.c is set up for suffixes instead:

  static const char *const ld_suffix    = "ld";
  static const char *const plugin_ld_suffix = PLUGIN_LD;
  static const char *const real_ld_suffix = "real-ld";
  static const char *const collect_ld_suffix = "collect-ld";
  static const char *const nm_suffix    = "nm";
  static const char *const gnm_suffix   = "gnm";
#ifdef LDD_SUFFIX
  static const char *const ldd_suffix   = LDD_SUFFIX;
#endif
  static const char *const strip_suffix = "strip";
  static const char *const gstrip_suffix = "gstrip";

so the attached patch attempts to pass a suffix in this case too.

Tested on i586-suse-linux and with the aforementioned cross-native build, OK 
for the mainline?


2012-05-04  Eric Botcazou  <ebotca...@adacore.com>

        * configure.ac (PLUGIN_LD): Rename into...
        (PLUGIN_LD_SUFFIX): ...this and strip the target_alias triplet.
        * config.in: Regenerate.
        * configure: Likewise.
        * collect2.c (main): Set plugin_ld_suffix to PLUGIN_LD_SUFFIX.


-- 
Eric Botcazou
Index: configure.ac
===================================================================
--- configure.ac	(revision 187074)
+++ configure.ac	(working copy)
@@ -2001,15 +2001,15 @@ else
 fi])
 
 ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld
-PLUGIN_LD=`basename $gcc_cv_ld`
+PLUGIN_LD_SUFFIX=`basename $gcc_cv_ld | sed -e "s,$target_alias-,,"`
 AC_ARG_WITH(plugin-ld,
 [AS_HELP_STRING([[--with-plugin-ld=[ARG]]], [specify the plugin linker])],
 [if test x"$withval" != x; then
    ORIGINAL_PLUGIN_LD_FOR_TARGET="$withval"
-   PLUGIN_LD="$withval"
+   PLUGIN_LD_SUFFIX=`echo $withval | sed -e "s,$target_alias-,,"`
  fi])
 AC_SUBST(ORIGINAL_PLUGIN_LD_FOR_TARGET)
-AC_DEFINE_UNQUOTED(PLUGIN_LD, "$PLUGIN_LD", [Specify plugin linker])
+AC_DEFINE_UNQUOTED(PLUGIN_LD_SUFFIX, "$PLUGIN_LD_SUFFIX", [Specify plugin linker])
 
 # Check to see if we are using gold instead of ld
 AC_MSG_CHECKING(whether we are using gold)
Index: collect2.c
===================================================================
--- collect2.c	(revision 187074)
+++ collect2.c	(working copy)
@@ -1018,7 +1018,7 @@ int
 main (int argc, char **argv)
 {
   static const char *const ld_suffix	= "ld";
-  static const char *const plugin_ld_suffix = PLUGIN_LD;
+  static const char *const plugin_ld_suffix = PLUGIN_LD_SUFFIX;
   static const char *const real_ld_suffix = "real-ld";
   static const char *const collect_ld_suffix = "collect-ld";
   static const char *const nm_suffix	= "nm";

Reply via email to