public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use newly built crt*.o files to build shared objects [BZ #22362]
@ 2017-10-29  2:07 H.J. Lu
  2017-10-29 12:35 ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2017-10-29  2:07 UTC (permalink / raw)
  To: GNU C Library

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 extends multi-lib support from nptl/Makefile 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.

OK for master?

H.J.
---
	[BZ #22362]
	* 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.
	* nptl/Makefile: Don't include multidir.mk.
	($(objpfx)multidir.mk): Removed.
---
 config.make.in |  1 +
 configure      |  6 ++++++
 configure.ac   |  5 +++++
 csu/Makefile   | 11 +++++++++++
 nptl/Makefile  | 10 ----------
 5 files changed, 23 insertions(+), 10 deletions(-)

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..b9803be0ff 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,9 @@ $(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-target-directory)
+	ln -f $(objpfx)/$(@F) $@
+endif
diff --git a/nptl/Makefile b/nptl/Makefile
index d819349f43..314cbda46a 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -401,16 +401,6 @@ tests: $(test-modules)
 endif
 
 ifeq ($(build-shared),yes)
-
-# Set the `multidir' variable by grabbing the variable from the compiler.
-# We do it once and save the result in a generated makefile.
--include $(objpfx)multidir.mk
-$(objpfx)multidir.mk: $(common-objpfx)config.make
-	$(make-target-directory)
-	dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
-	echo "multidir := $$dir" > $@T
-	mv -f $@T $@
-
 crti-objs := crti.o
 crtn-objs := crtn.o
 ifneq (,$(patsubst .,,$(multidir)))
-- 
2.13.6

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Use newly built crt*.o files to build shared objects [BZ #22362]
  2017-10-29  2:07 [PATCH] Use newly built crt*.o files to build shared objects [BZ #22362] H.J. Lu
@ 2017-10-29 12:35 ` Andreas Schwab
  2017-10-29 16:21   ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2017-10-29 12:35 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library

On Okt 28 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:

> diff --git a/csu/Makefile b/csu/Makefile
> index fd668a5d00..b9803be0ff 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,9 @@ $(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-target-directory)
> +	ln -f $(objpfx)/$(@F) $@
> +endif

Only a symlink . -> $(multidir) is needed.

> diff --git a/nptl/Makefile b/nptl/Makefile
> index d819349f43..314cbda46a 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile

Same here.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Use newly built crt*.o files to build shared objects [BZ #22362]
  2017-10-29 12:35 ` Andreas Schwab
@ 2017-10-29 16:21   ` H.J. Lu
  2017-11-01 14:44     ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2017-10-29 16:21 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 1325 bytes --]

On Sun, Oct 29, 2017 at 5:35 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> On Okt 28 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>
>> diff --git a/csu/Makefile b/csu/Makefile
>> index fd668a5d00..b9803be0ff 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,9 @@ $(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-target-directory)
>> +     ln -f $(objpfx)/$(@F) $@
>> +endif
>
> Only a symlink . -> $(multidir) is needed.

Like this?

>> diff --git a/nptl/Makefile b/nptl/Makefile
>> index d819349f43..314cbda46a 100644
>> --- a/nptl/Makefile
>> +++ b/nptl/Makefile
>
> Same here.

If the updated patch is OK, I will submit a separate patch to convert
nptl/Makefile to symlink.

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Use-newly-built-crt-.o-files-to-build-shared-objects.patch --]
[-- Type: text/x-patch, Size: 3845 bytes --]

From 3242db2138de7e0786ee3806f8bd016925d06099 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 28 Oct 2017 17:41:16 -0700
Subject: [PATCH] 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.
---
 Makerules      |  9 +++++++++
 config.make.in |  1 +
 configure      |  6 ++++++
 configure.ac   |  5 +++++
 csu/Makefile   | 10 ++++++++++
 5 files changed, 31 insertions(+)

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
-- 
2.13.6


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Use newly built crt*.o files to build shared objects [BZ #22362]
  2017-10-29 16:21   ` H.J. Lu
@ 2017-11-01 14:44     ` H.J. Lu
  2017-11-06 14:09       ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2017-11-01 14:44 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: GNU C Library

On Sun, Oct 29, 2017 at 9:21 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Oct 29, 2017 at 5:35 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> On Okt 28 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>>
>>> diff --git a/csu/Makefile b/csu/Makefile
>>> index fd668a5d00..b9803be0ff 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,9 @@ $(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-target-directory)
>>> +     ln -f $(objpfx)/$(@F) $@
>>> +endif
>>
>> Only a symlink . -> $(multidir) is needed.
>
> Like this?
>

Any other comments or objections?

-- 
H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Use newly built crt*.o files to build shared objects [BZ #22362]
  2017-11-01 14:44     ` H.J. Lu
@ 2017-11-06 14:09       ` H.J. Lu
  0 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 2017-11-06 14:09 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: GNU C Library

On Wed, Nov 1, 2017 at 7:43 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Oct 29, 2017 at 9:21 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Sun, Oct 29, 2017 at 5:35 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>>> On Okt 28 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>>>
>>>> diff --git a/csu/Makefile b/csu/Makefile
>>>> index fd668a5d00..b9803be0ff 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,9 @@ $(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-target-directory)
>>>> +     ln -f $(objpfx)/$(@F) $@
>>>> +endif
>>>
>>> Only a symlink . -> $(multidir) is needed.
>>
>> Like this?
>>
>
> Any other comments or objections?
>

I am checking it in.


-- 
H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-11-06 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-29  2:07 [PATCH] Use newly built crt*.o files to build shared objects [BZ #22362] H.J. Lu
2017-10-29 12:35 ` Andreas Schwab
2017-10-29 16:21   ` H.J. Lu
2017-11-01 14:44     ` H.J. Lu
2017-11-06 14:09       ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).