This is the mail archive of the gcc@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: libgomp crash fix


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


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