This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: libgomp crash fix
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Bruno Haible <bruno at clisp dot org>
- Cc: Richard Henderson <rth at redhat dot com>, Tom Tromey <tromey at redhat dot com>, gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 20 Nov 2006 11:18:45 +0100
- Subject: Re: libgomp crash fix
- References: <200611081433.10102.bruno@clisp.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Nov 08, 2006 at 02:33:08PM +0100, Bruno Haible wrote:
> Bug #28468 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28468)
> causes a crash of nearly every valid program that parallelizes a loop
> through OMP when OMP_NUM_THREADS > 1.
> 2006-11-07 Bruno Haible <bruno@clisp.org>
>
> * config/tls.m4 (GCC_CHECK_TLS): Also check whether the libc supports
> TLS via __thread.
>
> *** config/tls.m4 2006-09-19 03:48:06.000000000 +0200
> --- config/tls.m4.new 2006-11-08 01:47:33.000000000 +0100
> ***************
> *** 11,17 ****
> LDFLAGS="-static $LDFLAGS"
> AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }],
> [have_tls=yes], [have_tls=no], [])
> ! LDFLAGS="$save_LDFLAGS"],
> [have_tls=no],
> [AC_COMPILE_IFELSE([__thread int foo;], [have_tls=yes], [have_tls=no])]
> )])
> --- 11,53 ----
> LDFLAGS="-static $LDFLAGS"
> AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }],
> [have_tls=yes], [have_tls=no], [])
> ! LDFLAGS="$save_LDFLAGS"
> ! if test $have_tls = yes; then
> ! dnl So far, the binutils and the compiler support TLS.
> ! dnl Also check whether the libc supports TLS, i.e. whether a variable
> ! dnl with __thread linkage has a different address in different threads.
> ! save_LDFLAGS="$LDFLAGS"
> ! LDFLAGS="-lpthread $LDFLAGS"
I think you should use -pthread instead of -lpthread here (and put it into
CFLAGS too temporarily), to make it more portable, or try all of nothing,
-pthread and -lpthread, i.e. add a for loop trying to compile and run the program
3 times.
Look at libgomp/configure.ac for its test for -pthread vs. -lpthread.
Jakub