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]

Re: [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00


> The following two minor changes fix the default bootstrap failure on
> hppa2.0w-hp-hpux11.00 for me.  The issue is that on my PA/HPUX system
> the foo_r forms of libc functions aren't prototyped by the system
> headers unless the macro _REENTRANT is defined.  If GCC is using the
> posix thread model, then this macro is defined for us by the -pthread
> command line option in THREADCXXFLAGS, but in the default "single"
> thread model, it isn't and libjava fails with calls to undeclared
> functions.

Yes.

> Rather than insert the necessary #define _REENTRANT hack into
> libjava/gnu/classpath/natSystemProperties.cc and all the other
> places that'd require it, libjava conventiently provides a
> posix.h header specially for such hacks.  Unfortunately, it's
> not currently included by java/io/natFilePosix.cc, so the second
> hunk below adds the same #include <platform.h> idiom used elsewhere.
> 
> With these changes the libjava almost reaches the end of the
> top-level "make bootstrap" for me, but unfortunately most/all?
> of the compiled java programs "hang" when run, including the
> gcj_dbtool invocation at the very end of the build!  Doh!.

Try installing the latest HP linker patch.

> Tested on hppa2.0w-hp-hpux11.00, configured with the command
> "../gcc/configure --with-gnu-as --with-as=/usr/local/bin/as",
> followed by "make bootstrap", where "as --version" is 2.15.
> 
> Is this patch ok for mainline?  Should we change the default
> GCC thread model on hppa*-hp-hpux* to posix from single?  Is
> there something else I'm doing wrong that's causing the java
> executables to hang?  Many thanks in advance.  And also to the
> folks who've managed to get gcj (almost) working on PA/HPUX.
> 
> 
> 
> 2006-06-28  Roger Sayle  <roger@eyesopen.com>
> 
> 	* include/posix.h: Ensure that _REENTRANT is defined on HP-UX.
> 	* java/io/natFilePosix.cc: #include <platform.h>.

I'm not convinced this is the correct approach to fix the lack
of _REENTRANT being defined (see below).  This might also allow
building libjava on hpux 10.x.  There are some testsuite issues
which I haven't had a chance to look at in detail.

It's an open question in my mind as to whether we should force posix
threads when building libjava on hpux 11.  This might be the best
option.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

Index: gnu/classpath/natSystemProperties.cc
===================================================================
--- gnu/classpath/natSystemProperties.cc	(revision 113941)
+++ gnu/classpath/natSystemProperties.cc	(working copy)
@@ -203,7 +203,7 @@
   uid_t user_id = getuid ();
   struct passwd *pwd_entry;
 
-#ifdef HAVE_GETPWUID_R
+#if defined(HAVE_GETPWUID_R) && defined(_REENTRANT)
   struct passwd pwd_r;
   size_t len_r = 200;
   char *buf_r = (char *) _Jv_AllocBytes (len_r);
Index: java/io/natFilePosix.cc
===================================================================
--- java/io/natFilePosix.cc	(revision 113941)
+++ java/io/natFilePosix.cc	(working copy)
@@ -215,7 +215,7 @@
 
   java::util::ArrayList *list = new java::util::ArrayList ();
   struct dirent *d;
-#ifdef HAVE_READDIR_R
+#if defined(HAVE_READDIR_R) && defined(_REENTRANT)
   int name_max = pathconf (buf, _PC_NAME_MAX);
   char dbuf[sizeof (struct dirent) + name_max + 1];
   while (readdir_r (dir, (struct dirent *) dbuf, &d) == 0 && d != NULL)
Index: java/util/natVMTimeZone.cc
===================================================================
--- java/util/natVMTimeZone.cc	(revision 113941)
+++ java/util/natVMTimeZone.cc	(working copy)
@@ -54,7 +54,7 @@
 java::util::VMTimeZone::getSystemTimeZoneId()
 {
   struct tm tim;
-#ifndef HAVE_LOCALTIME_R
+#if !defined(HAVE_LOCALTIME_R) || !defined(_REENTRANT)
   struct tm *lt_tim;
 #endif
 #ifdef HAVE_TM_ZONE
@@ -66,7 +66,7 @@
   char *tzid;
 
   time(&current_time);
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
   localtime_r(&current_time, &tim);
 #else
   /* Fall back on non-thread safe localtime. */


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