This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] BZ #5784: Build libpthread.a with ld -r
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 5 Sep 2012 11:12:07 -0700
- Subject: [PATCH] BZ #5784: Build libpthread.a with ld -r
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
This patch builds libpthread.a with ld -r. Tested on x86-64 and ia32.
OK to install?
Thanks.
H.J.
---
ChangeLog | 5 +++++
extra-lib.mk | 5 ++++-
nptl/ChangeLog | 8 ++++++++
nptl/Makefile | 10 ++++++++++
4 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index c375cc1..5bee194 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 static archive if it is in $(non-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..17b7af8 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 $(non-lib.a).
+ifneq (,$(filter-out $(non-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..e44f2b0 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,11 @@
+2012-09-05 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #5784]
+ * Makefile (non-lib.a): Set to libpthread.a.
+ (extra-objs): Add libpthread.a.
+ ($(objpfx)libpthread.a): New rule.
+ (lib): Depend on $(objpfx)libpthread.a.
+
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..d859830 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -26,6 +26,9 @@ extra-libs := libpthread
extra-libs-others := $(extra-libs)
install-lib-ldscripts := libpthread.so
+non-lib.a := libpthread.a
+extra-objs = libpthread.a
+
routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \
libc-cleanup
shared-only-routines = forward
@@ -386,6 +389,13 @@ $(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
mv -f $@.new $@
endif
+$(objpfx)libpthread.a: $(patsubst %,$(objpfx)%.o,\
+ $(filter-out $(libpthread-shared-only-routines),\
+ $(all-libpthread-routines)))
+ cd $(objpfx) && \
+ $(CC) -r -nostdlib -o $(@:$(objpfx)%=%) $(patsubst $(objpfx)%,%,$^)
+
+lib: $(objpfx)libpthread.a
# '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