diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | Rules.mak | 6 | ||||
-rw-r--r-- | libc/Makefile | 16 | ||||
-rw-r--r-- | libc/sysdeps/linux/mips/Makefile | 19 | ||||
-rw-r--r-- | libpthread/Makefile | 11 | ||||
-rw-r--r-- | libpthread/nptl/Makefile | 300 | ||||
-rw-r--r-- | libpthread/nptl/Rules.mak | 10 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/mips/Makefile | 46 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/pthread/Makefile | 102 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/unix/sysv/linux/Makefile | 118 | ||||
-rw-r--r-- | utils/Makefile | 12 |
11 files changed, 474 insertions, 169 deletions
@@ -350,8 +350,9 @@ defconfig: extra/config/conf clean: - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \; @$(RM) -r tmp lib include/bits libc/tmp _install - $(RM) libc/obj.* headers + $(RM) libc/obj.* libc/obj-* headers $(MAKE) -C test clean + $(MAKE) -C utils clean $(MAKE) -C ldso clean $(MAKE) -C libc/misc/internals clean $(MAKE) -C libc/misc/wchar clean @@ -302,6 +302,12 @@ PTINC := -I$(PTDIR)sysdeps/$(TARGET_ARCH) \ -I$(PTDIR)sysdeps/pthread endif +# +# Thread objects linked into C library. +# +PTCOBJST := $(TOPDIR)libc/obj-pthread-libc +PTCOBJSH := $(TOPDIR)libc/obj-pthread-libc_shared + ifeq ($(UCLIBC_BUILD_RELRO),y) LDFLAGS+=-z relro endif diff --git a/libc/Makefile b/libc/Makefile index b03596712..5f6b399ff 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -52,7 +52,7 @@ all: halfclean $(LIBNAME_TARGET) $(DO_SHARED) # the wildcard will be evaluated when `make` is run instead of when the make # target is evaluated. That means if you run `rm obj.* ; make`, the wildcard # will evaluate to no files :(. -$(LIBNAME) shared_$(LIBNAME) ar-target: subdirs +$(LIBNAME) shared_$(LIBNAME) ar-target: subdirs objs-pthread-libc $(RM) $(LIBNAME) shared_$(LIBNAME) objs=`cat obj.*` ; \ $(AR) $(ARFLAGS) $(LIBNAME) $$objs && \ @@ -71,9 +71,7 @@ $(LIBNAME) shared_$(LIBNAME) ar-target: subdirs done cp $(LIBNAME) shared_$(LIBNAME) $(AR) $(ARFLAGS) $(LIBNAME) misc/internals/static.o -ifeq ($(PTHREADS_NATIVE),y) - $(AR) d $(LIBNAME) libc-lowlevellock.os -endif + $(AR) $(ARFLAGS) $(LIBNAME) `cat "$(PTCOBJST)"` $(RANLIB) $(LIBNAME) $(LIBNAME_TARGET): $(LIBNAME) @@ -82,9 +80,7 @@ $(LIBNAME_TARGET): $(LIBNAME) $(INSTALL) -m 644 $(LIBNAME) $(TOPDIR)lib shared: shared_$(LIBNAME) -ifeq ($(PTHREADS_NATIVE),y) - $(AR) d shared_$(LIBNAME) libc-tls.o libc-lowlevellock.o -endif + $(AR) $(ARFLAGS) shared_$(LIBNAME) `cat "$(PTCOBJSH)"` $(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \ --whole-archive shared_$(LIBNAME) \ $(TOPDIR)libc/misc/internals/interp.o --no-whole-archive \ @@ -106,7 +102,7 @@ tags: clean: subdirs_clean halfclean @$(RM) -r tmp $(RM) include/asm include/linux include/bits - $(RM) obj.* + $(RM) obj.* obj-* subdirs: $(patsubst %, _dir_%, $(DIRS)) subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS)) @@ -117,4 +113,8 @@ $(patsubst %, _dir_%, $(DIRS)) : dummy $(patsubst %, _dirclean_%, $(DIRS)) : dummy $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean +objs-pthread-libc: + $(RM) $(PTCOBJST) $(PTCOBJSH) + $(MAKE) -C ../libpthread $@ + .PHONY: dummy subdirs diff --git a/libc/sysdeps/linux/mips/Makefile b/libc/sysdeps/linux/mips/Makefile index 67524daac..bcfcb0b59 100644 --- a/libc/sysdeps/linux/mips/Makefile +++ b/libc/sysdeps/linux/mips/Makefile @@ -28,15 +28,9 @@ SSRC=bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S syscall.S pipe.S SOBJS=$(patsubst %.S,%.o, $(SSRC)) CSRC=__longjmp.c brk.c setjmp_aux.c mmap.c __syscall_error.c \ - cacheflush.c pread_write.c sysmips.c _test_and_set.c #sigaction.c + cacheflush.c pread_write.c sysmips.c _test_and_set.c sigaction.c COBJS=$(patsubst %.c,%.o, $(CSRC)) -ifeq ($(PTHREADS_NATIVE),y) -COBJS += $(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o \ - $(PTDIR)sysdeps/unix/sysv/linux/libc-lowlevellock.o \ - $(PTDIR)sysdeps/unix/sysv/linux/libc-lowlevellock.os -endif - OBJS=$(SOBJS) $(COBJS) OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) @@ -87,17 +81,6 @@ $(TOPDIR)lib/crtn.o: $(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o endif -ifeq ($(PTHREADS_NATIVE),y) -$(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o: - $(MAKE) -C $(PTDIR)sysdeps/$(TARGET_ARCH) libc-tls.o - -$(PTDIR)sysdeps/unix/sysv/linux/libc-lowlevellock.o: - $(MAKE) -C $(PTDIR)sysdeps/unix/sysv/linux libc-lowlevellock.o - -$(PTDIR)sysdeps/unix/sysv/linux/libc-lowlevellock.os: - $(MAKE) -C $(PTDIR)sysdeps/unix/sysv/linux libc-lowlevellock.os -endif - headers: $(LN) -fs ../libc/sysdeps/linux/mips/sgidefs.h $(TOPDIR)/include/ # $(LN) -fs ../libc/sysdeps/linux/mips/regdef.h $(TOPDIR)/include/ diff --git a/libpthread/Makefile b/libpthread/Makefile index a7317dc4e..3184435a6 100644 --- a/libpthread/Makefile +++ b/libpthread/Makefile @@ -80,6 +80,13 @@ ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) $(INSTALL) -m 644 $(LIBTHREAD_DB) $(TOPDIR)lib endif +objs-pthread-libc: +ifeq ($(strip $(PTHREADS_NATIVE)),y) + $(MAKE) -C nptl $@ +else + touch $(PTCOBJST) $(PTCOBJSH) +endif + $(OBJS): %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ @@ -93,7 +100,9 @@ ifeq ($(strip $(PTHREADS_NATIVE)),y) $(LD) $(LDFLAGS_NOSTRIP) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \ -o $(LIBPTHREAD_SHARED_FULLNAME) $(SHARED_START_FILES) --whole-archive $(LIBPTHREAD_SHARED_ARCHIVE) \ --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \ - -L$(TOPDIR)lib -lc -ldl $(LDADD_LIBFLOAT) $(LIBGCC) \ + -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) \ + $(TOPDIR)ldso/ldso/ld-uClibc-0.9.27.so \ + -L$(TOPDIR)ldso/libdl -ldl \ $(SHARED_END_FILES) else $(LD) $(LDFLAGS_NOSTRIP) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \ diff --git a/libpthread/nptl/Makefile b/libpthread/nptl/Makefile index 668fad09c..fec473cde 100644 --- a/libpthread/nptl/Makefile +++ b/libpthread/nptl/Makefile @@ -1,7 +1,6 @@ -# Makefile for uClibc's pthread library +# Makefile for uClibc's NPTL pthread library (Portions stolen from glibc.) # -# Copyright (C) 2002 Erik Andersen <andersen@uclibc.org> -# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org> +# Copyright (C) 2005 Steven J. Hill <sjhill@realitydiluted.com> # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU Library General Public License as published by the Free @@ -20,67 +19,280 @@ TOPDIR=../../ include $(TOPDIR)Rules.mak +include Rules.mak -# As long as there is only one subdir, we don't -# have to worry about race conditions with multiple -# $(AR)'s in subdirs running on linuxthreads.a. -DIRS = sysdeps +routines = alloca_cutoff forward libc-lowlevellock libc-cancellation +shared-only-routines = forward -#Adjust the soname version to avoid namespace collisions with glibc's libpthread -LIBPTHREAD:=../libpthread.a -ifeq ($(strip $(TARGET_ARCH)),sparc) -SYSDEPS_DIR:=$(TARGET_ARCH)/sparc32 -else -SYSDEPS_DIR:=$(TARGET_ARCH) -endif -#This stuff will not compile without at least -O1 -CFLAGS :=$(CFLAGS:-O0=-O1) +libpthread-routines = init vars events version \ + pthread_create pthread_exit pthread_detach \ + pthread_join pthread_tryjoin pthread_timedjoin \ + pthread_self pthread_equal pthread_yield \ + pthread_getconcurrency pthread_setconcurrency \ + pthread_getschedparam pthread_setschedparam \ + pthread_setschedprio \ + pthread_attr_init pthread_attr_destroy \ + pthread_attr_getdetachstate pthread_attr_setdetachstate \ + pthread_attr_getguardsize pthread_attr_setguardsize \ + pthread_attr_getschedparam pthread_attr_setschedparam \ + pthread_attr_getschedpolicy pthread_attr_setschedpolicy \ + pthread_attr_getinheritsched \ + pthread_attr_setinheritsched \ + pthread_attr_getscope pthread_attr_setscope \ + pthread_attr_getstackaddr pthread_attr_setstackaddr \ + pthread_attr_getstacksize pthread_attr_setstacksize \ + pthread_attr_getstack pthread_attr_setstack \ + pthread_getattr_np \ + pthread_mutex_init pthread_mutex_destroy \ + pthread_mutex_lock pthread_mutex_trylock \ + pthread_mutex_timedlock pthread_mutex_unlock \ + pthread_mutexattr_init pthread_mutexattr_destroy \ + pthread_mutexattr_getpshared \ + pthread_mutexattr_setpshared \ + pthread_mutexattr_gettype pthread_mutexattr_settype \ + pthread_rwlock_init pthread_rwlock_destroy \ + pthread_rwlock_rdlock pthread_rwlock_timedrdlock \ + pthread_rwlock_wrlock pthread_rwlock_timedwrlock \ + pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \ + pthread_rwlock_unlock \ + pthread_rwlockattr_init pthread_rwlockattr_destroy \ + pthread_rwlockattr_getpshared \ + pthread_rwlockattr_setpshared \ + pthread_rwlockattr_getkind_np \ + pthread_rwlockattr_setkind_np \ + pthread_cond_init pthread_cond_destroy \ + pthread_cond_wait pthread_cond_timedwait \ + pthread_cond_signal pthread_cond_broadcast \ + old_pthread_cond_init old_pthread_cond_destroy \ + old_pthread_cond_wait old_pthread_cond_timedwait \ + old_pthread_cond_signal old_pthread_cond_broadcast \ + pthread_condattr_init pthread_condattr_destroy \ + pthread_condattr_getpshared pthread_condattr_setpshared \ + pthread_condattr_getclock pthread_condattr_setclock \ + pthread_spin_init pthread_spin_destroy \ + pthread_spin_lock pthread_spin_trylock \ + pthread_spin_unlock \ + pthread_barrier_init pthread_barrier_destroy \ + pthread_barrier_wait \ + pthread_barrierattr_init pthread_barrierattr_destroy \ + pthread_barrierattr_getpshared \ + pthread_barrierattr_setpshared \ + pthread_key_create pthread_key_delete \ + pthread_getspecific pthread_setspecific \ + pthread_sigmask pthread_kill \ + pthread_cancel pthread_testcancel \ + pthread_setcancelstate pthread_setcanceltype \ + pthread_once \ + old_pthread_atfork pthread_atfork \ + pthread_getcpuclockid \ + pthread_clock_gettime pthread_clock_settime \ + sem_init sem_destroy \ + sem_open sem_close sem_unlink \ + sem_getvalue \ + sem_wait sem_trywait sem_timedwait sem_post \ + cleanup cleanup_defer cleanup_compat \ + cleanup_defer_compat unwind \ + pt-longjmp pt-cleanup\ + cancellation \ + lowlevellock \ + pt-vfork \ + ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \ + ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \ + ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek ptw-llseek \ + ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \ + ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \ + ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \ + ptw-sigwait \ + pt-raise pt-system \ + flockfile ftrylockfile funlockfile \ + sigaction \ + herrno res pt-allocrtsig \ + pthread_kill_other_threads \ + pthread_getaffinity pthread_setaffinity \ + pthread_attr_getaffinity pthread_attr_setaffinity \ + cleanup_routine unwind-forcedunwind +# pthread_setuid pthread_seteuid pthread_setreuid \ +# pthread_setresuid \ +# pthread_setgid pthread_setegid pthread_setregid \ +# pthread_setresgid + +libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind +libpthread-static-only-routines = pthread_atfork + +CFLAGS-pthread_atfork.c = -DNOT_IN_libc + +# Since cancellation handling is in large parts handled using exceptions +# we have to compile some files with exception handling enabled, some +# even with asynchronous unwind tables. + +# init.c contains sigcancel_handler(). +CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables +# The unwind code itself, +CFLAGS-unwind.c = -fexceptions +CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables + +# The following three functions must be async-cancel safe. +CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables + +# These are internal functions which similar functionality as setcancelstate +# and setcanceltype. +CFLAGS-cancellation.c = -fasynchronous-unwind-tables +CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables + +# Calling pthread_exit() must cause the registered cancel handlers to +# be executed. Therefore exceptions have to be thrown through this +# function. +CFLAGS-pthread_exit.c = -fexceptions + +# Among others, __pthread_unwind is forwarded. This function must handle +# exceptions. +CFLAGS-forward.c = -fexceptions + +# The following are cancellation points. Some of the functions can +# block and therefore temporarily enable asynchronous cancellation. +# Those must be compiled asynchronous unwind tables. +CFLAGS-pthread_testcancel.c = -fexceptions +CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \ + -fasynchronous-unwind-tables +CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables + +# These are the function wrappers we have to duplicate here. +CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-lockf.c = -fexceptions +CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables + +CFLAGS-pt-system.c = -fexceptions +# +# The rest of this file is uClibc specific. +# + +libpthread-os-routines = pthread_yield +libpthread-misc-routines = pthread_rwlock_rdlock pthread_rwlock_timedrdlock \ + pthread_rwlock_wrlock pthread_rwlock_timedwrlock \ + pthread_rwlock_unlock pthread_cond_wait \ + pthread_cond_timedwait pthread_cond_signal \ + pthread_cond_broadcast pthread_spin_init \ + pthread_spin_destroy pthread_spin_lock \ + pthread_spin_trylock pthread_spin_unlock \ + pthread_barrier_wait pthread_sigmask \ + pthread_kill pthread_once \ + pthread_getcpuclockid sem_wait \ + sem_trywait sem_timedwait \ + sem_post pt-longjmp \ + lowlevellock pt-vfork \ + ptw-close ptw-read ptw-write \ + ptw-fcntl ptw-accept ptw-connect \ + ptw-recv ptw-recvfrom ptw-recvmsg \ + ptw-send ptw-sendmsg ptw-sendto \ + ptw-fsync ptw-lseek ptw-llseek \ + ptw-msync ptw-nanosleep ptw-open \ + ptw-open64 ptw-pause ptw-pread \ + ptw-pread64 ptw-pwrite ptw-pwrite64 \ + ptw-tcdrain ptw-wait ptw-waitpid \ + ptw-msgrcv ptw-msgsnd ptw-sigwait \ + pt-raise flockfile ftrylockfile \ + funlockfile sigaction \ + pthread_kill_other_threads \ + pthread_getaffinity \ + pthread_setaffinity \ + pthread_attr_getaffinity \ + pthread_attr_setaffinity \ + unwind-forcedunwind + +DIRS := sysdeps/pthread sysdeps/$(TARGET_ARCH) sysdeps/unix/sysv/linux \ + sysdeps/unix/sysv/linux/$(TARGET_ARCH) -# set up system dependencies include dirs (NOTE: order matters!) -PTDIR = $(TOPDIR)libpthread/nptl/ -SYSDEPINC = -I$(PTDIR)sysdeps/unix \ - -I$(PTDIR)sysdeps/unix/sysv/linux \ - -I$(PTDIR)sysdeps/unix/sysv/linux/$(TARGET_ARCH) \ - -I$(PTDIR)sysdeps/$(TARGET_ARCH) \ - -I$(PTDIR)sysdeps/pthread \ - -I$(PTDIR)sysdeps \ - -I$(TOPDIR)libc/sysdeps/linux/$(TARGET_ARCH) \ - -I$(TOPDIR)ldso/include -CFLAGS += $(SYSDEPINC) +CSRC-LIBP-ST = $(patsubst %, %.c, $(filter-out $(libpthread-os-routines) \ + $(libpthread-misc-routines) \ + $(libpthread-shared-only-routines), \ + $(libpthread-routines))) -CSRC=init.c vars.c events.c pthread_create.c pthread_exit.c +CSRC-LIBP-SH = $(patsubst %, %.c, $(filter-out $(libpthread-os-routines) \ + $(libpthread-misc-routines) \ + $(libpthread-static-only-routines) pt-allocrtsig, \ + $(libpthread-routines))) -COBJS=$(patsubst %.c,%.o, $(CSRC)) -OBJS=$(COBJS) +CSRC-LIBC-ST = $(patsubst %, %.c, $(filter-out $(shared-only-routines) \ + libc-lowlevellock, $(routines))) -# We need to make sure that we put all the top-level $(OBJS) into -# our archive before executing subdirs. That way, when $(AR) is -# run in the subdirs, it'll bump the generic top-level objects -# out of our archive in favor of the machine-specific ones. -all: version.h $(LIBPTHREAD) subdirs +CSRC-LIBC-SH = $(patsubst %, %.c, $(filter-out libc-lowlevellock, $(routines))) + +COBJ-LIBP-ST = $(patsubst %.c, %.o, $(CSRC-LIBP-ST)) +COBJ-LIBP-SH = $(patsubst %.c, %.os, $(CSRC-LIBP-SH)) +COBJ-LIBC-ST = $(patsubst %.c, %.o, $(CSRC-LIBC-ST)) +COBJ-LIBC-SH = $(patsubst %.c, %.os, $(CSRC-LIBC-SH)) + +ar-target all: version.h banner.h $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) subdirs +ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) + $(STRIPTOOL) -X --strip-debug -R .note -R .comment \ + $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) +else + $(STRIPTOOL) -x -R .note -R .comment \ + $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) +endif + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_STATIC_ARCHIVE) $(COBJ-LIBP-ST) + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_SHARED_ARCHIVE) $(COBJ-LIBP-SH) version.h: - @echo "#define VERSION \""$(VERSION)"\"" > version.h + @echo "#define VERSION \""$(VERSION)"\"" > $@ + +banner.h: Banner + sed 's/\(.*\)/"\1\\n"/' $< > $@ + +$(COBJ-LIBP-ST): %.o : %.c + $(CC) $(CFLAGS-$<) $(CFLAGS-LIBP) -c $< -o $@ + +$(COBJ-LIBP-SH): %.os : %.c + $(CC) $(CFLAGS-$<) $(CFLAGS-LIBP) -DSHARED -c $< -o $@ + +$(COBJ-LIBC-ST): %.o : %.c + $(CC) $(CFLAGS-$<) $(CFLAGS-LIBC) -c $< -o $@ -$(LIBPTHREAD) ar-target: $(OBJS) - $(AR) $(ARFLAGS) $(LIBPTHREAD) $(OBJS) +$(COBJ-LIBC-SH): %.os : %.c + $(CC) $(CFLAGS-$<) $(CFLAGS-LIBC) -DSHARED -c $< -o $@ -$(COBJS): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ +objs-pthread-libc: $(COBJ-LIBC-ST) $(COBJ-LIBC-SH) ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) - $(STRIPTOOL) -X --strip-debug -R .note -R .comment $*.o + $(STRIPTOOL) -X --strip-debug -R .note -R .comment \ + $(COBJ-LIBC-ST) $(COBJ-LIBC-SH) else - $(STRIPTOOL) -x -R .note -R .comment $*.o + $(STRIPTOOL) -x -R .note -R .comment \ + $(COBJ-LIBC-ST) $(COBJ-LIBC-SH) endif + @for objfile in $(COBJ-LIBC-ST); do \ + echo ../libpthread/nptl/$$objfile >> $(PTCOBJST); \ + done + @for objfile in $(COBJ-LIBC-SH); do \ + echo ../libpthread/nptl/$$objfile >> $(PTCOBJSH); \ + done + $(MAKE) -C sysdeps/$(TARGET_ARCH) $@ + $(MAKE) -C sysdeps/unix/sysv/linux $@ + $(MAKE) -C sysdeps/unix/sysv/linux/$(TARGET_ARCH) $@ clean: subdirs_clean - $(RM) *.[oa] *~ core version.h + $(RM) *.o *.os *~ core banner.h version.h subdirs: $(patsubst %, _dir_%, $(DIRS)) subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS)) -$(patsubst %, _dir_%, $(DIRS)): $(LIBPTHREAD) +$(patsubst %, _dir_%, $(DIRS)): $(MAKE) -C $(patsubst _dir_%, %, $@) $(patsubst %, _dirclean_%, $(DIRS)): diff --git a/libpthread/nptl/Rules.mak b/libpthread/nptl/Rules.mak index c3970d235..9fbad743b 100644 --- a/libpthread/nptl/Rules.mak +++ b/libpthread/nptl/Rules.mak @@ -5,9 +5,9 @@ LIBPTHREAD_STATIC_ARCHIVE := libpthread.a LIBPTHREAD_SHARED_ARCHIVE := libpthread-shared.a -CFLAGS-NPTL := $(CFLAGS:-O0=-O2) \ - -I$(PTDIR) \ - -I$(TOPDIR)ldso/include \ - -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -std=gnu99 +CFLAGS-LIBC := $(CFLAGS:-O0=-O2) -I$(PTDIR) -I$(TOPDIR)ldso/include \ + -std=gnu99 +ASFLAGS-LIBC := $(filter-out -std=gnu99, $(CFLAGS-LIBC)) -D__ASSEMBLER__ -ASFLAGS-NPTL := $(filter-out -std=gnu99, $(CFLAGS-NPTL)) -D__ASSEMBLER__ +CFLAGS-LIBP := $(CFLAGS-LIBC) -DNOT_IN_libc=1 -DIS_IN_libpthread=1 +ASFLAGS-LIBP := $(filter-out -std=gnu99, $(CFLAGS-LIBP)) -D__ASSEMBLER__ diff --git a/libpthread/nptl/sysdeps/mips/Makefile b/libpthread/nptl/sysdeps/mips/Makefile index 29ee02c5a..2528194f3 100644 --- a/libpthread/nptl/sysdeps/mips/Makefile +++ b/libpthread/nptl/sysdeps/mips/Makefile @@ -1,4 +1,4 @@ -# Makefile for uClibc's NPTL pthread library +# Makefile for uClibc NPTL pthread library (MIPS) # # Copyright (C) 2005 Steven J. Hill <sjhill@realitydiluted.com> # @@ -19,21 +19,41 @@ TOPDIR=../../../../ include $(TOPDIR)Rules.mak +include ../../Rules.mak -# -# FIX ME: We should probably be including 'nptl-sysdep.S' which needs -# the new '__syscall_error' function for per-thread 'errno'. Maybe -# this work and maybe it will not. -# -SOBJS = $(patsubst %.S,%.o, $(filter-out nptl-sysdep.S, $(wildcard *.S))) +COBJ-LIBC-ST = $(patsubst %.c, %.o, $(wildcard *.c)) + +AOBJ-LIBP-ST = $(patsubst %.S, %.o, $(wildcard *.S)) +AOBJ-LIBP-SH = $(patsubst %.S, %.os, $(wildcard *.S)) + +ar-target all: $(AOBJ-LIBP-ST) $(AOBJ-LIBP-SH) +ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) + $(STRIPTOOL) -X --strip-debug -R .note -R .comment \ + $(AOBJ-LIBP-ST) $(AOBJ-LIBP-SH) +else + $(STRIPTOOL) -x -R .note -R .comment $(AOBJ-LIBP-ST) $(AOBJ-LIBP-SH) +endif + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_STATIC_ARCHIVE) $(AOBJ-LIBP-ST) + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_SHARED_ARCHIVE) $(AOBJ-LIBP-SH) + +$(AOBJ-LIBP-ST): %.o : %.S + $(CC) $(ASFLAGS) $(ASFLAGS-NPTL) -c $< -o $@ -OBJS = $(SOBJS) +$(AOBJ-LIBP-SH): %.os : %.S + $(CC) $(ASFLAGS) $(ASFLAGS-NPTL) -DSHARED -c $< -o $@ -all: $(OBJS) +$(COBJ-LIBC-ST): %.o : %.c + $(CC) $(CFLAGS-LIBC) -c $< -o $@ -$(SOBJS): %.o : %.S - echo $(PTDIR) - $(CC) $(ASFLAGS) -c $< -o $@ +objs-pthread-libc: $(COBJ-LIBC-ST) +ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) + $(STRIPTOOL) -X --strip-debug -R .note -R .comment $(COBJ-LIBC-ST) +else + $(STRIPTOOL) -x -R .note -R .comment $(COBJ-LIBC-ST) +endif + @for objfile in $(COBJ-LIBC-ST); do \ + echo ../libpthread/nptl/sysdeps/mips/$$objfile >> $(PTCOBJST); \ + done clean: - $(RM) *.[oa] *~ core + $(RM) *.o *.os *~ core diff --git a/libpthread/nptl/sysdeps/pthread/Makefile b/libpthread/nptl/sysdeps/pthread/Makefile index 207e10fad..0bd102d6e 100644 --- a/libpthread/nptl/sysdeps/pthread/Makefile +++ b/libpthread/nptl/sysdeps/pthread/Makefile @@ -1,52 +1,58 @@ -# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. -# This file is part of the GNU C Library. -# Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# The GNU C Library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. - -ifeq ($(subdir),csu) -CFLAGS-libc-start.c += -I../nptl -routines += unwind-resume -shared-only-routines += unwind-resume -CFLAGS-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables -endif - -ifeq ($(subdir),nptl) -libpthread-sysdep_routines += errno-loc -endif - -ifeq ($(subdir),rt) -librt-sysdep_routines += timer_routines librt-cancellation rt-unwind-resume -librt-shared-only-routines += rt-unwind-resume -CPPFLAGS-timer_routines.c = -I../nptl -CFLAGS-librt-cancellation.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-rt-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables - -ifeq (yes,$(build-shared)) -$(objpfx)tst-timer: $(objpfx)librt.so $(shared-thread-library) +# Makefile for uClibc NPTL pthread library (pthread) +# +# Copyright (C) 2005 Steven J. Hill <sjhill@realitydiluted.com> +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Library General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more +# details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Makefile for uClibc + +TOPDIR=../../../../ +include $(TOPDIR)Rules.mak +include ../../Rules.mak + +# +# NOTE: glibc puts flockfile.c, ftrylockfile.c, funlockfile.c, and +# pt-longjmp.c in libc and libpthread. For uClibc, they are +# in libc only. +# +CSRC = pthread_barrier_wait.c pthread_cond_broadcast.c pthread_cond_signal.c \ + pthread_cond_timedwait.c pthread_cond_wait.c pthread_getcpuclockid.c \ + pthread_once.c pthread_rwlock_rdlock.c pthread_rwlock_timedrdlock.c \ + pthread_rwlock_timedwrlock.c pthread_rwlock_unlock.c \ + pthread_rwlock_wrlock.c pthread_sigmask.c pthread_spin_destroy.c \ + pthread_spin_init.c pthread_spin_unlock.c sigaction.c \ + unwind-forcedunwind.c + +COBJ-LIBP-ST = $(patsubst %.c, %.o, $(CSRC)) +COBJ-LIBP-SH = $(patsubst %.c, %.os, $(CSRC)) + +ar-target all: $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) +ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) + $(STRIPTOOL) -X --strip-debug -R .note -R .comment \ + $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) else -$(objpfx)tst-timer: $(objpfx)librt.a $(static-thread-library) + $(STRIPTOOL) -x -R .note -R .comment \ + $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) endif + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_STATIC_ARCHIVE) $(COBJ-LIBP-ST) + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_SHARED_ARCHIVE) $(COBJ-LIBP-SH) -ifeq ($(have-forced-unwind),yes) -tests += tst-mqueue8x -CFLAGS-tst-mqueue8x.c += -fexceptions -endif -endif +$(COBJ-LIBP-ST): %.o : %.c + $(CC) $(CFLAGS-LIBP) -c $< -o $@ -ifeq ($(subdir),posix) -CFLAGS-confstr.c += -DLIBPTHREAD_VERSION='"NPTL $(version)"' -endif +$(COBJ-LIBP-SH): %.os : %.c + $(CC) $(CFLAGS-LIBP) -DSHARED -c $< -o $@ + +clean: + $(RM) *.o *.os *~ core diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile index 991398242..e29cf113b 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile @@ -1,34 +1,102 @@ -# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. -# This file is part of the GNU C Library. -# Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. +# Makefile for uClibc NPTL pthread library (Linux files) +# +# Copyright (C) 2005 Steven J. Hill <sjhill@realitydiluted.com> +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Library General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more +# details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Makefile for uClibc -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. +TOPDIR=../../../../../../ +include $(TOPDIR)Rules.mak +include ../../../../Rules.mak -# The GNU C Library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +CSRC-LIBP-ST = pt-raise.c pthread_attr_getaffinity.c \ + pthread_attr_setaffinity.c pthread_getaffinity.c \ + pthread_getcpuclockid.c pthread_kill.c \ + pthread_mutex_cond_lock.c pthread_setaffinity.c \ + pthread_yield.c sem_post.c sem_timedwait.c \ + sem_trywait.c sem_wait.c pt-fork.c -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. */ +CSRC-LIBP-SH = $(CSRC-LIBP-ST) -ifeq ($(subdir),nptl) -sysdep_routines += register-atfork unregister-atfork libc_pthread_init \ - libc_multiple_threads +CSRC-LIBC-ST = libc_pthread_init.c libc_multiple_threads.c \ + register-atfork.c unregister-atfork.c -libpthread-sysdep_routines += pt-fork pthread_mutex_cond_lock +CSRC-LIBC-SH = $(CSRC-LIBC-ST) -gen-as-const-headers += lowlevelcond.sym lowlevelrwlock.sym \ - lowlevelbarrier.sym unwindbuf.sym +ifeq ($(strip $(TARGET_ARCH)),alpha) +CSRC-LIBC-ST += libc-lowlevellock.c +CSRC-LIBP-ST += rtld-libc-lowlevellock.c endif +ifeq ($(strip $(TARGET_ARCH)),mips) +CSRC-LIBC-ST += libc-lowlevellock.c +CSRC-LIBP-ST += rtld-libc-lowlevellock.c +endif +ifeq ($(strip $(TARGET_ARCH)),powerpc) +CSRC-LIBC-ST += libc-lowlevellock.c +CSRC-LIBP-ST += rtld-libc-lowlevellock.c +endif +ifeq ($(strip $(TARGET_ARCH)),sparc) +CSRC-LIBC-ST += libc-lowlevellock.c +CSRC-LIBP-ST += rtld-libc-lowlevellock.c +endif + +COBJ-LIBP-ST = $(patsubst %.c, %.o, $(CSRC-LIBP-ST)) +COBJ-LIBP-SH = $(patsubst %.c, %.os, $(CSRC-LIBP-SH)) +COBJ-LIBC-ST = $(patsubst %.c, %.o, $(CSRC-LIBC-ST)) +COBJ-LIBC-SH = $(patsubst %.c, %.os, $(CSRC-LIBC-SH)) + +ar-target all: $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) +ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) + $(STRIPTOOL) -X --strip-debug -R .note -R .comment \ + $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) +else + $(STRIPTOOL) -x -R .note -R .comment \ + $(COBJ-LIBP-ST) $(COBJ-LIBP-SH) +endif + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_STATIC_ARCHIVE) $(COBJ-LIBP-ST) + $(AR) $(ARFLAGS) $(PTDIR)../$(LIBPTHREAD_SHARED_ARCHIVE) $(COBJ-LIBP-SH) -ifeq ($(subdir),posix) -CFLAGS-fork.c = -D_IO_MTSAFE_IO -CFLAGS-getpid.o = -fomit-frame-pointer -CFLAGS-getpid.os = -fomit-frame-pointer +$(COBJ-LIBP-ST): %.o : %.c + $(CC) $(CFLAGS-LIBP) -c $< -o $@ + +$(COBJ-LIBP-SH): %.os : %.c + $(CC) $(CFLAGS-LIBP) -DSHARED -c $< -o $@ + +$(COBJ-LIBC-ST): %.o : %.c + $(CC) $(CFLAGS-LIBC) -c $< -o $@ + +$(COBJ-LIBC-SH): %.os : %.c + $(CC) $(CFLAGS-LIBC) -DSHARED -c $< -o $@ + +objs-pthread-libc: $(COBJ-LIBC-ST) $(COBJ-LIBC-SH) +ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y) + $(STRIPTOOL) -X --strip-debug -R .note -R .comment \ + $(COBJ-LIBC-ST) $(COBJ-LIBC-SH) +else + $(STRIPTOOL) -x -R .note -R .comment \ + $(COBJ-LIBC-ST) $(COBJ-LIBC-SH) endif + @for objfile in $(COBJ-LIBC-ST); do \ + echo ../libpthread/nptl/sysdeps/unix/sysv/linux/$$objfile >> $(PTCOBJST); \ + done + @for objfile in $(COBJ-LIBC-SH); do \ + echo ../libpthread/nptl/sysdeps/unix/sysv/linux/$$objfile >> $(PTCOBJSH); \ + done + +rtld-libc-lowlevellock.c: libc-lowlevellock.c + $(LN) -fs $< $@ + +clean: + $(RM) *.o *.os *~ core rtld-libc-lowlevellock.c diff --git a/utils/Makefile b/utils/Makefile index 177d1b59f..dec011780 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -43,22 +43,22 @@ headers: readelf.c ldconfig.c ldd.c: headers readelf: readelf.c - $(CC) $(CFLAGS) $^ -o $@ - $(STRIPTOOL) -s -x -R .note -R .comment $@ + $(CC) $(CFLAGS) -Wl,-s $^ -o $@ + $(STRIPTOOL) -x -R .note -R .comment $@ ldconfig: ldconfig.c - $(CC) $(CFLAGS) $(if $(filter $(UCLIBC_STATIC_LDCONFIG),y),-static) \ + $(CC) $(CFLAGS) -Wl,-s $(if $(filter $(UCLIBC_STATIC_LDCONFIG),y),-static) \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \ $^ -o $@ - $(STRIPTOOL) -s -x -R .note -R .comment $@ + $(STRIPTOOL) -x -R .note -R .comment $@ ldd: ldd.c - $(CC) $(CFLAGS) $(PIEFLAG) \ + $(CC) $(CFLAGS) $(PIEFLAG) -Wl,-s \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \ $^ -o $@ - $(STRIPTOOL) -s -x -R .note -R .comment $@ + $(STRIPTOOL) -x -R .note -R .comment $@ iconv: ../libc/misc/wchar/wchar.c $(CC) $(CFLAGS) $(PIEFLAG) -Wl,-s \ |