This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Provide pthread_atfork in libc_nonshared.a and libc.a.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>, Jakub Jelinek <jakub at redhat dot com>
- Cc: Roland McGrath <roland at hack dot frob dot com>
- Date: Wed, 02 Oct 2013 21:30:34 -0400
- Subject: Re: [PATCH] Provide pthread_atfork in libc_nonshared.a and libc.a.
- Authentication-results: sourceware.org; auth=none
- References: <524C90A1 dot 6050801 at redhat dot com>
On 10/02/2013 05:31 PM, Carlos O'Donell wrote:
> Tested on x86-64 with no regressions.
>
> There are no versioning requirements since this is all static libraries.
>
> Verified pthread_atfork is available in libc_nonshared.a and libc.a
> afterwards and that it's available for linking without libpthread.
>
> What kind of testcase, if any, should go along with this?
>
> Before patch:
> [carlos@koi glibc]$ gcc -o /home/carlos/testatfork /home/carlos/testatfork.c
> /tmp/ccmX2uMU.o: In function `main':
> testatfork.c:(.text+0x24): undefined reference to `pthread_atfork'
> collect2: error: ld returned 1 exit status
>
> After patch the compilation and execution succeeds and the linker map shows:
> /home/carlos/install-glibc/usr/lib64/libc_nonshared.a(libc_pthread_atfork.oS)
> ./testatfork.o (pthread_atfork)
> ...
> .text 0x00000000004006a0 0x1c /home/carlos/install-glibc/usr/lib64/libc_nonshared.a(libc_pthread_atfork.oS)
> 0x00000000004006a0 __pthread_atfork
> 0x00000000004006a0 pthread_atfork
> ...
>
> Comments?
>
> nptl/
>
> 2013-10-02 Carlos O'Donell <carlos@redhat.com>
>
> * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add libc_pthread_atfork.
> (static-only-routines): Likewise.
> * sysdeps/unix/sysv/linux/libc_pthread_atfork.c: New file.
Does anyone materially object to this fix to allow applications
to use pthread_atfork safely without requiring libpthread?
Aside from the objections that Rich raised, which are
general objections to the weakref-and-check idiom that
doesn't work with static linking.
The root cause that prompted this fix is that libselinux
has a need to use pthread_atfork and not require libpthread.
Given that pthread_atfork is a wrapper around __register_atfork
it seemed a natural fix to provide pthread_atfork in libc.a
and libc_nonshared.a.
OK to checkin?
Cheers,
Carlos.