This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] BZ #5784: Build libpthread.a with ld -r
On Wed, Sep 5, 2012 at 12:15 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Wed, 5 Sep 2012, H.J. Lu wrote:
>
>> +$(objpfx)libpthread.a: $(patsubst %,$(objpfx)%.o,\
>> + $(filter-out $(libpthread-shared-only-routines),\
>> + $(all-libpthread-routines)))
>> + cd $(objpfx) && \
>> + $(CC) -r -nostdlib -o $(@:$(objpfx)%=%) $(patsubst $(objpfx)%,%,$^)
>
> This looks rather like it builds libpthread.a as an object file ... it
> would seem safer for it to be an archive containing a single object file,
> rather than directly being an object file itself.
>
Here is the patch to build libpthread.o first. OK to install?
Thanks.
--
H.J.
---
diff --git a/ChangeLog b/ChangeLog
index c375cc1..8e3667f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-05 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #5784]
+ * extra-lib.mk: Skip archive if it is in $(skip-lib.a)
+
2012-09-04 H.J. Lu <hongjiu.lu@intel.com>
[BZ #13679]
diff --git a/extra-lib.mk b/extra-lib.mk
index a2293c5..9dd387e 100644
--- a/extra-lib.mk
+++ b/extra-lib.mk
@@ -58,6 +58,9 @@ endif
# Use o-iterator.mk to generate a rule for each flavor of library.
ifneq (,$(filter-out .os .oS,$(object-suffixes-$(lib))))
+object-suffixes-left = $(filter-out .os .oS,$(object-suffixes-$(lib)))
+# Skip static archive if it is in $(skip-lib.a).
+ifneq (,$(filter-out $(skip-lib.a),$(lib).a))
define o-iterator-doit
$(objpfx)$(patsubst %,$(libtype$o),$(lib:lib%=%)): \
$(patsubst %,$(objpfx)%$o,\
@@ -65,9 +68,9 @@ $(objpfx)$(patsubst %,$(libtype$o),$(lib:lib%=%)): \
$(all-$(lib)-routines))); \
$$(build-extra-lib)
endef
-object-suffixes-left = $(filter-out .os .oS,$(object-suffixes-$(lib)))
include $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
endif
+endif
ifneq (,$(filter .os,$(object-suffixes-$(lib))))
$(objpfx)$(patsubst %,$(libtype.os),$(lib:lib%=%)): \
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index f4b7ff3..b9cac3e 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,11 @@
+2012-09-05 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #5784]
+ * Makefile (skip-lib.a): New. Set to libpthread.a.
+ (extra-objs): Add libpthread.o.
+ ($(objpfx)libpthread.o): New rule.
+ ($(objpfx)libpthread.a): Likewise.
+
2012-09-01 Joseph Myers <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
diff --git a/nptl/Makefile b/nptl/Makefile
index 614f0ce..f3afaa6 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -26,6 +26,9 @@ extra-libs := libpthread
extra-libs-others := $(extra-libs)
install-lib-ldscripts := libpthread.so
+skip-lib.a := libpthread.a
+extra-objs = libpthread.o
+
routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \
libc-cleanup
shared-only-routines = forward
@@ -386,6 +389,15 @@ $(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
mv -f $@.new $@
endif
+$(objpfx)libpthread.o: $(patsubst %,$(objpfx)%.o,\
+ $(filter-out $(libpthread-shared-only-routines),\
+ $(all-libpthread-routines)))
+ cd $(objpfx) && \
+ $(CC) -r -nostdlib -o $(@F) $(patsubst $(objpfx)%,%,$^)
+
+$(objpfx)libpthread.a: $(objpfx)libpthread.o
+ cd $(objpfx) && \
+ $(AR) $(CREATE_ARFLAGS) $(@F) $(patsubst $(objpfx)%,%,$^)
# 'pthread_self' is a simple memory or register load. Setting up the
# stack frame is more work than the actual operation. Disable the
--
1.7.11.4