diff mbox

Fix plugin-enabled LTO with cross-native build

Message ID 201205041235.31703.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou May 4, 2012, 10:35 a.m. UTC
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  <ebotcazou@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.

Comments

Diego Novillo May 7, 2012, 4:42 p.m. UTC | #1
On Fri, May 4, 2012 at 10:35 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:

> 2012-05-04  Eric Botcazou  <ebotcazou@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.

OK.


Diego.
diff mbox

Patch

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";