public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00
@ 2006-06-29  0:15 Roger Sayle
  2006-06-29  1:30 ` Bryce McKinlay
  2006-06-29  1:48 ` John David Anglin
  0 siblings, 2 replies; 6+ messages in thread
From: Roger Sayle @ 2006-06-29  0:15 UTC (permalink / raw)
  To: gcc-patches, java-patches; +Cc: John David Anglin


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00
  2006-06-29  0:15 [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00 Roger Sayle
@ 2006-06-29  1:30 ` Bryce McKinlay
  2006-06-29  1:48   ` John David Anglin
  2006-06-29  1:48 ` John David Anglin
  1 sibling, 1 reply; 6+ messages in thread
From: Bryce McKinlay @ 2006-06-29  1:30 UTC (permalink / raw)
  To: Roger Sayle; +Cc: gcc-patches, java-patches, John David Anglin

Roger Sayle wrote:
> 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!.
>   

Possibly, libgcj just doesn't work without threads - I doubt anyone has 
tested a "no threads" libgcj configuration for a while. In any case, 
Java is not very useful without threads - did you try it with posix 
threads enabled? HPUX has those, right? :)
> 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>.
>   

This shouldn't really be needed. There is an autoconf macro to do it 
already, so libjava's configure.ac should be defining it.

Bryce

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00
  2006-06-29  1:30 ` Bryce McKinlay
@ 2006-06-29  1:48   ` John David Anglin
  0 siblings, 0 replies; 6+ messages in thread
From: John David Anglin @ 2006-06-29  1:48 UTC (permalink / raw)
  To: Bryce McKinlay; +Cc: roger, gcc-patches, java-patches

> This shouldn't really be needed. There is an autoconf macro to do it 
> already, so libjava's configure.ac should be defining it.

I believe the define comes from boehm-gc.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00
  2006-06-29  0:15 [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00 Roger Sayle
  2006-06-29  1:30 ` Bryce McKinlay
@ 2006-06-29  1:48 ` John David Anglin
  2006-07-05 17:46   ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: John David Anglin @ 2006-06-29  1:48 UTC (permalink / raw)
  To: Roger Sayle; +Cc: gcc-patches, java-patches

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00
  2006-06-29  1:48 ` John David Anglin
@ 2006-07-05 17:46   ` Tom Tromey
  2006-07-05 21:49     ` John David Anglin
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2006-07-05 17:46 UTC (permalink / raw)
  To: John David Anglin; +Cc: Roger Sayle, gcc-patches, java-patches

>>>>> "Dave" == John David Anglin <dave@hiauly1.hia.nrc.ca> writes:

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

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

I never remember whether _REENTRANT is defined on all the
posix-threads-using platforms.  That's why I've been (half-heartedly)
pushing for a solution which is transparently HPUX-only... it is just
simpler to review :-)

If _REENTRANT is defined everywhere, then a patch like this one
is fine by me.  Otherwise I think it need to be handled some other
way, e.g., by changing the configure checks to realize that the
functions in question are not actually available.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00
  2006-07-05 17:46   ` Tom Tromey
@ 2006-07-05 21:49     ` John David Anglin
  0 siblings, 0 replies; 6+ messages in thread
From: John David Anglin @ 2006-07-05 21:49 UTC (permalink / raw)
  To: tromey; +Cc: roger, gcc-patches, java-patches

> I never remember whether _REENTRANT is defined on all the
> posix-threads-using platforms.  That's why I've been (half-heartedly)
> pushing for a solution which is transparently HPUX-only... it is just
> simpler to review :-)

_REENTRANT is defined when --enable-threads=posix is used under hpux11,
or when --enable-threads=yes|dce is used under hpux10 and -mt or -pthread
is present on the command line.  However, it's not defined with the
default --enable-threads=none.

> If _REENTRANT is defined everywhere, then a patch like this one
> is fine by me.  Otherwise I think it need to be handled some other
> way, e.g., by changing the configure checks to realize that the
> functions in question are not actually available.

The functions getpwuid_r, readdir_r and localtime_r are only declared
by the system headers when _REENTRANT is defined.  The functions are
present in libc under both hpux10 and hpux11.  However, the _PTHREADS_DRAFT4
hpux10 functions are not the same as POSIX hpux11 functions.  For
example,

#    ifdef _REENTRANT
#     ifdef _PTHREADS_DRAFT4
       extern int getpwuid_r(uid_t, struct passwd *, char *, int);
#     else
       extern int getpwuid_r(uid_t, struct passwd *, char *, __size_t, struct passwd **);
#     endif /* _PTHREADS_DRAFT4 */
#    endif

The _PTHREADS_DRAFT4 guard is not present in hpux10.  The hpux10 reentrant
functions aren't compatible with the POSIX ones expected by libjava.  DCE
threads also aren't usable.  So, I believe configure either has to force
threads to "none" when building libjava and boehm-gc, or the the toplevel
configure has to disable building these libraries when threads are enabled.

The libjava configure script always defines _REENTRANT when posix threads
are used.  Given that the interfaces have changed for some of these functions,
it would appear that configure needs to be enhanced to check for posix
compatible declarations of these functions.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-07-05 21:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-29  0:15 [Java PATCH] Fix libjava bootstrap issues on HP-UX 11.00 Roger Sayle
2006-06-29  1:30 ` Bryce McKinlay
2006-06-29  1:48   ` John David Anglin
2006-06-29  1:48 ` John David Anglin
2006-07-05 17:46   ` Tom Tromey
2006-07-05 21:49     ` John David Anglin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).