about summary refs log tree commit diff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-11-06 08:29:48 -0800
committerH.J. Lu <hjl.tools@gmail.com>2017-11-06 08:29:57 -0800
commitabcb584d0eae7270b35e1b3fed1f9661e26b8be0 (patch)
tree135e0a2bd7688a052a8bc3b1ddc9cbce570d3873
parent4e2dff67beeb063cb36fe100d9d2b3f2f88d80c6 (diff)
downloadglibc-abcb584d0eae7270b35e1b3fed1f9661e26b8be0.tar.gz
glibc-abcb584d0eae7270b35e1b3fed1f9661e26b8be0.tar.xz
glibc-abcb584d0eae7270b35e1b3fed1f9661e26b8be0.zip
Use newly built crt*.o files to build shared objects [BZ #22362]
When multi-lib GCC is used to build glibc, the search order of GCC driver
for crt*.o is -B*/`gcc -print-multi-directory`, the installed diretory,
-B*/.  This patch adds multi-lib support to csu/Makefile so that
-B/glibc-build-directory/csu/ will pick up the newly built crt*.o.

Tested on x86-64 for i686 and x32.

	[BZ #22362]
	* Makerules (make-link-multidir): New.
	* config.make.in (multidir): New.
	* configure.ac (libc_cv_multidir): New.  AC_SUBST.
	* configure: Regenerated.
	* csu/Makefile [$(multidir) != .](multilib-extra-objs): New.
	[$(multidir) != .](extra-objs): Add $(multilib-extra-objs).
	[$(multidir) != .]($(addprefix $(objpfx)$(multidir)/, $(install-lib))):
	New target.
-rw-r--r--ChangeLog12
-rw-r--r--Makerules9
-rw-r--r--config.make.in1
-rwxr-xr-xconfigure6
-rw-r--r--configure.ac5
-rw-r--r--csu/Makefile10
6 files changed, 43 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index acd573cfc3..57c99d6562 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-11-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #22362]
+	* Makerules (make-link-multidir): New.
+	* config.make.in (multidir): New.
+	* configure.ac (libc_cv_multidir): New.  AC_SUBST.
+	* configure: Regenerated.
+	* csu/Makefile [$(multidir) != .](multilib-extra-objs): New.
+	[$(multidir) != .](extra-objs): Add $(multilib-extra-objs).
+	[$(multidir) != .]($(addprefix $(objpfx)$(multidir)/, $(install-lib))):
+	New target.
+
 2017-11-06  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #22402]
diff --git a/Makerules b/Makerules
index bbfbefe33f..522de25cfd 100644
--- a/Makerules
+++ b/Makerules
@@ -1079,6 +1079,11 @@ rm -f $@.new
 $(SHELL) $(..)scripts/rellns-sh $< $@.new
 mv -f $@.new $@
 endef
+define make-link-multidir
+$(patsubst %/,cd %,$(objpfx)); \
+  $(LN_S) . $(multidir) 2> /dev/null; \
+  test -L $(multidir)
+endef
 else
 # If we have no symbolic links don't bother with rellns-sh.
 define make-link
@@ -1086,6 +1091,10 @@ rm -f $@.new
 $(LN_S) $< $@.new
 mv -f $@.new $@
 endef
+define make-link-multidir
+$(make-target-directory)
+ln -f $(objpfx)/$(@F) $@
+endef
 endif
 
 ifeq (yes,$(build-shared))
diff --git a/config.make.in b/config.make.in
index fd2dbc91d1..bd84a5747d 100644
--- a/config.make.in
+++ b/config.make.in
@@ -21,6 +21,7 @@ includedir = @includedir@
 datarootdir = @datarootdir@
 localstatedir = @libc_cv_localstatedir@
 localedir = @localedir@
+multidir= @libc_cv_multidir@
 
 # Should we use and build ldconfig?
 use-ldconfig = @use_ldconfig@
diff --git a/configure b/configure
index 6010977c58..c8697d9b1a 100755
--- a/configure
+++ b/configure
@@ -594,6 +594,7 @@ mach_interface_list
 DEFINES
 static_nss
 profile
+libc_cv_multidir
 libc_cv_pie_default
 libc_cv_pic_default
 shared
@@ -6698,6 +6699,11 @@ fi
 $as_echo "$libc_cv_pie_default" >&6; }
 
 
+# Set the `multidir' variable by grabbing the variable from the compiler.
+# We do it once and save the result in a generated makefile.
+libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
+
+
 
 
 
diff --git a/configure.ac b/configure.ac
index 148f7d1682..9f25c9fa0f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1783,6 +1783,11 @@ fi
 rm -f conftest.*])
 AC_SUBST(libc_cv_pie_default)
 
+# Set the `multidir' variable by grabbing the variable from the compiler.
+# We do it once and save the result in a generated makefile.
+libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
+AC_SUBST(libc_cv_multidir)
+
 AC_SUBST(profile)
 AC_SUBST(static_nss)
 
diff --git a/csu/Makefile b/csu/Makefile
index fd668a5d00..e42a32b3eb 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -77,6 +77,11 @@ crtstuff = crti crtn
 install-lib += $(crtstuff:=.o)
 extra-objs += $(crtstuff:=.o)
 
+ifneq ($(multidir),.)
+multilib-extra-objs = $(addprefix $(multidir)/, $(install-lib))
+extra-objs += $(multilib-extra-objs)
+endif
+
 extra-objs += abi-note.o init.o
 asm-CPPFLAGS += -I$(objpfx).
 
@@ -147,3 +152,8 @@ $(objpfx)abi-tag.h: $(..)abi-tags
 	done
 	if test -r $@.new; then mv -f $@.new $@; \
 	else echo >&2 'This configuration not matched in $<'; exit 1; fi
+
+ifneq ($(multidir),.)
+$(addprefix $(objpfx)$(multidir)/, $(install-lib)): $(addprefix $(objpfx), $(install-lib))
+	$(make-link-multidir)
+endif