This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libjava: Add option to disable BC ABI in libgcj.


Static linking with libgcj does not work well when portions are compiled
with the BC ABI.  The problem is that the compile time linker is not
able to resolve all the needed dependencies.

This patch adds a new configure option (--disable-libgcj-bc) that forces
all code in libgcj to be compiled with the C++ ABI.  The default is to
compile libgcj 'normally'.  This option would only be used by those
statically linking to libgcj.

Tested on i686-pc-linux-gnu with no failures in libjava testsuite.  I
also verified by inspecting build output that -findirect-dispatch
-fno-indirect-classes is being passed when compiling the BC ABI files.

OK to commit?

gcc/
2007-12-21  David Daney  <ddaney@avtrex.com>

    * doc/install.texi (disable-libgcj-bc): Document new option.

libjava/
2007-12-21  David Daney  <ddaney@avtrex.com>

    * scripts/makemake.tcl (emit_bc_rule): Use $(LIBGCJ_BC_FLAGS)
    instead of -findirect-dispatch -fno-indirect-classes.
    * configure.ac (libgcj-bc): New AC_ARG_ENABLE.
    (SUPPRESS_LIBGCJ_BC): New AM_CONDITIONAL.
    * Makefile.am (LIBGCJ_BC_FLAGS): New variable.
    * Makefile.in: Regenerate.
    * include/Makefile.in: Same.
    * testsuite/Makefile.in: Same.
    * configure: Same.
    * gcj/Makefile.in: Same.
    * sources.am: Same.

Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi	(revision 131121)
+++ gcc/doc/install.texi	(working copy)
@@ -1554,6 +1554,16 @@ using non-functional stubs for native me
 @item --disable-jvmpi
 Disable JVMPI support.
 
+@item --disable-libgcj-bc
+Disable BC ABI compilation of certain parts of libgcj.  By default,
+some portions of libgcj are compiled with @option{-findirect-dispatch}
+@option{-fno-indirect-classes}.  This allows them to be overridden at
+runtime.
+
+If @option{--disable-libgcj-bc} is specified, libgcj is built without
+these options.  This makes it impossible to override portions of
+libgcj at runtime, but can make it easier to statically link to libgcj.
+
 @item --with-ecos
 Enable runtime eCos target support.
 
Index: libjava/scripts/makemake.tcl
===================================================================
--- libjava/scripts/makemake.tcl	(revision 131121)
+++ libjava/scripts/makemake.tcl	(working copy)
@@ -317,7 +317,9 @@ proc emit_bc_rule {package} {
   if {$package_map($package) == "bc"} {
     puts -nonewline "-fjni "
   }
-  puts "-findirect-dispatch -fno-indirect-classes -c -o $loname @$tname"
+  # Unless bc is disabled with --disable-libgcj-bc, $(LIBGCJ_BC_FLAGS) is:
+  #   -findirect-dispatch -fno-indirect-classes
+  puts "\$(LIBGCJ_BC_FLAGS) -c -o $loname @$tname"
   puts "\t@rm -f $tname"
   puts ""
 
Index: libjava/configure.ac
===================================================================
--- libjava/configure.ac	(revision 131121)
+++ libjava/configure.ac	(working copy)
@@ -514,6 +514,15 @@ AC_ARG_WITH(java-home,
 AM_CONDITIONAL(JAVA_HOME_SET, test ! -z "$JAVA_HOME")
 AC_SUBST(JAVA_HOME)
 
+suppress_libgcj_bc=no
+AC_ARG_ENABLE(libgcj-bc,
+  AS_HELP_STRING([--enable-libgcj-bc],
+                 [enable(default) or disable BC ABI for portions of libgcj]),
+  [if test "$enable_libgcj_bc" = "no"; then
+     suppress_libgcj_bc=yes
+   fi])
+AM_CONDITIONAL(SUPPRESS_LIBGCJ_BC, test "$suppress_libgcj_bc" = "yes")
+
 # What is the native OS API for MinGW?
 AC_ARG_WITH(win32-nlsapi,
   AS_HELP_STRING([--with-win32-nlsapi=ansi or unicows or unicode],
Index: libjava/Makefile.am
===================================================================
--- libjava/Makefile.am	(revision 131121)
+++ libjava/Makefile.am	(working copy)
@@ -155,6 +155,12 @@ if USING_GCC
 AM_CFLAGS += $(WARNINGS)
 endif
 
+if SUPPRESS_LIBGCJ_BC
+LIBGCJ_BC_FLAGS =
+else
+LIBGCJ_BC_FLAGS = -findirect-dispatch -fno-indirect-classes
+endif
+
 ## Extra CFLAGS used for JNI C sources shared with GNU Classpath.
 PEDANTIC_CFLAGS = -ansi -pedantic -Wall -Wno-long-long
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]