This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: Exceptions: the "gij bug"
- To: bryce at albatross dot co dot nz
- Subject: Re: Exceptions: the "gij bug"
- From: Anthony Green <green at cygnus dot com>
- Date: Sun, 12 Dec 1999 19:44:20 -0800
- CC: java-discuss at sourceware dot cygnus dot com
- References: <384B862F.7CCB89A5@albatross.co.nz>
Bryce wrote:
> Anyone got any clues as to what might be causing this? All I know is
> that it works in gcc 2.95.2, and its broken in cvs gcc.
I blame the current broken scheme used to manage libgcc.a.
$ cat E.java
import java.io.*;
public class E
{
public static void main (String[] args) throws Exception
{
throw new IOException();
}
}
$ gcj -o E --main=E E.java
$ nm E | grep __throw
$ ./E
Aborted
$ gcj -o E --main=E E.java -Wl,-u,__throw
$ nm E | grep __throw
0804a760 T __throw
08049670 T __throw_type_match
$ ./E
java.io.IOException
libgcc should really be a system wide shared library.
The runtime linker is bringing parts of libgcc in from different
shared libraries. What's happening in the end is that the various
libgcc objects that end up linked together are not internally
consistant with one another.
Here's my proposed `fix' (although I've omitted the rebuilt configure
script) . Let me know if this works for you...
1999-12-12 Anthony Green <green@cygnus.com>
* libgcj.spec.in: Use @FORCELIBGCCSPEC@ in startfile.
* configure: Rebuilt.
* configure.in (FORCELIBGCCSPEC): Force important parts of libgcc
into every program.
Index: libjava/configure.in
===================================================================
RCS file: /cvs/java/libgcj/libjava/configure.in,v
retrieving revision 1.41
diff -u -r1.41 configure.in
--- configure.in 1999/11/19 19:13:42 1.41
+++ configure.in 1999/12/13 03:35:54
@@ -78,6 +78,12 @@
AC_DEFINE(SJLJ_EXCEPTIONS)
fi
+FORCELIBGCCSPEC=
+dnl Work around libgcc design flaw.
+if test "$with_gnu_ld" = yes; then
+ FORCELIBGCCSPEC="-u __rethrow -lgcc"
+fi
+
dnl See if the user wants to disable java.net. This is the mildly
dnl ugly way that we admit that target-side configuration sucks.
AC_ARG_ENABLE(java-net,
@@ -535,6 +541,7 @@
AC_SUBST(ZINCS)
AC_SUBST(DIVIDESPEC)
AC_SUBST(EXCEPTIONSPEC)
+AC_SUBST(FORCELIBGCCSPEC)
AM_CONDITIONAL(CANADIAN, test "$CANADIAN" = yes)
AM_CONDITIONAL(NULL_TARGET, test "$NULL_TARGET" = yes)
Index: libjava/libgcj.spec.in
===================================================================
RCS file: /cvs/java/libgcj/libjava/libgcj.spec.in,v
retrieving revision 1.7
diff -u -r1.7 libgcj.spec.in
--- libgcj.spec.in 1999/11/19 19:13:42 1.7
+++ libgcj.spec.in 1999/12/13 03:35:54
@@ -8,3 +8,11 @@
*jc1: @DIVIDESPEC@ @EXCEPTIONSPEC@
+#
+# libgcc should really be a shared library. This is a design flaw
+# that causes no end of mysterious problems. If we are using the
+# GNU linker, force parts of libgcc into the program file rather
+# than picking bits up from various shared libraries.
+#
+%rename startfile startfileorig
+*startfile: %(startfileorig) @FORCELIBGCCSPEC@
AG
--
Anthony Green Cygnus Solutions
Sunnyvale, California