diff mbox

[build] Move gthr to toplevel libgcc

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

Commit Message

Rainer Orth Sept. 23, 2011, 9:23 a.m. UTC
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> John David Anglin <dave.anglin@nrc-cnrc.gc.ca> writes:
>
>>> I could find no indication that HP-UX 10 supported anything but DCE
>>> threads (especially no POSIX threads), so _REENTRANT being defined must
>>> meant DCE threads, unless I'm mistaken.
>>
>> _REENTRANT doesn't imply DCE threads.  The reentrant routines were added
>> to the non threaded version of libc in HP-UX 10 in preparation for the
>> transition
>> to POSIX threads in HP-UX 11.  We define _REENTRANT under other
>> circumstances in pa-hpux10.h as the reentrant routines are needed for
>> libgfortran,
>> etc.
>
> One could argue that it's the responsibility of libgfortran to do so if
> necessary, though.
>
> But ok, I'll restore the definition and use of _DCE_THREADS in
> pa-hpux10.h and gthr-dce.h.

Here's the updated patch with that change.  I haven't yet rebased it
to current mainline (will do so for the whole patch series over the
weekend), and it still requires the previous libgcc patches to apply
cleanly.

	Rainer


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

	gcc:
	* gthr-posix.h, 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-rtems.h: Move to ../libgcc/config.
	* 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/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.
	* 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-posix.h, gthr-single.h, gthr.h: New files.
	* config/gthr-lynx.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".
	* config.host (thread_header, thread_dir): New variables.
	Set it depending on target_thread_file.
	* configure.ac (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.

Comments

Paolo Bonzini Sept. 23, 2011, 9:40 a.m. UTC | #1
On 09/23/2011 11:23 AM, Rainer Orth wrote:
> Rainer Orth<ro@CeBiTec.Uni-Bielefeld.DE>  writes:
>
>> John David Anglin<dave.anglin@nrc-cnrc.gc.ca>  writes:
>>
>>>> I could find no indication that HP-UX 10 supported anything but DCE
>>>> threads (especially no POSIX threads), so _REENTRANT being defined must
>>>> meant DCE threads, unless I'm mistaken.
>>>
>>> _REENTRANT doesn't imply DCE threads.  The reentrant routines were added
>>> to the non threaded version of libc in HP-UX 10 in preparation for the
>>> transition
>>> to POSIX threads in HP-UX 11.  We define _REENTRANT under other
>>> circumstances in pa-hpux10.h as the reentrant routines are needed for
>>> libgfortran,
>>> etc.
>>
>> One could argue that it's the responsibility of libgfortran to do so if
>> necessary, though.
>>
>> But ok, I'll restore the definition and use of _DCE_THREADS in
>> pa-hpux10.h and gthr-dce.h.
>
> Here's the updated patch with that change.  I haven't yet rebased it
> to current mainline (will do so for the whole patch series over the
> weekend), and it still requires the previous libgcc patches to apply
> cleanly.
>
> 	Rainer

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).

Paolo
diff mbox

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -529,9 +529,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@
@@ -1801,7 +1799,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/m32r/linux.h b/gcc/config/m32r/linux.h
--- a/gcc/config/m32r/linux.h
+++ b/gcc/config/m32r/linux.h
@@ -84,7 +84,7 @@ 
 #undef  SUBTARGET_CPP_SPEC
 #define SUBTARGET_CPP_SPEC "\
    %{posix:-D_POSIX_SOURCE} \
-   %{pthread:-D_REENTRANT -D_PTHREADS} \
+   %{pthread:-D_REENTRANT} \
 "
                                                                                 
 #define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
diff --git a/gcc/config/mn10300/linux.h b/gcc/config/mn10300/linux.h
--- a/gcc/config/mn10300/linux.h
+++ b/gcc/config/mn10300/linux.h
@@ -28,7 +28,7 @@ 
 #undef  CPP_SPEC
 #define CPP_SPEC "%{mam33:-D__AM33__} %{!mam33:-D__AM33__=2 -D__AM33_2__} \
   %{posix:-D_POSIX_SOURCE} \
-  %{pthread:-D_REENTRANT -D_PTHREADS}"
+  %{pthread:-D_REENTRANT}"
 
 #undef  ASM_SPEC
 #define ASM_SPEC ""
diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h
--- a/gcc/config/netbsd.h
+++ b/gcc/config/netbsd.h
@@ -33,7 +33,7 @@  along with GCC; see the file COPYING3.  
 /* CPP_SPEC parts common to all NetBSD targets.  */
 #define NETBSD_CPP_SPEC				\
   "%{posix:-D_POSIX_SOURCE} \
-   %{pthread:-D_REENTRANT -D_PTHREADS}"
+   %{pthread:-D_REENTRANT}"
 
 /* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
    source tree so it can be configured appropriately without using
diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
--- a/gcc/config/sh/linux.h
+++ b/gcc/config/sh/linux.h
@@ -28,7 +28,7 @@  along with GCC; see the file COPYING3.  
 #undef SUBTARGET_CPP_SPEC
 #define SUBTARGET_CPP_SPEC "\
    %{posix:-D_POSIX_SOURCE} \
-   %{pthread:-D_REENTRANT -D_PTHREADS} \
+   %{pthread:-D_REENTRANT} \
 "
 
 #define TARGET_OS_CPP_BUILTINS() \
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -72,8 +72,7 @@  along with GCC; see the file COPYING3.  
 #define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
 
 #undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "\
-%{pthreads|pthread:-D_REENTRANT -D_PTHREADS}"
+#define CPP_SUBTARGET_SPEC "%{pthreads|pthread:-D_REENTRANT}"
 
 /* Names to predefine in the preprocessor for this target machine.  */
 #define TARGET_SUB_OS_CPP_BUILTINS()
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
@@ -1374,19 +1374,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
 # --------
@@ -4887,7 +4874,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/libgcc/config.host b/libgcc/config.host
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -65,6 +65,7 @@ 
 #			built for the target, not the host.  These files
 #			are relative to $srcdir/config and must not have
 #			the same names as files in $srcdir/../gcc/config.
+#  thread_header	The name of the header file for the thread model used.
 #  unwind_header	The name of the header file declaring the unwind
 #			runtime interface routines.
 
@@ -74,6 +75,7 @@  extra_parts=
 tmake_file=
 tm_file=
 tm_define=
+thread_header=
 md_unwind_header=no-unwind.h
 unwind_header=unwind-generic.h
 
@@ -285,6 +287,38 @@  i[34567]86-*-mingw* | x86_64-*-mingw*)
   ;;
 esac
 
+# Map from thread model to thread header.
+thread_dir=
+case $target_thread_file in
+    aix)
+	thread_dir=config/rs6000/
+	;;
+    dce)
+	thread_dir=config/pa/
+	;;
+    lynx)
+	thread_dir=config/
+	;;
+    mipssde)
+	thread_dir=config/mips/
+	;;
+    posix | single)
+	;;
+    rtems)
+	thread_dir=config/
+	;;
+    tpf)
+	thread_dir=config/s390/
+	;;
+    vxworks)
+	thread_dir=config/
+	;;
+    win32)
+	thread_dir=config/i386/
+	;;
+esac
+thread_header=${thread_dir}gthr-${target_thread_file}.h
+
 case ${host} in
 alpha*-*-linux*)
 	tmake_file="${tmake_file} alpha/t-alpha alpha/t-ieee t-crtfm alpha/t-linux"
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
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
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
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
@@ -372,6 +372,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-posix.h b/libgcc/gthr-posix.h
rename from gcc/gthr-posix.h
rename to libgcc/gthr-posix.h
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
@@ -3226,34 +3229,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)
 ])
 
 
@@ -3267,7 +3246,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"
 
   AC_MSG_CHECKING([check whether it can be safely assumed that mutex_timedlock is available])
 
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
@@ -846,7 +846,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
 
 
@@ -1108,43 +1107,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/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}