This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: libjava test suite keeps getting stuck
- To: Zack Weinberg <zackw at Stanford dot EDU>
- Subject: Re: libjava test suite keeps getting stuck
- From: Jeff Sturm <jsturm at one-point dot com>
- Date: Fri, 20 Apr 2001 13:21:45 -0400 (EDT)
- cc: gcc at gcc dot gnu dot org, java at gcc dot gnu dot org
On Thu, 19 Apr 2001, Zack Weinberg wrote:
> On Thu, Apr 19, 2001 at 10:24:28PM -0700, Zack Weinberg wrote:
> > On Thu, Apr 19, 2001 at 11:05:03PM -0600, Tom Tromey wrote:
> > > It would be worth experimenting on the trunk to see if we need
> > > libsupc++ at all any more. It is possible we could arrange things so
> > > that we don't need libsupc++ at all.
> >
> > Looks like a one-line edit to Makefile.am. I'll give it a whirl.
I just did the same experiment on the branch...
> ./.libs/libgcj.so: undefined reference to `operator new[](unsigned)'
> ./.libs/libgcj.so: undefined reference to `operator delete(void*)'
> ./.libs/libgcj.so: undefined reference to `__gxx_personality_v0'
> ./.libs/libgcj.so: undefined reference to `operator new(unsigned)'
> collect2: ld returned 1 exit status
>
> new and delete are used all over the place in the C++ sources of
> libjava, but it would be trivial to slurp them over from libsupc++
> with rules like
It turns out there is very little C++ usage of new/delete in libjava.
It is trivial to replace these with malloc/free (patch below). The
remaining uses of `new' are all performed on Java and don't need symbols
from libsupc++ at all (since Java uses its own GC-based allocators).
The only symbol left from EH was std::terminate. This is generated by the
c++ frontend in the cleanup code for JvSynchronize. (I don't know
if that's a c++ requirement, but it's reasonable since JvSynchronize is
a true c++ class.) It is easy to provide a replacement for
std::terminate() without any symbol conflict-- it relies only on
__terminate which is found in libgcc_s. So I suspect the concerns over
symbol duplication between libgcj and libstdc++ are largely unfounded.
Having removed libsupc++ from my tree, the testsuite completes once again
with no regressions.
Index: exception.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/exception.cc,v
retrieving revision 1.10
diff -u -p -r1.10 exception.cc
--- exception.cc 2000/10/13 04:45:57 1.10
+++ exception.cc 2001/04/20 17:01:58
@@ -161,6 +161,16 @@ _Jv_Throw (void *value)
#endif
}
+// Provide a std::terminate implementation if we do not link with C++.
+extern "C" void __terminate (void) __attribute__ ((__noreturn__));
+namespace std
+{
+ void terminate ()
+ {
+ __terminate ();
+ }
+};
+
#ifdef USE_WIN32_SIGNALLING
// This is a mangled version of _Jv_Throw and __sjthrow except
Index: posix-threads.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/posix-threads.cc,v
retrieving revision 1.22
diff -u -p -r1.22 posix-threads.cc
--- posix-threads.cc 2000/12/30 12:18:39 1.22
+++ posix-threads.cc 2001/04/20 17:01:59
@@ -300,7 +300,7 @@ _Jv_InitThreads (void)
_Jv_Thread_t *
_Jv_ThreadInitData (java::lang::Thread *obj)
{
- _Jv_Thread_t *data = new _Jv_Thread_t;
+ _Jv_Thread_t *data = (_Jv_Thread_t *) malloc (sizeof (_Jv_Thread_t));
data->flags = 0;
data->thread_obj = obj;
@@ -315,7 +315,7 @@ _Jv_ThreadDestroyData (_Jv_Thread_t *dat
{
pthread_mutex_destroy (&data->wait_mutex);
pthread_cond_destroy (&data->wait_cond);
- delete data;
+ free (data);
}
void
Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.46.4.2
diff -u -p -r1.46.4.2 prims.cc
--- prims.cc 2001/03/23 19:16:40 1.46.4.2
+++ prims.cc 2001/04/20 17:01:59
@@ -610,7 +610,7 @@ _Jv_ThisExecutable (const char *name)
{
if (name)
{
- _Jv_execName = new char[strlen (name) + 1];
+ _Jv_execName = (char *) malloc (strlen (name) + 1);
strcpy (_Jv_execName, name);
}
}
Index: java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.28.4.1
diff -u -p -r1.28.4.1 natClassLoader.cc
--- natClassLoader.cc 2001/03/03 07:28:00 1.28.4.1
+++ natClassLoader.cc 2001/04/20 17:02:03
@@ -402,7 +402,8 @@ _Jv_UnregisterClass (jclass the_class)
void
_Jv_RegisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
{
- _Jv_LoaderInfo *info = new _Jv_LoaderInfo; // non-gc alloc!
+ // non-gc alloc!
+ _Jv_LoaderInfo *info = (_Jv_LoaderInfo *) malloc (sizeof (_Jv_LoaderInfo));
jint hash = HASH_UTF(klass->name);
_Jv_MonitorEnter (&ClassClass);