diff mbox

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

Message ID 5406BB72.60907@huawei.com
State Rejected
Headers show

Commit Message

Yang Yingliang Sept. 3, 2014, 6:55 a.m. UTC
From: Yang Yingliang <yangyingliang@huawei.com>

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.

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,
CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread and
CFLAGS-dir_linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread.

Cc: Waldemar Brodkorb <wbx@openadk.org>
Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Tested-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

---
Change note: 
  Update changelog to describe other parts' IS_IN_libpthread.
  Add Tested-by: Waldemar Brodkorb <wbx@openadk.org>.
---
 libpthread/nptl/Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 1.8.0 .

Comments

Bernhard Reutner-Fischer Sept. 4, 2014, 4:13 p.m. UTC | #1
On 3 September 2014 08:55, Yang Yingliang <yangyingliang@huawei.com> wrote:
> From: Yang Yingliang <yangyingliang@huawei.com>
>
> 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.
>
> 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,
> CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread and
> CFLAGS-dir_linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread.

These are defined but it seems to me they are not effective, no?
Please try the attached instead. The hunks in nptl/... should be moved to
Makerules, near objs: though, so it affects LT and LT.old, too.

Comments?
Thanks,
>
> Cc: Waldemar Brodkorb <wbx@openadk.org>
> Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
> Tested-by: Waldemar Brodkorb <wbx@openadk.org>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>
> ---
> Change note:
>   Update changelog to describe other parts' IS_IN_libpthread.
>   Add Tested-by: Waldemar Brodkorb <wbx@openadk.org>.
> ---
>  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 .
>
>
>
Yang Yingliang Sept. 5, 2014, 3:15 a.m. UTC | #2
On 2014/9/5 0:13, Bernhard Reutner-Fischer wrote:
> On 3 September 2014 08:55, Yang Yingliang <yangyingliang@huawei.com> wrote:
>> From: Yang Yingliang <yangyingliang@huawei.com>
>>
>> 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.
>>
>> 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,
>> CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread and
>> CFLAGS-dir_linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread.
> 
> These are defined but it seems to me they are not effective, no?
> Please try the attached instead. The hunks in nptl/... should be moved to
> Makerules, near objs: though, so it affects LT and LT.old, too.
> 
> Comments?
> Thanks,

I tried the attachment. The IS_IN_libpthread and NOT_IN_libc are defined twice
when it's compiling the source files in nptl.
One is defined by $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS)),
the other is defined by $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(<D)))).
Here $(CFLAGS-$(notdir $(<D))) is CFLAGS-nptl or CFLAGS-pthread.
They are defined twice in LT and LT.old, too.

Regards,
Yang
Bernhard Reutner-Fischer Sept. 5, 2014, 4:49 p.m. UTC | #3
On 5 September 2014 05:15, Yang Yingliang <yangyingliang@huawei.com> wrote:

> I tried the attachment. The IS_IN_libpthread and NOT_IN_libc are defined twice
> when it's compiling the source files in nptl.
> One is defined by $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS)),
> the other is defined by $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(<D)))).
> Here $(CFLAGS-$(notdir $(<D))) is CFLAGS-nptl or CFLAGS-pthread.
> They are defined twice in LT and LT.old, too.

Yea, that's a cosmetic issue that can be addressed later on.
I'll install something to the effect of the fwd0 patch.
Thanks for testing!

cheers,
Bernhard Reutner-Fischer Sept. 16, 2014, 9:18 p.m. UTC | #4
On 5 September 2014 18:49, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> On 5 September 2014 05:15, Yang Yingliang <yangyingliang@huawei.com> wrote:
>
>> I tried the attachment. The IS_IN_libpthread and NOT_IN_libc are defined twice
>> when it's compiling the source files in nptl.
>> One is defined by $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS)),
>> the other is defined by $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(<D)))).
>> Here $(CFLAGS-$(notdir $(<D))) is CFLAGS-nptl or CFLAGS-pthread.
>> They are defined twice in LT and LT.old, too.
>
> Yea, that's a cosmetic issue that can be addressed later on.
> I'll install something to the effect of the fwd0 patch.
> Thanks for testing!

I have pushed something to that effect now.
See 41537a770b46f2376e74af58ba4885749339e81e
and 95acdd4b30d856f46e3dd908a934eaeb68c9b572

Thanks for the report!
diff mbox

Patch

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