This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Thread support for HPUX, revised


Revised patch incorporating John's suggestion - that is, don't define
_HPUX_SOURCE when -pthread is given, just _POSIX_C_SOURCE=199506L.
I'm going to go ahead and check this in; if there are problems please
let me know and I will address them in a followup patch.

zw

[3.3]
gcc:
        * config.gcc (hppa*-*-hpux11*, ia64*-*-hpux*): Remove
        commented-out logic to use DCE threads (if present), add
        support for POSIX threads.
        * config/ia64/hpux.h: Define CPP_SPEC to set appropriate
        #defines for -pthread.  Add -lpthread to LIB_SPEC when
        -pthread.  In both cases take -mt as a synonym for -pthread
        for acc compatibility.
        Define GTHREAD_USE_WEAK to 0.
        * config/pa/pa-hpux11.h: Likewise for CPP_SPEC and LIB_SPEC.
        Remove old logic for DCE threads from LIB_SPEC.
        * config/pa/pa64-hpux.h: Define GTHREAD_USE_WEAK to 0.
libstdc++-v3:
        * config/os/hpux/os_defines.h: Unconditionally define
        _GLIBCPP_GTHREAD_USE_WEAK to 0.

[the changelog for 3.4 is identical except that
_GLIBCPP_GTHREAD_USE_WEAK is spelled _GLIBCXX_GTHREAD_USE_WEAK.]

===================================================================
Index: gcc/config.gcc
--- gcc/config.gcc	10 Aug 2003 23:11:22 -0000	1.266.2.13
+++ gcc/config.gcc	26 Aug 2003 06:47:41 -0000
@@ -961,13 +961,11 @@ hppa*64*-*-hpux11*)
 	then
 		target_cpu_default="${target_cpu_default}|MASK_GNU_LD"
 	fi
-#	if [ x$enable_threads = x ]; then
-#	    enable_threads=$have_pthread_h
-#	fi
-#	if [ x$enable_threads = xyes ]; then
-#		thread_file='dce'
-#		tmake_file="${tmake_file} pa/t-dce-thr"
-#	fi
+	case x${enable_threads} in
+	xyes | xposix )
+		thread_file=posix 
+		;;
+	esac
 	install_headers_dir=install-headers-cpio
 	;;
 hppa1.1-*-hpux11* | hppa2*-*-hpux11*)
@@ -976,13 +974,11 @@ hppa1.1-*-hpux11* | hppa2*-*-hpux11*)
 	xm_defines=POSIX
 	tmake_file="pa/t-pa pa/t-pa-hpux pa/t-hpux-shlib"
 	xmake_file="pa/x-ada"
-#	if test x$enable_threads = x; then
-#	    enable_threads=$have_pthread_h
-#	fi
-#	if test x$enable_threads = xyes; then
-#		thread_file='dce'
-#		tmake_file="${tmake_file} pa/t-dce-thr"
-#	fi
+	case x${enable_threads} in
+	xyes | xposix )
+		thread_file=posix 
+		;;
+	esac
 	install_headers_dir=install-headers-cpio
 	use_collect2=yes
 	;;
@@ -991,13 +987,11 @@ hppa1.0-*-hpux11*)
 	xm_defines=POSIX
 	tmake_file="pa/t-pa pa/t-pa-hpux pa/t-hpux-shlib"
 	xmake_file="pa/x-ada"
-#	if test x$enable_threads = x; then
-#	    enable_threads=$have_pthread_h
-#	fi
-#	if test x$enable_threads = xyes; then
-#		thread_file='dce'
-#		tmake_file="${tmake_file} pa/t-dce-thr"
-#	fi
+	case x${enable_threads} in
+	xyes | xposix )
+		thread_file=posix 
+		;;
+	esac
 	install_headers_dir=install-headers-cpio
 	use_collect2=yes
 	;;
@@ -1492,9 +1486,11 @@ ia64*-*-hpux*)
 	tm_file="${tm_file} dbxelf.h elfos.h svr4.h ia64/sysv4.h ia64/hpux.h ia64/hpux_longdouble.h"
 	tmake_file="ia64/t-ia64 ia64/t-hpux"
 	target_cpu_default="MASK_GNU_AS"
-	if test x$enable_threads = xyes; then
-		thread_file='posix'
-	fi
+	case x$enable_threads in
+	xyes | xposix )
+		thread_file=posix
+		;;
+	esac
 	use_collect2=no
 	c_target_objs="ia64-c.o"
 	cxx_target_objs="ia64-c.o"
===================================================================
Index: gcc/config/ia64/hpux.h
--- gcc/config/ia64/hpux.h	22 Aug 2003 21:07:55 -0000	1.20.2.4
+++ gcc/config/ia64/hpux.h	26 Aug 2003 06:47:41 -0000
@@ -49,6 +49,13 @@ do {							\
 	  }						\
 } while (0)
 
+#undef CPP_SPEC
+#define CPP_SPEC \
+  "%{mt|pthread:-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L}"
+/* aCC defines also -DRWSTD_MULTI_THREAD, -DRW_MULTI_THREAD.  These
+   affect only aCC's C++ library (Rogue Wave-derived) which we do not
+   use, and they violate the user's name space.  */
+
 #undef  ASM_EXTRA_SPEC
 #define ASM_EXTRA_SPEC "%{milp32:-milp32} %{mlp64:-mlp64}"
 
@@ -68,6 +75,7 @@ do {							\
 #undef  LIB_SPEC
 #define LIB_SPEC \
   "%{!shared: \
+     %{mt|pthread:-lpthread} \
      %{p:%{!mlp64:-L/usr/lib/hpux32/libp} \
 	 %{mlp64:-L/usr/lib/hpux64/libp} -lprof} \
      %{pg:%{!mlp64:-L/usr/lib/hpux32/libp} \
@@ -133,6 +141,10 @@ do {								\
 
 #undef TARGET_HPUX_LD
 #define TARGET_HPUX_LD	1
+
+/* The HPUX dynamic linker objects to weak symbols with no
+   definitions, so do not use them in gthr-posix.h.  */
+#define GTHREAD_USE_WEAK 0
 
 /* Put out the needed function declarations at the end.  */
 
===================================================================
Index: gcc/config/pa/pa-hpux11.h
--- gcc/config/pa/pa-hpux11.h	10 Aug 2003 18:37:25 -0000	1.5.4.4
+++ gcc/config/pa/pa-hpux11.h	26 Aug 2003 06:47:41 -0000
@@ -74,6 +74,13 @@ Boston, MA 02111-1307, USA.  */
     }								\
   while (0)
 
+#undef CPP_SPEC
+#define CPP_SPEC \
+  "%{mt|pthread:-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L}"
+/* aCC defines also -DRWSTD_MULTI_THREAD, -DRW_MULTI_THREAD.  These
+   affect only aCC's C++ library (Rogue Wave-derived) which we do not
+   use, and they violate the user's name space.  */
+
 /* We can debug dynamically linked executables on hpux11; we also
    want dereferencing of a NULL pointer to cause a SEGV.  */
 #undef LINK_SPEC
@@ -88,17 +95,13 @@ Boston, MA 02111-1307, USA.  */
    %{static:-a archive} %{shared:-b}"
 #endif
 
-/* Like the default, except no -lg.  */
+/* hpux 11 has posix threads.  */
 #undef LIB_SPEC
 #define LIB_SPEC \
   "%{!shared:\
-     %{!p:%{!pg:\
-       %{!threads:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
-       %{threads:-lcma -lc_r}}}\
-     %{p: -L/lib/libp/ -lc\
-       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
-     %{pg: -L/lib/libp/ -lc\
-       %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
+     %{mt|pthread:-lpthread}     \
+     %{p|pg:-L/usr/lib/libp} -lc \
+     %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}"
 
 /* Under hpux11, the normal location of the `ld' and `as' programs is the
    /usr/ccs/bin directory.  */
===================================================================
Index: gcc/config/pa/pa64-hpux.h
--- gcc/config/pa/pa64-hpux.h	11 Apr 2003 18:57:56 -0000	1.19.2.3
+++ gcc/config/pa/pa64-hpux.h	26 Aug 2003 06:47:41 -0000
@@ -408,3 +408,7 @@ PA_INIT_FINI_HACK
    and returns 0.  /bin/true cannot be used because it is a script without
    an interpreter.  */
 #define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size"
+
+/* The HPUX dynamic linker objects to weak symbols with no
+   definitions, so do not use them in gthr-posix.h.  */
+#define GTHREAD_USE_WEAK 0
===================================================================
Index: libstdc++-v3/config/os/hpux/os_defines.h
--- libstdc++-v3/config/os/hpux/os_defines.h	27 May 2003 21:48:54 -0000	1.5.4.2
+++ libstdc++-v3/config/os/hpux/os_defines.h	26 Aug 2003 06:47:43 -0000
@@ -97,8 +97,10 @@ typedef long int __padding_type;
 #define _GLIBCPP_INST_ATOMICITY_LOCK 1
 #endif
 
-/* Don't use pragma weak in gthread headers.  */
-#ifdef __hppa__
+/* Don't use pragma weak in gthread headers.  HP-UX rejects programs
+   with unsatisfied external references even if all of those references
+   are weak; gthread relies on such unsatisfied references being resolved
+   to null pointers when weak symbol support is on.  */
 #define _GLIBCPP_GTHREAD_USE_WEAK 0
-#endif
+
 #endif
===================================================================
Index: gcc/config.gcc
--- gcc/config.gcc	24 Aug 2003 03:57:48 -0000	1.345
+++ gcc/config.gcc	26 Aug 2003 06:49:50 -0000
@@ -882,13 +882,11 @@ hppa*64*-*-hpux11*)
 	then
 		target_cpu_default="${target_cpu_default}|MASK_GNU_LD"
 	fi
-#	if [ x$enable_threads = x ]; then
-#	    enable_threads=$have_pthread_h
-#	fi
-#	if [ x$enable_threads = xyes ]; then
-#		thread_file='dce'
-#		tmake_file="${tmake_file} pa/t-dce-thr"
-#	fi
+	case x${enable_threads} in
+	xyes | xposix )
+		thread_file=posix 
+		;;
+	esac
 	install_headers_dir=install-headers-cpio
 	;;
 hppa1.1-*-hpux11* | hppa2*-*-hpux11*)
@@ -896,13 +894,11 @@ hppa1.1-*-hpux11* | hppa2*-*-hpux11*)
 	tm_file="${tm_file} pa/pa32-regs.h pa/long_double.h dbxelf.h pa/som.h pa/pa-hpux.h pa/pa-hpux11.h"
 	tmake_file="pa/t-pa pa/t-pa-hpux pa/t-hpux-shlib"
 	xmake_file="pa/x-ada"
-#	if test x$enable_threads = x; then
-#	    enable_threads=$have_pthread_h
-#	fi
-#	if test x$enable_threads = xyes; then
-#		thread_file='dce'
-#		tmake_file="${tmake_file} pa/t-dce-thr"
-#	fi
+	case x${enable_threads} in
+	xyes | xposix )
+		thread_file=posix 
+		;;
+	esac
 	install_headers_dir=install-headers-cpio
 	use_collect2=yes
 	;;
@@ -910,13 +906,11 @@ hppa1.0-*-hpux11*)
 	tm_file="${tm_file} pa/pa32-regs.h pa/long_double.h dbxelf.h pa/som.h pa/pa-hpux.h pa/pa-hpux11.h"
 	tmake_file="pa/t-pa pa/t-pa-hpux pa/t-hpux-shlib"
 	xmake_file="pa/x-ada"
-#	if test x$enable_threads = x; then
-#	    enable_threads=$have_pthread_h
-#	fi
-#	if test x$enable_threads = xyes; then
-#		thread_file='dce'
-#		tmake_file="${tmake_file} pa/t-dce-thr"
-#	fi
+	case x${enable_threads} in
+	xyes | xposix )
+		thread_file=posix 
+		;;
+	esac
 	install_headers_dir=install-headers-cpio
 	use_collect2=yes
 	;;
@@ -1296,9 +1290,11 @@ ia64*-*-hpux*)
 	tm_file="${tm_file} dbxelf.h elfos.h svr4.h ia64/sysv4.h ia64/hpux.h ia64/hpux_longdouble.h"
 	tmake_file="ia64/t-ia64 ia64/t-hpux"
 	target_cpu_default="MASK_GNU_AS"
-	if test x$enable_threads = xyes; then
-		thread_file='posix'
-	fi
+	case x$enable_threads in
+	xyes | xposix )
+		thread_file=posix
+		;;
+	esac
 	use_collect2=no
 	c_target_objs="ia64-c.o"
 	cxx_target_objs="ia64-c.o"
===================================================================
Index: gcc/config/ia64/hpux.h
--- gcc/config/ia64/hpux.h	22 Aug 2003 21:09:04 -0000	1.30
+++ gcc/config/ia64/hpux.h	26 Aug 2003 06:49:50 -0000
@@ -49,6 +49,13 @@ do {							\
 	  }						\
 } while (0)
 
+#undef CPP_SPEC
+#define CPP_SPEC \
+  "%{mt|pthread:-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L}"
+/* aCC defines also -DRWSTD_MULTI_THREAD, -DRW_MULTI_THREAD.  These
+   affect only aCC's C++ library (Rogue Wave-derived) which we do not
+   use, and they violate the user's name space.  */
+
 #undef  ASM_EXTRA_SPEC
 #define ASM_EXTRA_SPEC "%{milp32:-milp32} %{mlp64:-mlp64}"
 
@@ -68,6 +75,7 @@ do {							\
 #undef  LIB_SPEC
 #define LIB_SPEC \
   "%{!shared: \
+     %{mt|pthread:-lpthread} \
      %{p:%{!mlp64:-L/usr/lib/hpux32/libp} \
 	 %{mlp64:-L/usr/lib/hpux64/libp} -lprof} \
      %{pg:%{!mlp64:-L/usr/lib/hpux32/libp} \
@@ -133,6 +141,10 @@ do {								\
 
 #undef TARGET_HPUX_LD
 #define TARGET_HPUX_LD	1
+
+/* The HPUX dynamic linker objects to weak symbols with no
+   definitions, so do not use them in gthr-posix.h.  */
+#define GTHREAD_USE_WEAK 0
 
 /* Put out the needed function declarations at the end.  */
 
===================================================================
Index: gcc/config/pa/pa-hpux11.h
--- gcc/config/pa/pa-hpux11.h	23 Aug 2003 01:32:54 -0000	1.12
+++ gcc/config/pa/pa-hpux11.h	26 Aug 2003 06:49:50 -0000
@@ -74,6 +74,13 @@ Boston, MA 02111-1307, USA.  */
     }								\
   while (0)
 
+#undef CPP_SPEC
+#define CPP_SPEC \
+  "%{mt|pthread:-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L}"
+/* aCC defines also -DRWSTD_MULTI_THREAD, -DRW_MULTI_THREAD.  These
+   affect only aCC's C++ library (Rogue Wave-derived) which we do not
+   use, and they violate the user's name space.  */
+
 /* We can debug dynamically linked executables on hpux11; we also
    want dereferencing of a NULL pointer to cause a SEGV.  */
 #undef LINK_SPEC
@@ -100,15 +107,12 @@ Boston, MA 02111-1307, USA.  */
    %{static:-a archive} %{shared:-b}"
 #endif
 
-/* Like the default, except no -lg.  */
+/* hpux 11 has posix threads.  */
 #undef LIB_SPEC
 #define LIB_SPEC \
   "%{!shared:\
-     %{!p:%{!pg:\
-       %{!threads:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}\
-       %{threads:-lcma -lc_r}}}\
-     %{p:%{!pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
-     %{pg:-lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}"
+     %{mt|pthread:-lpthread} -lc \
+     %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}"
 
 /* Under hpux11, the normal location of the `ld' and `as' programs is the
    /usr/ccs/bin directory.  */
===================================================================
Index: gcc/config/pa/pa64-hpux.h
--- gcc/config/pa/pa64-hpux.h	23 Aug 2003 01:32:59 -0000	1.29
+++ gcc/config/pa/pa64-hpux.h	26 Aug 2003 06:49:50 -0000
@@ -383,3 +383,7 @@ PA_INIT_FINI_HACK
    and returns 0.  /bin/true cannot be used because it is a script without
    an interpreter.  */
 #define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size"
+
+/* The HPUX dynamic linker objects to weak symbols with no
+   definitions, so do not use them in gthr-posix.h.  */
+#define GTHREAD_USE_WEAK 0
===================================================================
Index: libstdc++-v3/config/os/hpux/os_defines.h
--- libstdc++-v3/config/os/hpux/os_defines.h	5 Jul 2003 04:05:31 -0000	1.8
+++ libstdc++-v3/config/os/hpux/os_defines.h	26 Aug 2003 06:49:51 -0000
@@ -97,8 +97,9 @@ typedef long int __padding_type;
 #define _GLIBCXX_INST_ATOMICITY_LOCK 1
 #endif
 
-/* Don't use pragma weak in gthread headers.  */
-#ifdef __hppa__
+/* Don't use pragma weak in gthread headers.  HP-UX rejects programs
+   with unsatisfied external references even if all of those references
+   are weak; gthread relies on such unsatisfied references being resolved
+   to null pointers when weak symbol support is on.  */
 #define _GLIBCXX_GTHREAD_USE_WEAK 0
-#endif
 #endif

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