diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 2f8fe74f2d5d2963784d9e2bb819a6f2b999d79e..41b3a09536fe9a4172d8e7ddcf53f99d99a539a0 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 3ddc85445d274de5cdeee4af62c73a5b862273fe..31faff066e176823726a34ef6233dda9ac5d4dfb 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 b66cc9fcce29ee91033099ba4a196ece954b53be..b7428cfe35dae6e3aaab330ef9ef69b5bd5f72ad 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 eaada1f3d5d99be3fd4d205dfb4a4a0a11851b7a..fb9be461e87ba32f4b7b5145150f2d375b7e2a48 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 2d9482677f2d12d0cac68fe2592e1843b4dc139b..5d906f651311236f78cd335b4ea31319efb33675 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 08f67243dcd97d4af23a61f618352139739a4ed2..606a0fd6ba626a508bd18c3fc708b38c280f97da 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 743bb056ddbc62b9e2902f4ab66ae46c60a1f7ec..01227b605af6912931a17c51080b19baa8cb8820 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)