This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: enable static libgcj on darwin
On Wed, 27 Dec 2006, Adam Megacz wrote:
Look, if I'm wrong, please explain why classes fail to get registered
in static libgcj builds on Darwin.
In my work with micro-libgcj, I found the following patch useful. Perhaps
it addresses your problem.
diff --git a/libjava/darwin.cc b/libjava/darwin.cc
index d427ba7..6d27caf 100644
--- a/libjava/darwin.cc
+++ b/libjava/darwin.cc
@@ -61,3 +61,11 @@ static struct darwin_constructor_s{
/* At present, you mustn't unload any java plugin. */
};
} darwin_constructor;
+
+#ifdef JV_ULIBGCJ_DARWIN
+// this is here to force the linker to include the object file
+// generated from this compilation unit.
+void _Jv_DarwinStaticLinkDummyFunction(void) {
+ // do nothing
+}
+#endif//JV_ULIBGCJ_DARWIN
diff --git a/libjava/prims.cc b/libjava/prims.cc
index 3a55bfb..cf1d049 100644
--- a/libjava/prims.cc
+++ b/libjava/prims.cc
@@ -1267,6 +1267,10 @@ parse_init_args (JvVMInitArgs* vm_args)
return 0;
}
+#ifdef JV_ULIBGCJ_DARWIN
+extern void _Jv_DarwinStaticLinkDummyFunction(void);
+#endif//JV_ULIBGCJ_DARWIN
+
jint
_Jv_CreateJavaVM (JvVMInitArgs* vm_args)
{
@@ -1283,6 +1287,11 @@ _Jv_CreateJavaVM (JvVMInitArgs* vm_args)
PROCESS_GCJ_PROPERTIES;
+#ifdef JV_ULIBGCJ_DARWIN
+ // this is here to force the linker to include darwin.o.
+ _Jv_DarwinStaticLinkDummyFunction();
+#endif//JV_ULIBGCJ_DARWIN
+
/* Threads must be initialized before the GC, so that it inherits the
signal mask. */
_Jv_InitThreads ();