This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 12/13] libstdc++, libgfortran gthr workaround for musl



On 22/04/15 14:17, Jeff Law wrote:
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.

I've committed this on Szabolcs' behalf with r222329.

Kyrill


jeff



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]