public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] darwin full x86_64 and i?86 libjava support
@ 2007-12-06 22:45 Andreas Tobler
  2007-12-06 23:00 ` Eric Christopher
  2007-12-07 10:38 ` Andrew Haley
  0 siblings, 2 replies; 6+ messages in thread
From: Andreas Tobler @ 2007-12-06 22:45 UTC (permalink / raw)
  To: Java Patches, Eric Christopher

[-- Attachment #1: Type: text/plain, Size: 2159 bytes --]

Hi all,

the appended patch brings libjava support for i?86-apple-darwin9 with 
signal handling and x86_64-apple-darwin9 as well.
(the magic throw_2 passes !!!)

i?86-apple-darwin9 was tested with 32 and 64-bit support.
x86_64-apple-darwin9 only on 64-bit. According to Eric it is not 
foreseen to have a x86_64-apple-darwin9 compiler which supports -m32.

There are 2 failures in the 64-bit part, the PR16923 run part and the 
magic events output. These two failures are not unique to darwin, I see 
them as well on sparc-solaris and hupx (HPUX) 64-bit. I'll address them 
later.
On the 32-bit part there is one failure: ClosureGC.jar, and from my 
opinion this one is due to 32843, I was not able to fix this one due to 
time constraints. Also in the queue to fix.

The test results look like this:

for i?86-apple-darwin9

                 === libjava Summary for unix/-m64 ===

# of expected passes            2548
# of unexpected failures        2
# of untested testcases         1

                 === libjava Summary for unix ===

# of expected passes            2548
# of unexpected failures        1
# of untested testcases         1

                 === libjava Summary ===

# of expected passes            5096
# of unexpected failures        3
# of untested testcases         2

for x86_64-apple-darwin9:

                 === libjava Summary ===

# of expected passes            2548
# of unexpected failures        2
# of untested testcases         1

Is this patch feasible for trunk ? No regression, nothing, only improved 
situation....

Thanks for review and feedback,
Andreas


2007-12-06  Andreas Tobler  <a.tobler@schweiz.org>

	* configure.host: Add bits for i?86-*-darwin9 and x86_64-*-darwin9.
	* configure.ac: Add darwin-signal.h to x86_64-*-darwin9 and
	i?86-*darwin9.
	* configure.in: Regenerate.
	* darwin.cc: Add definitions for Darwin specific functions for 64-bit.
	(darwin_java_register_dyld_add_image_hook): Use this specific
	functions.
	* Makefile.am (gij_LDFLAGS): Add extra_gij_ldflags for Darwin9.
	* Makefile.in: Regenerate.
	* testsuite/lib/libjava.exp (libjava_arguments): Add allow_stack_execute
	for *-*-darwin9*.

[-- Attachment #2: libjava_x86_64-darwin-20071206-2.diff --]
[-- Type: text/plain, Size: 5333 bytes --]

Index: Makefile.am
===================================================================
--- Makefile.am	(revision 130657)
+++ Makefile.am	(working copy)
@@ -675,7 +675,8 @@
 ## need this because we are explicitly using libtool to link using the
 ## `.la' file.
 gij_LDFLAGS = -rpath $(dbexecdir) -rpath $(toolexeclibdir) \
-	-shared-libgcc $(THREADLDFLAGS) $(extra_ldflags)
+	-shared-libgcc $(THREADLDFLAGS) $(extra_ldflags) \
+	$(extra_gij_ldflags) 
 gij_LINK = $(GCJLINK)
 ## See jv_convert_LDADD.
 gij_LDADD = -L$(here)/.libs libgij.la
Index: darwin.cc
===================================================================
--- darwin.cc	(revision 130657)
+++ darwin.cc	(working copy)
@@ -1,6 +1,6 @@
 /* darwin.cc - class loader stuff for Darwin.  */
 
-/* Copyright (C) 2004  Free Software Foundation
+/* Copyright (C) 2004, 2007  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -21,42 +21,62 @@
    ourself.  */
 
 #include <stdint.h>
+#if !defined (__LP64__)
 struct mach_header;
+#define JAVA_MACH_HEADER mach_header
+#define  mh_size_t uint32_t
 extern "C" void _dyld_register_func_for_add_image
-  (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
+(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
 extern "C" void _dyld_register_func_for_remove_image
-  (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
+(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
 extern "C" char *getsectdatafromheader
 (const struct mach_header *mhp, const char *segname, const char *sectname,
  uint32_t *size);
+#else
+struct mach_header_64;
+#define JAVA_MACH_HEADER mach_header_64
+#define mh_size_t uint64_t
+extern "C" void _dyld_register_func_for_add_image
+(void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
+extern "C" void _dyld_register_func_for_remove_image
+(void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
+extern "C" char *getsectdatafromheader_64
+(const struct mach_header_64 *mhp, const char *segname, const char *sectname,
+ uint64_t *size);
+#endif
 
 /* When a new image is loaded, look to see if it has a jcr section
    and if so register the classes listed in it.  */
 
 static void
-darwin_java_register_dyld_add_image_hook (const struct mach_header *mh,
+darwin_java_register_dyld_add_image_hook (const struct JAVA_MACH_HEADER *mh,
 					  intptr_t slide)
 {
   char *fde;
-  uint32_t sz;
+  mh_size_t sz;
 
-  fde = getsectdatafromheader (mh, "__DATA", "jcr", &sz);
+#if defined (__LP64__)
+  fde = getsectdatafromheader_64(
+#else
+  fde = getsectdatafromheader(
+#endif
+			      mh, "__DATA", "jcr", &sz);
   if (! fde)
     return;
-  
+
   /* As far as I can tell, you're only supposed to load shared
      libraries while having a lock on java.lang.Class.  So there's
      no need to synchronize on anything here.  (I'm not sure how exactly
      you can ensure this given lazy library loading.  FIXME.)  */
- 
+
   _Jv_RegisterClasses_Counted ((const jclass *) (fde + slide),
 			       sz / sizeof (jclass *));
 }
 
 static struct darwin_constructor_s{
-  darwin_constructor_s() 
+  darwin_constructor_s()
   {
-    _dyld_register_func_for_add_image 
+    _dyld_register_func_for_add_image
       (darwin_java_register_dyld_add_image_hook);
     /* At present, you mustn't unload any java plugin.  */
   };
Index: testsuite/lib/libjava.exp
===================================================================
--- testsuite/lib/libjava.exp	(revision 130657)
+++ testsuite/lib/libjava.exp	(working copy)
@@ -429,6 +429,10 @@
 	    lappend args "additional_flags=-bind_at_load"
 	    lappend args "additional_flags=-multiply_defined suppress"
 	}
+	if { [istarget "*-*-darwin9*"] } {
+	    lappend args "additional_flags=-Wl,-allow_stack_execute"
+	}
+
     }
 
     return $args
Index: configure.ac
===================================================================
--- configure.ac	(revision 130657)
+++ configure.ac	(working copy)
@@ -788,6 +788,9 @@
     # on Darwin -single_module speeds up loading of the dynamic libraries.
     extra_ldflags_libjava=-Wl,-single_module
     ;;
+*-*-darwin[[9]]*)
+    extra_gij_ldflags=-Wl,-allow_stack_execute
+    ;;
 arm*linux*eabi)
     # Some of the ARM unwinder code is actually in libstdc++.  We
     # could in principle replicate it in libgcj, but it's better to
@@ -798,6 +801,7 @@
     ;;
 esac
 AC_SUBST(extra_ldflags_libjava)
+AC_SUBST(extra_gij_ldflags)
 AC_SUBST(extra_ldflags)
 AC_SUBST(LIBSTDCXXSPEC)
 
@@ -1546,7 +1550,7 @@
  m68*-*-linux*)
     SIGNAL_HANDLER=include/dwarf2-signal.h
     ;;
- powerpc*-*-darwin*)
+ powerpc*-*-darwin* | i?86-*-darwin9* | x86_64-*-darwin9*)
     SIGNAL_HANDLER=include/darwin-signal.h
     ;;
  *)
Index: configure.host
===================================================================
--- configure.host	(revision 130657)
+++ configure.host	(working copy)
@@ -295,6 +295,17 @@
 	slow_pthread_self=
 	can_unwind_signal=no
 	;;
+  i?86-*-darwin9*)
+	can_unwind_signal=yes
+	DIVIDESPEC=-f%{m32:no-}%{!m32:%{!m64:no-}}%{m64:}use-divide-subroutine
+        ;;
+  x86_64-*-darwin9*)
+	enable_hash_synchronization_default=yes
+	slow_pthread_self=
+	can_unwind_signal=yes
+	DIVIDESPEC=-fuse-divide-subroutine
+	CHECKREFSPEC=-fcheck-references
+	;;
   *-*-freebsd*)
 	slow_pthread_self=
 	;;

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

* Re: [patch] darwin full x86_64 and i?86 libjava support
  2007-12-06 22:45 [patch] darwin full x86_64 and i?86 libjava support Andreas Tobler
@ 2007-12-06 23:00 ` Eric Christopher
  2007-12-07 10:38 ` Andrew Haley
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Christopher @ 2007-12-06 23:00 UTC (permalink / raw)
  To: Andreas Tobler; +Cc: Java Patches


On Dec 6, 2007, at 2:45 PM, Andreas Tobler wrote:

> 2007-12-06  Andreas Tobler  <a.tobler@schweiz.org>
>
> 	* configure.host: Add bits for i?86-*-darwin9 and x86_64-*-darwin9.
> 	* configure.ac: Add darwin-signal.h to x86_64-*-darwin9 and
> 	i?86-*darwin9.
> 	* configure.in: Regenerate.
> 	* darwin.cc: Add definitions for Darwin specific functions for 64- 
> bit.
> 	(darwin_java_register_dyld_add_image_hook): Use this specific
> 	functions.
> 	* Makefile.am (gij_LDFLAGS): Add extra_gij_ldflags for Darwin9.
> 	* Makefile.in: Regenerate.
> 	* testsuite/lib/libjava.exp (libjava_arguments): Add  
> allow_stack_execute
> 	for *-*-darwin9*.

Yes, this is all correct. Thanks. OK for mainline.

-eric

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

* Re: [patch] darwin full x86_64 and i?86 libjava support
  2007-12-06 22:45 [patch] darwin full x86_64 and i?86 libjava support Andreas Tobler
  2007-12-06 23:00 ` Eric Christopher
@ 2007-12-07 10:38 ` Andrew Haley
  2007-12-07 19:39   ` Andreas Tobler
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Haley @ 2007-12-07 10:38 UTC (permalink / raw)
  To: Andreas Tobler; +Cc: Java Patches, Eric Christopher

Andreas Tobler writes:
 > 
 > 
 > Thanks for review and feedback,

Your formatting is FUBAR in a few places:

>  #include <stdint.h>
 > +#if !defined (__LP64__)
 >  struct mach_header;
 > +#define JAVA_MACH_HEADER mach_header
 > +#define  mh_size_t uint32_t
 >  extern "C" void _dyld_register_func_for_add_image
 > -  (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
 > +(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));

Whitespace incorrectly removed here, and in several other places.

 >  extern "C" void _dyld_register_func_for_remove_image
 > -  (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
 > +(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
 >  extern "C" char *getsectdatafromheader
 >  (const struct mach_header *mhp, const char *segname, const char *sectname,
 >   uint32_t *size);
 > +#else
 > +struct mach_header_64;
 > +#define JAVA_MACH_HEADER mach_header_64
 > +#define mh_size_t uint64_t
 > +extern "C" void _dyld_register_func_for_add_image
 > +(void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
 > +extern "C" void _dyld_register_func_for_remove_image
 > +(void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
 > +extern "C" char *getsectdatafromheader_64
 > +(const struct mach_header_64 *mhp, const char *segname, const char *sectname,
 > + uint64_t *size);
 > +#endif
 >  
 >  /* When a new image is loaded, look to see if it has a jcr section
 >     and if so register the classes listed in it.  */
 >  
 >  static void
 > -darwin_java_register_dyld_add_image_hook (const struct mach_header *mh,
 > +darwin_java_register_dyld_add_image_hook (const struct JAVA_MACH_HEADER *mh,
 >  					  intptr_t slide)
 >  {
 >    char *fde;
 > -  uint32_t sz;
 > +  mh_size_t sz;
 >  
 > -  fde = getsectdatafromheader (mh, "__DATA", "jcr", &sz);

This is kinda horrible:

 > +#if defined (__LP64__)
 > +  fde = getsectdatafromheader_64(
 > +#else
 > +  fde = getsectdatafromheader(
 > +#endif
 > +			      mh, "__DATA", "jcr", &sz);

Remember spaces between function names and arg lists.

Otherwise OK.

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

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

* Re: [patch] darwin full x86_64 and i?86 libjava support
  2007-12-07 10:38 ` Andrew Haley
@ 2007-12-07 19:39   ` Andreas Tobler
  2007-12-08 10:16     ` Andrew Haley
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Tobler @ 2007-12-07 19:39 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Java Patches, Eric Christopher

Andrew Haley wrote:
> Andreas Tobler writes:
>  > 
>  > 
>  > Thanks for review and feedback,
> 
> Your formatting is FUBAR in a few places:

:(

> This is kinda horrible:

Tried to make it better, see below.

>  > +#if defined (__LP64__)
>  > +  fde = getsectdatafromheader_64(
>  > +#else
>  > +  fde = getsectdatafromheader(
>  > +#endif
>  > +			      mh, "__DATA", "jcr", &sz);
> 
> Remember spaces between function names and arg lists.

Fixed.

> Otherwise OK.

Thanks!

Is the below a better approach? I'm not sure how much I can modify 
existing code when it only belongs to formatting.

Andreas

Index: darwin.cc
===================================================================
--- darwin.cc   (revision 130692)
+++ darwin.cc   (working copy)
@@ -1,6 +1,6 @@
  /* darwin.cc - class loader stuff for Darwin.  */

-/* Copyright (C) 2004  Free Software Foundation
+/* Copyright (C) 2004, 2007  Free Software Foundation

     This file is part of libgcj.

@@ -21,26 +21,44 @@
     ourself.  */

  #include <stdint.h>
-struct mach_header;
-extern "C" void _dyld_register_func_for_add_image
-  (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
-extern "C" void _dyld_register_func_for_remove_image
-  (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
-extern "C" char *getsectdatafromheader
-(const struct mach_header *mhp, const char *segname, const char *sectname,
- uint32_t *size);
+#if !defined (__LP64__)
+  struct mach_header;
+# define JAVA_MACH_HEADER mach_header
+# define  mh_size_t uint32_t
+  extern "C" void _dyld_register_func_for_add_image
+    (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
+  extern "C" void _dyld_register_func_for_remove_image
+    (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
+  extern "C" char *getsectdatafromheader
+    (const struct mach_header *mhp, const char *segname, const char 
*sectname,
+     uint32_t *size);
+# define GETDATA getsectdatafromheader
+#else
+  struct mach_header_64;
+# define JAVA_MACH_HEADER mach_header_64
+# define mh_size_t uint64_t
+  extern "C" void _dyld_register_func_for_add_image
+    (void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
+  extern "C" void _dyld_register_func_for_remove_image
+    (void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
+  extern "C" char *getsectdatafromheader_64
+    (const struct mach_header_64 *mhp, const char *segname,
+     const char *sectname, uint64_t *size);
+# define GETDATA getsectdatafromheader_64
+#endif

  /* When a new image is loaded, look to see if it has a jcr section
     and if so register the classes listed in it.  */

  static void
-darwin_java_register_dyld_add_image_hook (const struct mach_header *mh,
+darwin_java_register_dyld_add_image_hook (const struct JAVA_MACH_HEADER 
*mh,
                                           intptr_t slide)
  {
    char *fde;
-  uint32_t sz;
-
-  fde = getsectdatafromheader (mh, "__DATA", "jcr", &sz);
+  mh_size_t sz;
+
+  fde = GETDATA (mh, "__DATA", "jcr", &sz);
+
    if (! fde)
      return;

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

* Re: [patch] darwin full x86_64 and i?86 libjava support
  2007-12-07 19:39   ` Andreas Tobler
@ 2007-12-08 10:16     ` Andrew Haley
  2007-12-08 19:21       ` Andreas Tobler
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Haley @ 2007-12-08 10:16 UTC (permalink / raw)
  To: Andreas Tobler; +Cc: Java Patches, Eric Christopher

Andreas Tobler writes:
 > Andrew Haley wrote:
 > > Andreas Tobler writes:
 > >  > 
 > >  > 
 > >  > Thanks for review and feedback,
 > > 
 > > Your formatting is FUBAR in a few places:
 > 
 > :(
 > 
 > > This is kinda horrible:
 > 
 > Tried to make it better, see below.
 > 
 > >  > +#if defined (__LP64__)
 > >  > +  fde = getsectdatafromheader_64(
 > >  > +#else
 > >  > +  fde = getsectdatafromheader(
 > >  > +#endif
 > >  > +			      mh, "__DATA", "jcr", &sz);
 > > 
 > > Remember spaces between function names and arg lists.
 > 
 > Fixed.
 > 
 > > Otherwise OK.
 > 
 > Thanks!
 > 
 > Is the below a better approach? I'm not sure how much I can modify 
 > existing code when it only belongs to formatting.

That looks much better, thanks.  I was only asking you not to make
formatting worse, I wasn't asking you to fix what's there already.

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

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

* Re: [patch] darwin full x86_64 and i?86 libjava support
  2007-12-08 10:16     ` Andrew Haley
@ 2007-12-08 19:21       ` Andreas Tobler
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Tobler @ 2007-12-08 19:21 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Java Patches, Eric Christopher

Andrew Haley wrote:

>  > Is the below a better approach? I'm not sure how much I can modify 
>  > existing code when it only belongs to formatting.
> 
> That looks much better, thanks.  I was only asking you not to make
> formatting worse, I wasn't asking you to fix what's there already.

I'll commit in the next minutes with the CL below.

Thanks again for review and nitpicking. I think it is worth, honestly.

Andreas

2007-12-08  Andreas Tobler  <a.tobler@schweiz.org>

	* configure.host: Add bits for i?86-*-darwin9 and x86_64-*-darwin9.
	* configure.ac: Add darwin-signal.h to x86_64-*-darwin9 and
	i?86-*darwin9.
	* configure.in: Regenerate.
	* darwin.cc: Add definitions for Darwin specific functions for 64-bit.
	(darwin_java_register_dyld_add_image_hook): Use this specific
	functions.
	* Makefile.am (gij_LDFLAGS): Add extra_gij_ldflags for Darwin9.
	* Makefile.in: Regenerate.
	* include/Makefile.in: Likewise.
	* gcj/Makefile.in: Likewise.
	* testsuite/Makefile.in: Likewise.
	* testsuite/lib/libjava.exp (libjava_arguments): Add allow_stack_execute
	for *-*-darwin9*.

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

end of thread, other threads:[~2007-12-08 19:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-06 22:45 [patch] darwin full x86_64 and i?86 libjava support Andreas Tobler
2007-12-06 23:00 ` Eric Christopher
2007-12-07 10:38 ` Andrew Haley
2007-12-07 19:39   ` Andreas Tobler
2007-12-08 10:16     ` Andrew Haley
2007-12-08 19:21       ` Andreas Tobler

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