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]

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

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

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


Index: include/posix.h
===================================================================
*** include/posix.h	(revision 114960)
--- include/posix.h	(working copy)
*************** details.  */
*** 16,21 ****
--- 16,31 ----
     early so <standards.h> defines the correct version of __PIIX.  */
  #define _POSIX_PII_SOCKET

+ /* On HP-UX, _REENTRANT needs to be defined before #including <pwd.h>
+    in order to declare getpwuid_r.  With the "posix" thread model this is
+    done by the -pthread command line option in THREADCXXFLAGS.  However,
+    for GCC's "single" thread model, we need to do this ourselves.  */
+ #if defined (__hpux__)
+ #ifndef _REENTRANT
+ #define _REENTRANT 1
+ #endif
+ #endif
+
  #include <time.h>
  #include <sys/types.h>

Index: java/io/natFilePosix.cc
===================================================================
*** java/io/natFilePosix.cc	(revision 114960)
--- java/io/natFilePosix.cc	(working copy)
*************** Libgcj License.  Please consult the file
*** 9,14 ****
--- 9,15 ----
  details.  */

  #include <config.h>
+ #include <platform.h>

  #include <stdio.h>
  #include <errno.h>


Roger
--


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