From f3d533d3b5d828abef210862e9644b8ddf96c75b Mon Sep 17 00:00:00 2001
From: Alexandre Oliva <aoliva@redhat.com>
Date: Sat, 12 Feb 2011 12:02:24 +0000
Subject: [PATCH] re PR lto/47225 (cross-compile fails while configuring libgcc
 with "xgcc: fatal error: -fuse-linker-plugin, but liblto_plugin.so not
 found")

ChangeLog:
PR lto/47225
* Makefile.def (lto-plugin): Double dash for enable-shared.
(configure-gcc): Depend on all-lto-plugin.
* Makefile.in: Rebuilt.
lto-plugin/ChangeLog:
PR lto/47225
* Makefile.am (gcc_build_dir, in_gcc_libs): New.
(liblto_plugin_la_LDFLAGS): Add -module.
(copy_lto_plugin): Renamed to...
($(in_gcc_libs)): ... this.  Add mkinstalldirs.  Skip copying
of static modules.
* Makefile.in: Rebuild.
gcc/ChangeLog:
PR lto/47225
* configure.ac (gcc_cv_lto_plugin): Test for liblto_plugin.la
in the current directory.
* configure: Rebuilt.

From-SVN: r170070
---
 ChangeLog              |  7 +++++++
 Makefile.def           |  4 ++--
 Makefile.in            | 30 +++++++++++++++---------------
 gcc/ChangeLog          |  7 +++++++
 gcc/configure          |  2 +-
 gcc/configure.ac       |  2 +-
 lto-plugin/ChangeLog   | 10 ++++++++++
 lto-plugin/Makefile.am | 16 +++++++++++-----
 lto-plugin/Makefile.in | 15 +++++++++++----
 9 files changed, 65 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ac455ed53e5e..afa98d1c5b19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-02-12  Alexandre Oliva  <aoliva@redhat.com>
+
+	PR lto/47225
+	* Makefile.def (lto-plugin): Double dash for enable-shared.
+	(configure-gcc): Depend on all-lto-plugin.
+	* Makefile.in: Rebuilt.
+
 2011-02-11  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
 	* configure.ac: Remove extra bracket.
diff --git a/Makefile.def b/Makefile.def
index 5a7a0d781e10..85b582c9944f 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -146,7 +146,7 @@ host_modules= { module= libtermcap; no_check=true;
 host_modules= { module= utils; no_check=true; };
 host_modules= { module= gnattools; };
 host_modules= { module= lto-plugin; bootstrap=true;
-		extra_configure_flags=-enable-shared; };
+		extra_configure_flags=--enable-shared; };
 
 target_modules = { module= libstdc++-v3;
 		   bootstrap=true;
@@ -322,7 +322,7 @@ dependencies = { module=all-build-fixincludes; on=all-build-libiberty; };
 
 // Host modules specific to gcc.
 dependencies = { module=configure-gcc; on=configure-intl; };
-dependencies = { module=configure-gcc; on=configure-lto-plugin; };
+dependencies = { module=configure-gcc; on=all-lto-plugin; };
 dependencies = { module=configure-gcc; on=all-binutils; };
 dependencies = { module=configure-gcc; on=all-gas; };
 dependencies = { module=configure-gcc; on=all-ld; };
diff --git a/Makefile.in b/Makefile.in
index b42e227994ff..660f81322460 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -45248,7 +45248,7 @@ configure-lto-plugin:
 	libsrcdir="$$s/lto-plugin"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} $${srcdiroption} -enable-shared \
+	  --target=${target_alias} $${srcdiroption} --enable-shared \
 	  || exit 1
 @endif lto-plugin
 
@@ -45283,7 +45283,7 @@ configure-stage1-lto-plugin:
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  -enable-shared
+	  --enable-shared
 @endif lto-plugin-bootstrap
 
 .PHONY: configure-stage2-lto-plugin maybe-configure-stage2-lto-plugin
@@ -45317,7 +45317,7 @@ configure-stage2-lto-plugin:
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  -enable-shared
+	  --enable-shared
 @endif lto-plugin-bootstrap
 
 .PHONY: configure-stage3-lto-plugin maybe-configure-stage3-lto-plugin
@@ -45351,7 +45351,7 @@ configure-stage3-lto-plugin:
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  -enable-shared
+	  --enable-shared
 @endif lto-plugin-bootstrap
 
 .PHONY: configure-stage4-lto-plugin maybe-configure-stage4-lto-plugin
@@ -45385,7 +45385,7 @@ configure-stage4-lto-plugin:
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  -enable-shared
+	  --enable-shared
 @endif lto-plugin-bootstrap
 
 .PHONY: configure-stageprofile-lto-plugin maybe-configure-stageprofile-lto-plugin
@@ -45419,7 +45419,7 @@ configure-stageprofile-lto-plugin:
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  -enable-shared
+	  --enable-shared
 @endif lto-plugin-bootstrap
 
 .PHONY: configure-stagefeedback-lto-plugin maybe-configure-stagefeedback-lto-plugin
@@ -45453,7 +45453,7 @@ configure-stagefeedback-lto-plugin:
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  -enable-shared
+	  --enable-shared
 @endif lto-plugin-bootstrap
 
 
@@ -60266,14 +60266,14 @@ configure-stage3-gcc: maybe-configure-stage3-intl
 configure-stage4-gcc: maybe-configure-stage4-intl
 configure-stageprofile-gcc: maybe-configure-stageprofile-intl
 configure-stagefeedback-gcc: maybe-configure-stagefeedback-intl
-configure-gcc: maybe-configure-lto-plugin
-
-configure-stage1-gcc: maybe-configure-stage1-lto-plugin
-configure-stage2-gcc: maybe-configure-stage2-lto-plugin
-configure-stage3-gcc: maybe-configure-stage3-lto-plugin
-configure-stage4-gcc: maybe-configure-stage4-lto-plugin
-configure-stageprofile-gcc: maybe-configure-stageprofile-lto-plugin
-configure-stagefeedback-gcc: maybe-configure-stagefeedback-lto-plugin
+configure-gcc: maybe-all-lto-plugin
+
+configure-stage1-gcc: maybe-all-stage1-lto-plugin
+configure-stage2-gcc: maybe-all-stage2-lto-plugin
+configure-stage3-gcc: maybe-all-stage3-lto-plugin
+configure-stage4-gcc: maybe-all-stage4-lto-plugin
+configure-stageprofile-gcc: maybe-all-stageprofile-lto-plugin
+configure-stagefeedback-gcc: maybe-all-stagefeedback-lto-plugin
 configure-gcc: maybe-all-binutils
 
 configure-stage1-gcc: maybe-all-stage1-binutils
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9c87513bf72d..143264b80c81 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2011-02-12  Alexandre Oliva  <aoliva@redhat.com>
+
+	PR lto/47225
+	* configure.ac (gcc_cv_lto_plugin): Test for liblto_plugin.la
+	in the current directory.
+	* configure: Rebuilt.
+
 2011-02-12  Iain Sandoe  <iains@gcc.gnu.org>
 
 	* config/darwin.c (darwin_override_options): Add a hunk missed
diff --git a/gcc/configure b/gcc/configure
index f38bb6596655..340c81511793 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -23125,7 +23125,7 @@ fi
 { $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 -f ../lto-plugin/Makefile ; then
+if test -f liblto_plugin.la; 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
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 366a5aef9df4..0c065e0de9bb 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3174,7 +3174,7 @@ fi
 
 AC_MSG_CHECKING(linker plugin support)
 gcc_cv_lto_plugin=no
-if test -f ../lto-plugin/Makefile ; then
+if test -f liblto_plugin.la; 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
diff --git a/lto-plugin/ChangeLog b/lto-plugin/ChangeLog
index 1129a3784326..9355ea57dfc3 100644
--- a/lto-plugin/ChangeLog
+++ b/lto-plugin/ChangeLog
@@ -1,3 +1,13 @@
+2011-02-12  Alexandre Oliva  <aoliva@redhat.com>
+
+	PR lto/47225
+	* Makefile.am (gcc_build_dir, in_gcc_libs): New.
+	(liblto_plugin_la_LDFLAGS): Add -module.
+	(copy_lto_plugin): Renamed to...
+	($(in_gcc_libs)): ... this.  Add mkinstalldirs.  Skip copying
+	of static modules.
+	* Makefile.in: Rebuild.
+
 2011-02-07  Kai Tietz  <kai.tietz@onevision.com>
 
 	PR lto/47225
diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am
index a150f80f50c4..fd9ea625f9bf 100644
--- a/lto-plugin/Makefile.am
+++ b/lto-plugin/Makefile.am
@@ -12,6 +12,8 @@ AM_CFLAGS = -Wall -Werror
 AM_LIBTOOLFLAGS = --tag=disable-static
 
 libexecsub_LTLIBRARIES = liblto_plugin.la
+gcc_build_dir = ../gcc
+in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib))
 
 # Can be removed when libiberty becomes a normal convenience library
 Wc=-Wc,
@@ -20,13 +22,17 @@ liblto_plugin_la_SOURCES = lto-plugin.c
 liblto_plugin_la_LIBADD = \
 	$(if $(wildcard ../libiberty/pic/libiberty.a),$(Wc)../libiberty/pic/libiberty.a,)
 # Note that we intentionally override the bindir supplied by ACX_LT_HOST_FLAGS
-liblto_plugin_la_LDFLAGS = $(lt_host_flags) -bindir $(libexecsubdir) \
+liblto_plugin_la_LDFLAGS = $(lt_host_flags) -module -bindir $(libexecsubdir) \
 	$(if $(wildcard ../libiberty/pic/libiberty.a),,-Wc,../libiberty/libiberty.a)
 liblto_plugin_la_DEPENDENCIES = $(if $(wildcard \
 	../libiberty/pic/libiberty.a),../libiberty/pic/libiberty.a,)
 
-all: copy_lto_plugin
-
-copy_lto_plugin: all-am
-	$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $(libexecsub_LTLIBRARIES) `pwd`/../gcc/
+all: $(in_gcc_libs)
 
+$(in_gcc_libs) : $(gcc_build_dir)/%: %
+	@if test "X`dlname=; . ./$*; echo dlname:$$dlname`" = "Xdlname:"; then \
+	  echo WARNING: $* is static, not copying to $@ >&2 ; \
+	else \
+	  $(mkinstalldirs) $(gcc_build_dir) && \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $* `pwd`/$@ ; \
+	fi
diff --git a/lto-plugin/Makefile.in b/lto-plugin/Makefile.in
index aa14e52a031d..c5192041703d 100644
--- a/lto-plugin/Makefile.in
+++ b/lto-plugin/Makefile.in
@@ -230,6 +230,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS)
 AM_CFLAGS = -Wall -Werror
 AM_LIBTOOLFLAGS = --tag=disable-static
 libexecsub_LTLIBRARIES = liblto_plugin.la
+gcc_build_dir = ../gcc
+in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib))
 
 # Can be removed when libiberty becomes a normal convenience library
 Wc = -Wc,
@@ -238,7 +240,7 @@ liblto_plugin_la_LIBADD = \
 	$(if $(wildcard ../libiberty/pic/libiberty.a),$(Wc)../libiberty/pic/libiberty.a,)
 
 # Note that we intentionally override the bindir supplied by ACX_LT_HOST_FLAGS
-liblto_plugin_la_LDFLAGS = $(lt_host_flags) -bindir $(libexecsubdir) \
+liblto_plugin_la_LDFLAGS = $(lt_host_flags) -module -bindir $(libexecsubdir) \
 	$(if $(wildcard ../libiberty/pic/libiberty.a),,-Wc,../libiberty/libiberty.a)
 
 liblto_plugin_la_DEPENDENCIES = $(if $(wildcard \
@@ -530,10 +532,15 @@ uninstall-am: uninstall-libexecsubLTLIBRARIES
 	tags uninstall uninstall-am uninstall-libexecsubLTLIBRARIES
 
 
-all: copy_lto_plugin
+all: $(in_gcc_libs)
 
-copy_lto_plugin: all-am
-	$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $(libexecsub_LTLIBRARIES) `pwd`/../gcc/
+$(in_gcc_libs) : $(gcc_build_dir)/%: %
+	@if test "X`dlname=; . ./$*; echo dlname:$$dlname`" = "Xdlname:"; then \
+	  echo WARNING: $* is static, not copying to $@ >&2 ; \
+	else \
+	  $(mkinstalldirs) $(gcc_build_dir) && \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $* `pwd`/$@ ; \
+	fi
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
-- 
GitLab