diff mbox

libpthread: modify CFLAGS-pthread_once.c to avoid earlier setting being replaced

Message ID CAC1BbcSPAEPonN6pcq1vVPFdOMbCj7QN6qc0gbMCouTtxHtuHQ@mail.gmail.com
State Rejected
Headers show

Commit Message

Bernhard Reutner-Fischer Aug. 29, 2014, 3:19 p.m. UTC
On 29 August 2014 05:21, Yang Yingliang <yangyingliang@huawei.com> wrote:
> I use uclibc in arch arm. The CFLAGS-pthread_once.c has been set
> to -DNOT_IN_libc -DIS_IN_libpthread in
> libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch.
> But it will be replaced by -fexceptions -fasynchronous-unwind-tables in
> libpthread/nptl/Makefile.in.
>
> If CFLAGS-pthread_once.c has no -DIS_IN_libpthread the testcase
> tst-once3 in test/nptl/ will be failed. The reason is pthread_once
> calls another pthread_cleanup_push() which is not under IS_IN_libpthread
> so that clear_once_control do not be called when the thread is canceled.
> So pthread_once will hang up when it's called second time.

yea, but the other parts of libpthread.{so,a} suffer from the same
problem, don't they?
I.e. We should rather do something like:

$(libpthread_libc_OBJS:.o=.c)), $(libc-shared-routines-y))
 libc-static-routines-y := $(filter-out $(notdir
$(libpthread_libc_OBJS:.o=.c)), $(libc-static-routines-y))
@@ -62,6 +64,8 @@ else
 librt-a-y += $(librt_OBJS)
 endif
 librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS)
+$(librt_OBJS) $(librt_OBJS:.o=.os): CFLAGS += -DNOT_IN_libc -DIS_IN_librt
+

 ifeq ($(UCLIBC_CTOR_DTOR),y)
 START_FILE-libpthread.so :=
$(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crti.o


(and check LT and LT.old if they need the same; and remove the now
redundant spots-on).

What do you think?

TIA,
>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  libpthread/nptl/Makefile.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
> index 0008822..1b9ba8c 100644
> --- a/libpthread/nptl/Makefile.in
> +++ b/libpthread/nptl/Makefile.in
> @@ -186,7 +186,7 @@ CFLAGS-forward.c = -fexceptions
>  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 \
> +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
> --
> 1.8.0
>
>
> _______________________________________________
> uClibc mailing list
> uClibc@uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc

Comments

Yang Yingliang Aug. 30, 2014, 9:58 a.m. UTC | #1
On 2014/8/29 23:19, Bernhard Reutner-Fischer wrote:
> On 29 August 2014 05:21, Yang Yingliang <yangyingliang@huawei.com> wrote:
>> I use uclibc in arch arm. The CFLAGS-pthread_once.c has been set
>> to -DNOT_IN_libc -DIS_IN_libpthread in
>> libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch.
>> But it will be replaced by -fexceptions -fasynchronous-unwind-tables in
>> libpthread/nptl/Makefile.in.
>>
>> If CFLAGS-pthread_once.c has no -DIS_IN_libpthread the testcase
>> tst-once3 in test/nptl/ will be failed. The reason is pthread_once
>> calls another pthread_cleanup_push() which is not under IS_IN_libpthread
>> so that clear_once_control do not be called when the thread is canceled.
>> So pthread_once will hang up when it's called second time.
> 
> yea, but the other parts of libpthread.{so,a} suffer from the same
> problem, don't they?

Hi,

Other parts don't have this problem, because IS_IN_libpthread is defined by
CFLAGS-nptl = -DNOT_IN_libc -DIS_IN_libpthread $(SSP_ALL_CFLAGS), 
CFLAGS-pthread = $(SSP_ALL_CFLAGS) -DNOT_IN_libc -DIS_IN_libpthread.


> I.e. We should rather do something like:
> 
> diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
> index 0008822..228afe0 100644
> --- a/libpthread/nptl/Makefile.in
> +++ b/libpthread/nptl/Makefile.in
> @@ -41,6 +41,8 @@ libpthread-a-y := $(libpthread-static-y:.o=.os)
>  else
>  libpthread-a-y := $(libpthread-static-y)
>  endif
> +$(libpthread-so-y) $(libpthread-nonshared-y) $(libpthread-static-y)
> $(libpthread-a-y) : \
> + CFLAGS += -DNOT_IN_libc -DIS_IN_libpthread
> 
>  libc-shared-routines-y := $(filter-out $(notdir
> $(libpthread_libc_OBJS:.o=.c)), $(libc-shared-routines-y))
>  libc-static-routines-y := $(filter-out $(notdir
> $(libpthread_libc_OBJS:.o=.c)), $(libc-static-routines-y))
> @@ -62,6 +64,8 @@ else
>  librt-a-y += $(librt_OBJS)
>  endif
>  librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS)
> +$(librt_OBJS) $(librt_OBJS:.o=.os): CFLAGS += -DNOT_IN_libc -DIS_IN_librt
> +
> 
>  ifeq ($(UCLIBC_CTOR_DTOR),y)
>  START_FILE-libpthread.so :=
> $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crti.o
> 
> 
> (and check LT and LT.old if they need the same; and remove the now
> redundant spots-on).
> 
> What do you think?

I checked the LT and LT.old, the IS_IN_libthread is defined by
CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread and
CFLAGS-dir_linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread.

Regards,
Yang

> 
> TIA,
>>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>>  libpthread/nptl/Makefile.in | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
>> index 0008822..1b9ba8c 100644
>> --- a/libpthread/nptl/Makefile.in
>> +++ b/libpthread/nptl/Makefile.in
>> @@ -186,7 +186,7 @@ CFLAGS-forward.c = -fexceptions
>>  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 \
>> +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
>> --
>> 1.8.0
>>
>>
>> _______________________________________________
>> uClibc mailing list
>> uClibc@uclibc.org
>> http://lists.busybox.net/mailman/listinfo/uclibc
> 
> .
>
diff mbox

Patch

diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index 0008822..228afe0 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -41,6 +41,8 @@  libpthread-a-y := $(libpthread-static-y:.o=.os)
 else
 libpthread-a-y := $(libpthread-static-y)
 endif
+$(libpthread-so-y) $(libpthread-nonshared-y) $(libpthread-static-y)
$(libpthread-a-y) : \
+ CFLAGS += -DNOT_IN_libc -DIS_IN_libpthread

 libc-shared-routines-y := $(filter-out $(notdir