[PATCH] buildsys: Add support for bringing librt as needed.

William Pitcock nenolod at dereferenced.org
Wed Nov 16 10:24:28 UTC 2011


This helps improve portability with broken applications which expect that linking
directly against libc will bring in mq_*() functions.

Signed-off-by: William Pitcock <nenolod at dereferenced.org>
---
 Makefile.in |    6 ++++++
 Rules.mak   |    8 ++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 0f8b48e..4da9533 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -349,6 +349,12 @@ ifeq ($(UCLIBC_HAS_BACKTRACE),y)
 		echo "GROUP ( $(UBACKTRACE_ASNEEDED) )" >> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
 	fi
 endif
+ifeq ($(UCLIBC_HAS_REALTIME),y)
+# Add the AS_NEEDED entry for librt.so
+	if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so ] ; then \
+		echo "GROUP ( $(LIBRT_ASNEEDED) )" >> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
+	fi
+endif
 ifeq ($(UCLIBC_HAS_THREADS),y)
 ifneq ($(LINUXTHREADS_OLD),y)
 ifeq ($(HARDWIRED_ABSPATH),y)
diff --git a/Rules.mak b/Rules.mak
index a5b6901..c8ffdaf 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -119,6 +119,7 @@ export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION ABI_VERSION LC_ALL
 LIBC := libc
 SHARED_LIBNAME := $(LIBC).so.$(ABI_VERSION)
 UBACKTRACE_DSO := libubacktrace.so.$(ABI_VERSION)
+LIBRT_DSO := librt.so.$(ABI_VERSION)
 ifneq ($(findstring  $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sparc64 x86_64 ),)
 UCLIBC_LDSO_NAME := ld64-uClibc
 ARCH_NATIVE_BIT := 64
@@ -523,6 +524,13 @@ export UBACKTRACE_ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-n
 else
 export UBACKTRACE_ASNEEDED:=""
 endif
+ifeq ($(UCLIBC_HAS_REALTIME),y)
+# Only used in installed libc.so linker script
+LIBRT_FULL_NAME := $(RUNTIME_PREFIX)lib/$(LIBRT_DSO)
+export LIBRT_ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-needed && echo "AS_NEEDED ( $(LIBRT_FULL_NAME) )" || echo "$(LIBRT_FULL_NAME)")
+else
+export LIBRT_ASNEEDED:=""
+endif
 endif
 
 # Add a bunch of extra pedantic annoyingly strict checks
-- 
1.7.7.3



More information about the uClibc mailing list