From 60e1758f60c2be0682dcbac7ea270b90e78ec526 Mon Sep 17 00:00:00 2001
From: Richard Henderson <rth@redhat.com>
Date: Tue, 25 Apr 2006 13:58:25 -0700
Subject: [PATCH] re PR libgomp/25865 (libgomp incorrectly detects support for
 TLS)

        PR libgomp/25865
        * configure.ac: Use GCC_CHECK_TLS.
        * acinclude.m4 (LIBGOMP_CHECK_TLS): Remove.
        * Makefile.in, aclocal.m4, configure: Regenerate.

From-SVN: r113256
---
 libgomp/ChangeLog             |  7 +++
 libgomp/Makefile.in           |  8 ++--
 libgomp/acinclude.m4          | 12 ------
 libgomp/aclocal.m4            |  6 ++-
 libgomp/configure             | 80 ++++++++++++++++++++++++++++-------
 libgomp/configure.ac          |  2 +-
 libgomp/testsuite/Makefile.in |  6 ++-
 7 files changed, 85 insertions(+), 36 deletions(-)

diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 2f8fe74f2d5d..41b3a09536fe 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-25  Richard Henderson  <rth@redhat.com>
+
+	PR libgomp/25865
+	* configure.ac: Use GCC_CHECK_TLS.
+	* acinclude.m4 (LIBGOMP_CHECK_TLS): Remove.
+	* Makefile.in, aclocal.m4, configure: Regenerate.
+
 2006-04-10  Matthias Klose  <doko@debian.org>
 
 	* testsuite/lib/libgomp.exp (libgomp_init): Recognize multilib
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 3ddc85445d27..31faff066e17 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -15,8 +15,6 @@
 @SET_MAKE@
 
 
-SOURCES = $(libgomp_la_SOURCES)
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -51,8 +49,10 @@ DIST_COMMON = $(am__configure_deps) $(srcdir)/../config.guess \
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/enable.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
-	$(top_srcdir)/../config/stdint.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/../config/stdint.m4 \
+	$(top_srcdir)/../config/tls.m4 $(top_srcdir)/acinclude.m4 \
 	$(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
diff --git a/libgomp/acinclude.m4 b/libgomp/acinclude.m4
index b66cc9fcce29..b7428cfe35da 100644
--- a/libgomp/acinclude.m4
+++ b/libgomp/acinclude.m4
@@ -1,15 +1,3 @@
-dnl Check whether the target supports TLS.
-AC_DEFUN([LIBGOMP_CHECK_TLS], [
-  LIBGOMP_ENABLE(tls, yes, [Use thread-local storage])
-  AC_CACHE_CHECK([whether the target supports thread-local storage],
-		 have_tls, [
-    AC_TRY_COMPILE([__thread int foo;],
-		   [], have_tls=$enable_tls, have_tls=no)])
-  if test $have_tls = yes; then
-    AC_DEFINE(HAVE_TLS, 1,
-	      [Define to 1 if the target supports thread-local storage.])
-  fi])
-
 dnl ----------------------------------------------------------------------
 dnl This whole bit snagged from libgfortran.
 
diff --git a/libgomp/aclocal.m4 b/libgomp/aclocal.m4
index eaada1f3d5d9..fb9be461e87b 100644
--- a/libgomp/aclocal.m4
+++ b/libgomp/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.9.5 -*- Autoconf -*-
+# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 # 2005  Free Software Foundation, Inc.
@@ -28,7 +28,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
 # Call AM_AUTOMAKE_VERSION so it can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-	 [AM_AUTOMAKE_VERSION([1.9.5])])
+	 [AM_AUTOMAKE_VERSION([1.9.6])])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
@@ -915,6 +915,8 @@ AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
 
 m4_include([../config/depstand.m4])
+m4_include([../config/enable.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/stdint.m4])
+m4_include([../config/tls.m4])
 m4_include([acinclude.m4])
diff --git a/libgomp/configure b/libgomp/configure
index 2d9482677f2d..5d906f651311 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -8611,20 +8611,9 @@ if test "${have_tls+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+    if test "$cross_compiling" = yes; then
+  cat >conftest.$ac_ext <<_ACEOF
 __thread int foo;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
 _ACEOF
 rm -f conftest.$ac_objext
 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
@@ -8648,7 +8637,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  have_tls=$enable_tls
+  have_tls=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -8656,10 +8645,71 @@ sed 's/^/| /' conftest.$ac_ext >&5
 have_tls=no
 fi
 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+else
+  cat >conftest.$ac_ext <<_ACEOF
+__thread int a; int b; int main() { return a = b; }
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+                    save_LDFLAGS="$LDFLAGS"
+      LDFLAGS="-static $LDFLAGS"
+      if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+__thread int a; int b; int main() { return a = b; }
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  have_tls=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+have_tls=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+      LDFLAGS="$save_LDFLAGS"
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+have_tls=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
 fi
 echo "$as_me:$LINENO: result: $have_tls" >&5
 echo "${ECHO_T}$have_tls" >&6
-  if test $have_tls = yes; then
+  if test "$enable_tls $have_tls" = "yes yes"; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_TLS 1
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index 08f67243dcd9..606a0fd6ba62 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -183,7 +183,7 @@ if test $ac_cv_func_clock_gettime = no; then
 fi
 
 # See if we support thread-local storage.
-LIBGOMP_CHECK_TLS
+GCC_CHECK_TLS
 
 # See what sort of export controls are availible.
 LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index 743bb056ddbc..01227b605af6 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -40,8 +40,10 @@ subdir = testsuite
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
+	$(top_srcdir)/../config/enable.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
-	$(top_srcdir)/../config/stdint.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/../config/stdint.m4 \
+	$(top_srcdir)/../config/tls.m4 $(top_srcdir)/acinclude.m4 \
 	$(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-- 
GitLab