diff mbox

[build] Move gthr to toplevel libgcc

Message ID yddfwi68vx2.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Nov. 2, 2011, 2:02 p.m. UTC
Paolo Bonzini <bonzini@gnu.org> writes:

> Ok with a couple of changes:
>
>> 	gcc:
>> 	* gthr-posix.h, gthr-single.h, gthr.h: Move to ../libgcc.
>
> Move gthr-posix.h to config/
>
>>        * config/m32r/linux.h (SUBTARGET_CPP_SPEC): Don't define _PTHREADS
>>        if -pthread.
>>        * config/mn10300/linux.h (CPP_SPEC): Likewise.
>>        * config/netbsd.h (NETBSD_CPP_SPEC): Likewise.
>>        * config/sh/linux.h (SUBTARGET_CPP_SPEC): Likewise.
>>        * config/sol2.h (CPP_SUBTARGET_SPEC): Likewise.
>
> Don't commit these, not yet at least (well, for Solaris it's your choice).
>
>> 	* config.host (thread_header, thread_dir): New variables.
>> 	Set it depending on target_thread_file.
>
> Move to configure.ac, and remove the indirection on thread_dir (i.e. just
> set thread_header).

Here's the updated and rebased version of the patch I'm about to commit,
after regtesting on i386-pc-solaris2.11, sparc-sun-solaris2.11,
x86_64-unknown-linux-gnu, i386-apple-darwin9.8.0, and
powerpc-apple-darwin9.8.0.

Thanks.
        Rainer


2011-08-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc:
	* gthr-single.h, gthr.h: Move to ../libgcc.
	* gthr-aix.h: Move to ../libgcc/config/rs6000.
	* gthr-dce.h: Move to ../libgcc/config/pa.
	* gthr-lynx.h: Move to ../libgcc/config.
	* gthr-mipssde.h: Move to ../libgcc/config/mips.
	* gthr-posix.h: Move to ../libgcc/config.
	* gthr-rtems.h: Likewise.
	* gthr-tpf.h: Move to ../libgcc/config/s390.
	* gthr-vxworks.h: Move to ../libgcc/config.
	* gthr-win32.h: Move to ../libgcc/config/i386.
	* configure.ac (gthread_flags): Remove
	(gthr-default.h): Don't create.
	(thread_file): Don't substitute.
	* configure: Regenerate.
	* Makefile.in (GCC_THREAD_FILE): Remove.
	(GTHREAD_FLAGS): Remove.
	(libgcc.mvars): Remove GTHREAD_FLAGS.
	* config/t-vxworks (EXTRA_HEADERS): Remove.

	gcc/po:
	* EXCLUDES (gthr-aix.h, gthr-dce.h, gthr-posix.c, gthr-posix.h)
	(gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h)
	(gthr-win32.h, gthr.h): Remove.

	libgcc:
	* gthr-single.h, gthr.h: New files.
	* config/gthr-lynx.h, config/gthr-posix.h., config/gthr-rtems.h,
	config/gthr-vxworks.h, config/i386/gthr-win32.h,
	config/mips/gthr-mipssde.h, config/pa/gthr-dce.h,
	config/rs6000/gthr-aix.h, config/s390/gthr-tpf.h: New files.
	* config/i386/gthr-win32.c: Include "gthr-win32.h".
	* configure.ac (thread_header): New variable.
	Set it depending on target_thread_file.
	(gthr-default.h): Link from $thread_header.
	* configure: Regenerate.
	* Makefile.in (LIBGCC2_CFLAGS): Remove $(GTHREAD_FLAGS).

	libgfortran:
	* Makefile.am (AM_CPPFLAGS): Add
	-I$(srcdir)/$(MULTISRCTOP)../libgcc, -I$(MULTIBUILDTOP)../libgcc.
	* Makefile.in: Regenerate.
	* acinclude.m4 (LIBGFOR_CHECK_GTHR_DEFAULT): Remove.
	* configure.ac (LIBGFOR_CHECK_GTHR_DEFAULT): Likewise.
	* configure: Regenerate.
	* config.h.in: Regenerate.

	libobjc:
	* Makefile.in (INCLUDES): Add -I$(MULTIBUILDTOP)../libgcc.
	* configure.ac (target_thread_file, HAVE_GTHR_DEFAULT): Remove.
	* configure: Regenerate.
	* config.h.in: Regenerate.

	libstdc++-v3:
	* acinclude.m4 (GLIBCXX_CONFIGURE): Determine and substitute
	toplevel_builddir.
	(GLIBCXX_ENABLE_THREADS): Remove glibcxx_thread_h,
	HAVE_GTHR_DEFAULT, enable_thread.
	(GLIBCXX_CHECK_GTHREADS): Reflect gthr move to libgcc.
	* include/Makefile.am (thread_host_headers): Remove
	${host_builddir}/gthr-tpf.h.
	(${host_builddir}/gthr.h): Reflect gthr move to libgcc.
	Use $<.
	(${host_builddir}/gthr-single.h): Likewise.
	(${host_builddir}/gthr-posix.h): Likewise.
	(${host_builddir}/gthr-tpf.h): Remove.
	(${host_builddir}/gthr-default.h): Likewise.
	* configure, config.h.in: Regenerate.
	* Makefile.in, doc/Makefile.in, include/Makefile.in,
	libsupc++/Makefile.in, po/Makefile.in, python/Makefile.in,
	src/Makefile.intestsuite/Makefile.in: Regenerate.
diff mbox

Patch

# HG changeset patch
# Parent cbf2f0be2fab363976fac5e57a96f8bc4ae75f52
Move gthr to toplevel libgcc

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -532,9 +532,7 @@  lang_opt_files=@lang_opt_files@ $(srcdir
 lang_specs_files=@lang_specs_files@
 lang_tree_files=@lang_tree_files@
 target_cpu_default=@target_cpu_default@
-GCC_THREAD_FILE=@thread_file@
 OBJC_BOEHM_GC=@objc_boehm_gc@
-GTHREAD_FLAGS=@gthread_flags@
 extra_modes_file=@extra_modes_file@
 extra_opt_files=@extra_opt_files@
 host_hook_obj=@out_host_hook_obj@
@@ -1806,7 +1804,6 @@  libgcc-support: libgcc.mvars stmp-int-hd
 libgcc.mvars: config.status Makefile specs xgcc$(exeext)
 	: > tmp-libgcc.mvars
 	echo GCC_CFLAGS = '$(GCC_CFLAGS)' >> tmp-libgcc.mvars
-	echo GTHREAD_FLAGS = '$(GTHREAD_FLAGS)' >> tmp-libgcc.mvars
 	echo INHIBIT_LIBC_CFLAGS = '$(INHIBIT_LIBC_CFLAGS)' >> tmp-libgcc.mvars
 	echo TARGET_SYSTEM_ROOT = '$(TARGET_SYSTEM_ROOT)' >> tmp-libgcc.mvars
 
diff --git a/gcc/config/t-vxworks b/gcc/config/t-vxworks
--- a/gcc/config/t-vxworks
+++ b/gcc/config/t-vxworks
@@ -17,10 +17,6 @@ 
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-# Some runtime modules need these.  Can't set extra_headers in config.gcc
-# because the paths are always made absolute to the cpu config dir.
-EXTRA_HEADERS += $(srcdir)/gthr-vxworks.h gthr-default.h
-
 # Both the kernel and RTP headers provide limits.h.
 LIMITS_H_TEST = true
 
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1416,19 +1416,6 @@  if test x${thread_file} = x; then
   thread_file=${target_thread_file}
 fi
 
-# Make gthr-default.h if we have a thread file.
-gthread_flags=
-if test $thread_file != single; then
-  echo "#include \"gthr-${thread_file}.h\"" > gthr-default.h-t
-  if diff gthr-default.h-t gthr-default.h 2>/dev/null; then
-    rm -f gthr-default.h-t
-  else
-    mv -f gthr-default.h-t gthr-default.h
-  fi
-  gthread_flags=-DHAVE_GTHR_DEFAULT
-fi
-AC_SUBST(gthread_flags)
-
 # --------
 # UNSORTED
 # --------
@@ -4961,7 +4948,6 @@  AC_SUBST(out_file)
 AC_SUBST(out_object_file)
 AC_SUBST(common_out_file)
 AC_SUBST(common_out_object_file)
-AC_SUBST(thread_file)
 AC_SUBST(tm_file_list)
 AC_SUBST(tm_include_list)
 AC_SUBST(tm_defines)
diff --git a/gcc/po/EXCLUDES b/gcc/po/EXCLUDES
--- a/gcc/po/EXCLUDES
+++ b/gcc/po/EXCLUDES
@@ -24,16 +24,6 @@ 
 #   These files are part of libgcc, or target headers provided by gcc.
 gcov-io.h
 gcov-iov.c
-gthr-aix.h
-gthr-dce.h
-gthr-posix.c
-gthr-posix.h
-gthr-rtems.h
-gthr-single.h
-gthr-solaris.h
-gthr-vxworks.h
-gthr-win32.h
-gthr.h
 limitx.h
 limity.h
 
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -223,8 +223,7 @@  endif
 #
 LIBGCC2_DEBUG_CFLAGS = -g
 LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
-		 $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) \
-		 -DIN_LIBGCC2 \
+		 $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \
 		 -fbuilding-libgcc -fno-stack-protector \
 		 $(INHIBIT_LIBC_CFLAGS)
 
diff --git a/gcc/gthr-lynx.h b/libgcc/config/gthr-lynx.h
rename from gcc/gthr-lynx.h
rename to libgcc/config/gthr-lynx.h
--- a/gcc/gthr-lynx.h
+++ b/libgcc/config/gthr-lynx.h
@@ -1,7 +1,7 @@ 
 /* Threads compatibility routines for libgcc2 and libobjc for
    LynxOS.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2008, 2009, 2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -52,7 +52,7 @@  see the files COPYING3 and COPYING.RUNTI
 #undef  GTHREAD_USE_WEAK
 #define GTHREAD_USE_WEAK 0
 
-#include "gthr-posix.h"
+#include "config/gthr-posix.h"
 
 #else
 #include "gthr-single.h"
diff --git a/gcc/gthr-posix.h b/libgcc/config/gthr-posix.h
rename from gcc/gthr-posix.h
rename to libgcc/config/gthr-posix.h
diff --git a/gcc/gthr-rtems.h b/libgcc/config/gthr-rtems.h
rename from gcc/gthr-rtems.h
rename to libgcc/config/gthr-rtems.h
diff --git a/gcc/gthr-vxworks.h b/libgcc/config/gthr-vxworks.h
rename from gcc/gthr-vxworks.h
rename to libgcc/config/gthr-vxworks.h
--- a/gcc/gthr-vxworks.h
+++ b/libgcc/config/gthr-vxworks.h
@@ -1,6 +1,7 @@ 
 /* Threads compatibility routines for libgcc2 and libobjc for VxWorks.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1997, 1999, 2000, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999, 2000, 2008, 2009, 2011
+   Free Software Foundation, Inc.
    Contributed by Mike Stump <mrs@wrs.com>.
 
 This file is part of GCC.
@@ -30,7 +31,7 @@  see the files COPYING3 and COPYING.RUNTI
 #ifdef _LIBOBJC
 
 /* libobjc requires the optional pthreads component.  */
-#include "gthr-posix.h"
+#include "config/gthr-posix.h"
 
 #else
 #ifdef __cplusplus
diff --git a/libgcc/config/i386/gthr-win32.c b/libgcc/config/i386/gthr-win32.c
--- a/libgcc/config/i386/gthr-win32.c
+++ b/libgcc/config/i386/gthr-win32.c
@@ -1,7 +1,8 @@ 
 /* Implementation of W32-specific threads compatibility routines for
    libgcc2.  */
 
-/* Copyright (C) 1999, 2000, 2002, 2004, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2002, 2004, 2008, 2009, 2011
+   Free Software Foundation, Inc.
    Contributed by Mumit Khan <khan@xraylith.wisc.edu>.
    Modified and moved to separate file by Danny Smith
    <dannysmith@users.sourceforge.net>.
@@ -33,7 +34,7 @@  see the files COPYING3 and COPYING.RUNTI
 #endif
 #undef  __GTHREAD_I486_INLINE_LOCK_PRIMITIVES
 #define __GTHREAD_I486_INLINE_LOCK_PRIMITIVES
-#include <gthr-win32.h>
+#include "gthr-win32.h"
 
 /* Windows32 threads specific definitions. The windows32 threading model
    does not map well into pthread-inspired gcc's threading model, and so 
diff --git a/gcc/gthr-win32.h b/libgcc/config/i386/gthr-win32.h
rename from gcc/gthr-win32.h
rename to libgcc/config/i386/gthr-win32.h
diff --git a/gcc/gthr-mipssde.h b/libgcc/config/mips/gthr-mipssde.h
rename from gcc/gthr-mipssde.h
rename to libgcc/config/mips/gthr-mipssde.h
diff --git a/gcc/gthr-dce.h b/libgcc/config/pa/gthr-dce.h
rename from gcc/gthr-dce.h
rename to libgcc/config/pa/gthr-dce.h
diff --git a/gcc/gthr-aix.h b/libgcc/config/rs6000/gthr-aix.h
rename from gcc/gthr-aix.h
rename to libgcc/config/rs6000/gthr-aix.h
--- a/gcc/gthr-aix.h
+++ b/libgcc/config/rs6000/gthr-aix.h
@@ -1,6 +1,6 @@ 
 /* Threads compatibility routines for libgcc2 and libobjc.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 2000, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2009, 2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -27,7 +27,7 @@  see the files COPYING3 and COPYING.RUNTI
 #define GCC_GTHR_AIX_H
 
 #ifdef _THREAD_SAFE
-#include "gthr-posix.h"
+#include "config/gthr-posix.h"
 #else
 #include "gthr-single.h"
 #endif
diff --git a/gcc/gthr-tpf.h b/libgcc/config/s390/gthr-tpf.h
rename from gcc/gthr-tpf.h
rename to libgcc/config/s390/gthr-tpf.h
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -364,6 +364,20 @@  tm_file="${tm_file_}"
 AC_SUBST(tm_file)
 AC_SUBST(tm_defines)
 
+# Map from thread model to thread header.
+case $target_thread_file in
+    aix)	thread_header=config/rs6000/gthr-aix.h ;;
+    dce)	thread_header=config/pa/gthr-dce.h ;;
+    lynx)	thread_header=config/gthr-lynx.h ;;
+    mipssde)	thread_header=config/mips/gthr-mipssde.h ;;
+    posix)	thread_header=config/gthr-posix.h ;;
+    rtems)	thread_header=config/gthr-rtems.h ;;
+    single)	thread_header=gthr-single.h ;;
+    tpf)	thread_header=config/s390/gthr-tpf.h ;;
+    vxworks)	thread_header=config/gthr-vxworks.h ;;
+    win32)	thread_header=config/i386/gthr-win32.h ;;
+esac
+
 # Substitute configuration variables
 AC_SUBST(cpu_type)
 AC_SUBST(extra_parts)
@@ -372,6 +386,7 @@  AC_CONFIG_LINKS([enable-execute-stack.c:
 AC_CONFIG_LINKS([unwind.h:$unwind_header])
 AC_CONFIG_LINKS([md-unwind-support.h:config/$md_unwind_header])
 AC_CONFIG_LINKS([sfp-machine.h:config/$sfp_machine_header])
+AC_CONFIG_LINKS([gthr-default.h:$thread_header])
 
 # We need multilib support.
 AC_CONFIG_FILES([Makefile])
diff --git a/gcc/gthr-single.h b/libgcc/gthr-single.h
rename from gcc/gthr-single.h
rename to libgcc/gthr-single.h
diff --git a/gcc/gthr.h b/libgcc/gthr.h
rename from gcc/gthr.h
rename to libgcc/gthr.h
--- a/gcc/gthr.h
+++ b/libgcc/gthr.h
@@ -132,23 +132,8 @@  see the files COPYING3 and COPYING.RUNTI
                                              __gthread_recursive_mutex_t *mutex,
                                              const __gthread_time_t *abs_time)
 
-   Currently supported threads packages are
-     TPF threads with -D__tpf__
-     POSIX/Unix98 threads with -D_PTHREADS
-     DCE threads with -D_DCE_THREADS
-
 */
 
-/* Check first for thread specific defines.  */
-#if defined (__tpf__)
-#include "gthr-tpf.h"
-#elif _PTHREADS
-#include "gthr-posix.h"
-#elif _DCE_THREADS
-#include "gthr-dce.h"
-
-/* Include GTHREAD_FILE if one is defined.  */
-#elif defined(HAVE_GTHR_DEFAULT)
 #if SUPPORTS_WEAK
 #ifndef GTHREAD_USE_WEAK
 #define GTHREAD_USE_WEAK 1
@@ -156,11 +141,6 @@  see the files COPYING3 and COPYING.RUNTI
 #endif
 #include "gthr-default.h"
 
-/* Fallback to single thread definitions.  */
-#else
-#include "gthr-single.h"
-#endif
-
 #ifndef HIDE_EXPORTS
 #pragma GCC visibility pop
 #endif
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -56,7 +56,9 @@  libcaf_single_la_LINK = $(LINK) $(libcaf
 ## use -iquote
 AM_CPPFLAGS = -iquote$(srcdir)/io -I$(srcdir)/$(MULTISRCTOP)../gcc \
 	      -I$(srcdir)/$(MULTISRCTOP)../gcc/config $(LIBQUADINCLUDE) \
-	      -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc
+	      -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc \
+	      -I$(srcdir)/$(MULTISRCTOP)../libgcc \
+	      -I$(MULTIBUILDTOP)../libgcc
 
 # Fortran rules for complex multiplication and division
 AM_CFLAGS += -fcx-fortran-rules
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -83,17 +83,6 @@  if (foovar > 10) return __sync_add_and_f
 	      [Define to 1 if the target supports __sync_fetch_and_add])
   fi])
 
-dnl Check if threads are supported.
-AC_DEFUN([LIBGFOR_CHECK_GTHR_DEFAULT], [
-  AC_CACHE_CHECK([configured target thread model],
-		 libgfor_cv_target_thread_file, [
-libgfor_cv_target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`])
-
-  if test $libgfor_cv_target_thread_file != single; then
-    AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
-	      [Define if the compiler has a thread header that is non single.])
-  fi])
-
 dnl Check for pragma weak.
 AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
   AC_CACHE_CHECK([whether pragma weak works],
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -550,9 +550,6 @@  LIBGFOR_CHECK_ATTRIBUTE_ALIAS
 # Check out sync builtins support.
 LIBGFOR_CHECK_SYNC_FETCH_AND_ADD
 
-# Check out thread support.
-LIBGFOR_CHECK_GTHR_DEFAULT
-
 # Check out #pragma weak.
 LIBGFOR_GTHREAD_WEAK
 
diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in
--- a/libobjc/Makefile.in
+++ b/libobjc/Makefile.in
@@ -102,6 +102,7 @@  INCLUDES = -I$(srcdir)/$(MULTISRCTOP)../
   -I$(srcdir)/$(MULTISRCTOP)../gcc/config \
   -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc \
   -I$(srcdir)/$(MULTISRCTOP)../libgcc \
+  -I$(MULTIBUILDTOP)../libgcc \
   -I$(srcdir)/$(MULTISRCTOP)../include \
   $(OBJC_BOEHM_GC_INCLUDES)
 
diff --git a/libobjc/configure.ac b/libobjc/configure.ac
--- a/libobjc/configure.ac
+++ b/libobjc/configure.ac
@@ -217,15 +217,6 @@  AC_CHECK_HEADERS(sched.h)
 # Miscellanea
 # -----------
 
-AC_MSG_CHECKING([for thread model used by GCC])
-target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
-AC_MSG_RESULT([$target_thread_file]) 
-
-if test $target_thread_file != single; then
-  AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
-        [Define if the compiler has a thread header that is non single.])
-fi 
-
 # Check if we have thread-local storage
 GCC_CHECK_TLS
 
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -35,6 +35,7 @@  dnl  SUBDIRS
 dnl Substs:
 dnl  glibcxx_builddir     (absolute path)
 dnl  glibcxx_srcdir       (absolute path)
+dnl  toplevel_builddir    (absolute path)
 dnl  toplevel_srcdir      (absolute path)
 dnl  with_cross_host
 dnl  with_newlib
@@ -59,9 +60,11 @@  AC_DEFUN([GLIBCXX_CONFIGURE], [
     [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
     *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
   esac
+  toplevel_builddir=${glibcxx_builddir}/..
   toplevel_srcdir=${glibcxx_srcdir}/..
   AC_SUBST(glibcxx_builddir)
   AC_SUBST(glibcxx_srcdir)
+  AC_SUBST(toplevel_builddir)
   AC_SUBST(toplevel_srcdir)
 
   # We use these options to decide which functions to include.  They are
@@ -3315,34 +3318,10 @@  dnl having to write complex code (the se
 dnl namespace are complex and fragile enough as it is).  We must also
 dnl add a relative path so that -I- is supported properly.
 dnl
-dnl Substs:
-dnl  glibcxx_thread_h
-dnl
-dnl Defines:
-dnl  HAVE_GTHR_DEFAULT
-dnl
 AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
   AC_MSG_CHECKING([for thread model used by GCC])
   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
   AC_MSG_RESULT([$target_thread_file])
-
-  if test $target_thread_file != single; then
-    AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
-	      [Define if gthr-default.h exists
-	      (meaning that threading support is enabled).])
-  fi
-
-  glibcxx_thread_h=gthr-$target_thread_file.h
-
-  dnl Check for __GTHREADS define.
-  gthread_file=${toplevel_srcdir}/gcc/${glibcxx_thread_h}
-  if grep __GTHREADS $gthread_file >/dev/null 2>&1 ; then
-    enable_thread=yes
-  else
-   enable_thread=no
-  fi
-
-  AC_SUBST(glibcxx_thread_h)
 ])
 
 
@@ -3356,7 +3335,8 @@  AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
   AC_LANG_CPLUSPLUS
 
   ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc"
+  CXXFLAGS="$CXXFLAGS -fno-exceptions \
+	-I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc"
 
   target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
   case $target_thread_file in
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -855,7 +855,6 @@  thread_host_headers = \
 	${host_builddir}/gthr.h \
 	${host_builddir}/gthr-single.h \
 	${host_builddir}/gthr-posix.h \
-	${host_builddir}/gthr-tpf.h \
 	${host_builddir}/gthr-default.h
 
 
@@ -1122,43 +1121,35 @@  endif
 # Host includes for threads
 uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_]
 
-${host_builddir}/gthr.h: ${toplevel_srcdir}/gcc/gthr.h stamp-${host_alias}
+${host_builddir}/gthr.h: ${toplevel_srcdir}/libgcc/gthr.h stamp-${host_alias}
 	sed -e '/^#pragma/b' \
 	    -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \
 	    -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \
 	    -e 's,^#include "\(.*\)",#include <bits/\1>,g' \
-	    < ${toplevel_srcdir}/gcc/gthr.h > $@
+	    < $< > $@
 
-${host_builddir}/gthr-single.h: ${toplevel_srcdir}/gcc/gthr-single.h \
+${host_builddir}/gthr-single.h: ${toplevel_srcdir}/libgcc/gthr-single.h \
 				  stamp-${host_alias}
 	sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
 	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \
-	    < ${toplevel_srcdir}/gcc/gthr-single.h > $@
+	    < $< > $@
 
-${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/gcc/gthr-posix.h \
+${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/libgcc/config/gthr-posix.h \
 				   stamp-${host_alias}
 	sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
 	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \
 	    -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \
 	    -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \
-	    < ${toplevel_srcdir}/gcc/gthr-posix.h > $@
+	    < $< > $@
 
-${host_builddir}/gthr-tpf.h: ${toplevel_srcdir}/gcc/gthr-tpf.h \
-				   stamp-${host_alias}
-	sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
-	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \
-	    -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \
-	    -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \
-	    < ${toplevel_srcdir}/gcc/gthr-tpf.h > $@
-
-${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \
+${host_builddir}/gthr-default.h: ${toplevel_builddir}/libgcc/gthr-default.h \
 				   stamp-${host_alias}
 	sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
 	    -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \
 	    -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \
 	    -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \
 	    -e 's,^#include "\(.*\)",#include <bits/\1>,g' \
-	    < ${toplevel_srcdir}/gcc/${glibcxx_thread_h} > $@
+	    < $< > $@
 
 # Build two precompiled C++ includes, stdc++.h.gch/*.gch
 ${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}