This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 12/13] libstdc++, libgfortran gthr workaround for musl
- From: Jeff Law <law at redhat dot com>
- To: Szabolcs Nagy <szabolcs dot nagy at arm dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Gregor Richards <gregor dot richards at uwaterloo dot ca>, Rich Felker <dalias at libc dot org>, Szabolcs Nagy <nsz at port70 dot net>
- Date: Wed, 22 Apr 2015 07:17:34 -0600
- Subject: Re: [PATCH 12/13] libstdc++, libgfortran gthr workaround for musl
- Authentication-results: sourceware.org; auth=none
- References: <55354A4A dot 4060702 at arm dot com> <55354C98 dot 8040204 at arm dot com>
On 04/20/2015 12:59 PM, Szabolcs Nagy wrote:
libgcc/gthr-posix.h uses weak reference logic to determine if libpthread
is linked into the application or not. This is broken unless there is
special workaround with libc internal knowledge and even then static
linking needs further manual link time workaround, so this was disabled
for os/generic in libstdc++v3 and for musl in libgfortran.
The change minimizes the impact on other setups, but I think the weak
ref logic should be disabled by default, it is never entirely correct.
Conforming code can crash on a glibc setup too:
$ cat a.cpp
#include <pthread.h>
void(*f)(void) = (void(*)(void))pthread_key_create;
int main(){}
$ g++ -static a.cpp -lpthread
$ ./a.out
Segmentation fault
I reported this previously at
https://gcc.gnu.org/ml/gcc/2014-11/msg00246.html
libgfortran/Changelog:
2015-04-16 Szabolcs Nagy <szabolcs.nagy@arm.com>
* acinclude.m4 (GTHREAD_USE_WEAK): Define as 0 for *-*-musl*.
* configure: Regenerate.
libstdc++v3/Changelog:
2015-04-16 Szabolcs Nagy <szabolcs.nagy@arm.com>
* config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
* configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
OK. Please install on the trunk.
jeff