[git commit master 1/1] nptl: Fix libpthread build when UCLIBC_LINUX_SPECIFIC is disabled

Carmelo Amoroso carmelo.amoroso at st.com
Mon Sep 20 13:03:17 UTC 2010


commit: http://git.uclibc.org/uClibc/commit/?id=0f85b228aa3f5ea797e10e69deae54ea898cb44a
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

NPTL library needs both madvise and statfs symbols, that are guarded
by UCLIBC_LINUX_SPECIFIC option. This fix provides these symbols too
when NPTL is used, indipendently by UCLIBC_LINUX_SPECIFIC choice.
Otherwise libpthread link fails as below:

LD libpthread-0.9.32-git.so
libpthread/nptl/libpthread_so.a(pthread_create.oS): In function `__free_tcb':
pthread_create.c:(.text+0x1184): undefined reference to `madvise'
libpthread/nptl/libpthread_so.a(sem_open.oS): In function `__where_is_shmfs':
sem_open.c:(.text+0x764): undefined reference to `statfs'
collect2: ld returned 1 exit status
make: *** [lib/libpthread.so] Error 1

Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
---
 include/sys/mman.h                    |    2 +-
 libc/sysdeps/linux/common/Makefile.in |    6 +++++-
 libc/sysdeps/linux/common/statfs.c    |    3 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/sys/mman.h b/include/sys/mman.h
index d46b922..470209e 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -100,7 +100,7 @@ static __inline__ int msync (void *__addr, size_t __len, int __flags) { return 0
 
 #endif
 
-#if defined __USE_BSD && defined __UCLIBC_LINUX_SPECIFIC__
+#if defined __USE_BSD && (defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__)
 /* Advise the system about particular usage patterns the program follows
    for the region starting at ADDR and extending LEN bytes.  */
 extern int madvise (void *__addr, size_t __len, int __advice) __THROW;
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index 1711e80..4222912 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -26,12 +26,16 @@ endif
 
 ifneq ($(UCLIBC_LINUX_SPECIFIC),y)
 # we need these internally: fstatfs.c statfs.c
-CSRC := $(filter-out capget.c capset.c inotify.c ioperm.c iopl.c madvise.c \
+CSRC := $(filter-out capget.c capset.c inotify.c ioperm.c iopl.c \
 	modify_ldt.c personality.c ppoll.c prctl.c readahead.c reboot.c \
 	remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \
 	sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \
 	splice.c vmsplice.c tee.c signalfd.c swapoff.c swapon.c \
 	sync_file_range.c sysctl.c sysinfo.c timerfd.c uselib.c vhangup.c,$(CSRC))
+ifneq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+# we need madvise.c in NPTL
+CSRC := $(filter-pout madvise.c,$(CSRC))
+endif
 endif
 
 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
diff --git a/libc/sysdeps/linux/common/statfs.c b/libc/sysdeps/linux/common/statfs.c
index 2f8548d..d24bc9d 100644
--- a/libc/sysdeps/linux/common/statfs.c
+++ b/libc/sysdeps/linux/common/statfs.c
@@ -16,6 +16,7 @@ extern __typeof(statfs) __libc_statfs attribute_hidden;
 #define __NR___libc_statfs __NR_statfs
 _syscall2(int, __libc_statfs, const char *, path, struct statfs *, buf)
 
-#if defined __UCLIBC_LINUX_SPECIFIC__
+#if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__
+/* statfs is used by NPTL, so it must exported in case */
 weak_alias(__libc_statfs,statfs)
 #endif
-- 
1.7.1



More information about the uClibc-cvs mailing list