This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

Get target libraries to obtain thread information from GCC


This patch cleans up the thread-model recognition code in all target
libraries such that it obtains the thread information out of GCC,
instead of having (and failing) to duplicate the logic used in
gcc/configure.in.

Tested on i686-pc-linux-gnu.  Ok to install?  Ok for 3.0 branch?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* configure.in (configargs.h): Define thread_model.
	* configure: Rebuilt.
	* gcc.c (main): Print it with -v.

Index: gcc/configure.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/configure.in,v
retrieving revision 1.517
diff -u -p -r1.517 configure.in
--- gcc/configure.in 2001/04/23 04:07:15 1.517
+++ gcc/configure.in 2001/04/24 13:56:59
@@ -857,6 +857,7 @@ fi
 cat > configargs.h <<EOF
 /* Generated automatically. */
 static const char configuration_arguments[] = "$gcc_config_arguments";
+static const char thread_model[] = "$thread_file";
 EOF
 changequote([,])dnl
 
Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcc.c,v
retrieving revision 1.219
diff -u -p -r1.219 gcc.c
--- gcc/gcc.c 2001/04/19 20:28:05 1.219
+++ gcc/gcc.c 2001/04/24 13:57:02
@@ -5792,6 +5792,8 @@ main (argc, argv)
 
       notice ("Configured with: %s\n", configuration_arguments);
 
+      notice ("Thread model: %s\n", thread_model);
+
       /* compiler_version is truncated at the first space when initialized
 	 from version string, so truncate version_string at the first space
 	 before comparing.  */
Index: libstdc++-v3/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* acinclude.m4 (GLIBCPP_ENABLE_THREADS): Obtain
	target_thread_file with `gcc -v'.
	* aclocal.m4, configure: Rebuilt.

Index: libstdc++-v3/acinclude.m4
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/acinclude.m4,v
retrieving revision 1.143
diff -u -p -r1.143 acinclude.m4
--- libstdc++-v3/acinclude.m4 2001/04/23 19:50:00 1.143
+++ libstdc++-v3/acinclude.m4 2001/04/24 13:57:02
@@ -1200,40 +1200,10 @@ dnl Default is no threads, which also di
 dnl libio.  Any actual thread package will enable it.
 dnl
 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
-  dnl Note this comes from the gcc/config.in and libjava/config.in
-  dnl Efforts should be made to keep this in sync.
-  AC_MSG_CHECKING([for threads package to use])
-  AC_ARG_ENABLE(threads,
-  [  --enable-threads       enable thread usage for target GCC.
-     --enable-threads=LIB   use LIB thread package for target GCC. [default=no]
-  ],
-  if test x$enable_threads = xno; then
-    enable_threads=''
-  fi,
-    enable_threads='')
+  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])
 
-  enable_threads_flag=$enable_threads
-
-  dnl Check if a valid thread package
-  case x${enable_threads_flag} in
-        x | xno | xnone)
-                # No threads
-                target_thread_file='single'
-                ;;
-        xyes)
-                # default
-                target_thread_file='posix'
-                ;;
-        xdecosf1 | xirix | xmach | xos2 | xposix | xpthreads | xsingle | \
-        xsolaris | xwin32 | xdce | xvxworks)
-                target_thread_file=$enable_threads_flag
-                ;;
-        *)
-                echo "$enable_threads is an unknown thread package" 1>&2
-                exit 1
-                ;;
-  esac
-
   dnl Check for thread package actually supported in libstdc++ 
   THREADH=
   case "$target_thread_file" in
@@ -1244,13 +1214,13 @@ AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
       THREADH=threads-posix.h
       ;;
     decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
-      AC_MSG_ERROR(thread package $THREADS not yet supported)
+      AC_MSG_WARN(disabling unsupported thread package $target_thread_file)
+      THREADH=threads-no.h
       ;;
     *)
-      AC_MSG_ERROR($THREADS is an unsupported/unknown thread package)
+      AC_MSG_ERROR($target_thread_file: unsupported/unknown thread package)
       ;;
   esac
-  AC_MSG_RESULT($THREADH)
 
   AC_LINK_FILES(config/$THREADH, include/bits/c++threads.h)
   if test $THREADH != threads-no.h; then
Index: boehm-gc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* configure.in: Obtain THREADS with `gcc -v'.
	* configure: Rebuilt.

Index: boehm-gc/configure.in
===================================================================
RCS file: /cvs/gcc/egcs/boehm-gc/configure.in,v
retrieving revision 1.21
diff -u -p -r1.21 configure.in
--- boehm-gc/configure.in 2000/12/30 12:18:38 1.21
+++ boehm-gc/configure.in 2001/04/24 13:57:02
@@ -26,45 +26,10 @@ if test "x" = "y"; then
    AC_EXEEXT
 fi
 
-AC_MSG_CHECKING([for threads package to use])
-AC_ARG_ENABLE(threads, [  --enable-threads=TYPE   choose threading package],
-  THREADS=$enableval,
-  dnl FIXME: figure out native threads to use here.
-  THREADS=no)
+AC_MSG_CHECKING([for thread model used by GCC])
+THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
+AC_MSG_RESULT([$THREADS])
 
-if test "$THREADS" = yes; then
-   case "$host" in
-    *-*-vxworks*)
-       THREADS=vxworks
-       ;;
-    *-*-linux*)
-       # FIXME: this isn't correct in all cases.
-       THREADS=posix
-       ;;
-    *-*-win*)
-       THREADS=win32
-       ;;
-    *-*-irix[[1-5]].*)
-       # No built-in threads library on IRIX 5.* and older.
-       THREADS=none
-       ;;
-    *-*-irix*)
-       # FIXME: for now, choose POSIX, because we implement that.
-       # Later, choose irix threads.
-       THREADS=posix
-       ;;
-    *-*-solaris*)
-       # FIXME: for now, choose POSIX, because we implement that.
-       # Later, choose solaris threads.
-       THREADS=posix
-       ;;
-    *)
-       # For now.
-       THREADS=none
-       ;;
-   esac
-fi
-
 INCLUDES=
 THREADLIBS=
 case "$THREADS" in
@@ -95,7 +60,6 @@ case "$THREADS" in
     AC_MSG_ERROR($THREADS is an unknown thread package)
     ;;
 esac
-AC_MSG_RESULT($THREADS)
 AC_SUBST(THREADLIBS)
 
 AC_CHECK_LIB(dl, dlopen, EXTRA_TEST_LIBS="$EXTRA_TEST_LIBS -ldl")
Index: libjava/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* configure.in: Obtain THREADS with `gcc -v'.
	* configure: Rebuilt.

Index: libjava/configure.in
===================================================================
RCS file: /cvs/gcc/egcs/libjava/configure.in,v
retrieving revision 1.79
diff -u -p -r1.79 configure.in
--- libjava/configure.in 2001/04/24 11:27:19 1.79
+++ libjava/configure.in 2001/04/24 13:57:03
@@ -279,44 +279,10 @@ AC_SUBST(GCTESTSPEC)
 AC_LINK_FILES(include/$GCHDR, include/java-gc.h)
 
 
-dnl Note that this code is kept in sync with similar code in gcc/configure.in.
-dnl In particular both packages must make the same decision about which
-dnl thread package to use.
-AC_MSG_CHECKING([for threads package to use])
-AC_ARG_ENABLE(threads, [  --enable-threads=TYPE   choose threading package],
-  THREADS=$enableval,
-  dnl FIXME: figure out native threads to use here.
-  THREADS=no)
+AC_MSG_CHECKING([for thread model used by GCC])
+THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
+AC_MSG_RESULT([$THREADS])
 
-if test "$THREADS" = yes; then
-   case "$host" in
-    *-*-vxworks*)
-       THREADS=vxworks
-       ;;
-    *-*-linux*)
-       # FIXME: this isn't correct in all cases.
-       THREADS=posix
-       ;;
-    *-*-win*)
-       THREADS=win32
-       ;;
-    *-*-irix*)
-       # FIXME: for now, choose POSIX, because we implement that.
-       # Later, choose irix threads.
-       THREADS=posix
-       ;;
-    *-*-solaris*)
-       # FIXME: for now, choose POSIX, because we implement that.
-       # Later, choose solaris threads.
-       THREADS=posix
-       ;;
-    *)
-       # For now.
-       THREADS=none
-       ;;
-   esac
-fi
-
 case "$THREADS" in
  no | none | single)
     THREADS=none
@@ -336,7 +302,6 @@ case "$THREADS" in
     AC_MSG_ERROR($THREADS is an unknown thread package)
     ;;
 esac
-AC_MSG_RESULT($THREADS)
 
 THREADLIBS=
 THREADINCS=

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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