[PATCH] Build libjava as two separate gorillas on Windows.

Dave Korn dave.korn.cygwin@googlemail.com
Fri Aug 28 00:21:00 GMT 2009


[ ref thread: http://gcc.gnu.org/ml/gcc/2009-05/threads.html#00130
   continued: http://gcc.gnu.org/ml/gcc/2009-08/threads.html#00404
    see also: http://gcc.gnu.org/wiki/Internal_dependencies_of_libgcj ]


    Hi lists,

  Sorry, did I say "gorillas"?  I meant DLLs.  This patch enables building
libjava as two separate DLLs on Cygwin, and potentially on MinGW as well,
although I haven't tested that side of it yet.  (Offers of help there would
come in handy as I'm not set up for gcc development on MinGW.)

  The attached patch will need at least one minor respin before it's ready,
but time is running out on stage 1, so I want to put a marker down that I'd
like to get this in for 4.5.0, and hopefully get any points arising after
review done together with the known glitches all in one single respin.

  The design of the patch is fairly straightforward.  It adds a configure
option, --enable-libgcj-sublibs, with a default settable in configure.host,
and an automake conditional derived from it.  If sublibs are enabled, the
Makefile filters the list of libgcj libtool objects against a manually
generated list of core files and builds only those into libgcj, then it builds
a non-core library that depends on the core one.

  First off, there is one known bug and one known weakness in this patch.

  The bug is a missing dependency that can break parallel builds: the tools
like jv-convert.exe and gcj-dbtool.exe only currently depend on the core
library, and so might be built ahead of or in parallel with the noncore
library.  This causes the final link of the tools to fail, because both
libraries are passed to LD on the command-line via the GCJ linker spec, and LD
reports "cannot find -lgcj-noncore".  I think that to solve this I need to add
simple dependencies for them inside "if BUILD_SUBLIBS", just haven't done it
in this iteration.

  The weakness is that it systematically ignores the whole USE_LIBGCJ_BC
thing.  I didn't approach that yet because I'm not 100% clear what's going on
with it.  I /think/ that libgcj_bc.la is basically a version of libgcj
compiled with the binary abi, but there's all this stuff in the makefile about
a dummy library and making a link to the real libgcj, so maybe I don't
actually need to do anything except extend the specs handling a bit.  Advice
eagerly accepted here.

gcc/ChangeLog:

	* config/i386/cygming.h (TARGET_USE_JCR_SECTION): Enable.
	* config/i386/cygwin.h (LIBGCJ_SONAME): Define.
	* config/i386/mingw32.h (LIBGCJ_SONAME): Likewise.

libjava/ChangeLog:

	* libltdl/ltdl.h (LT_SCOPE): Change conditional to avoid breaking
	auto-export during libgcj DLL linking.
	* configure.host (enable_libgcj_sublibs_default): New variable,
	set for Cygwin and MinGW.
	* configure.ac (--enable-libgcj-sublibs): New command-line switch.
	(BUILD_SUBLIBS): New AM_CONDITIONAL relating to it.
	(libgcj_spec_lgcj_override): New variable, define if building sublibs.
	(LIBGCJ_SPEC_LGCJ): New variable to abstract "-lgcj" from specs.
	(LIBGCJ_SPEC): Use it.
	* configure: Regenerate.
	* sysdep/i386/backtrace.h (MAIN_FUNC): New #define for main function,
	set appropriately for Cygwin on that platform or to "main" elsewhere.
	(fallback_backtrace): Use it to limit stack unwind.
	* Makefile.am (LOWER_PACKAGE_FILES_LO): New variable.
	(ALL_PACKAGE_SOURCE_FILES_LO): Likewise.
	(NONCORE_PACKAGE_SOURCE_FILES_LO): Likewise.
	(CORE_PACKAGE_SOURCE_FILES_LO): Likewise.
	(toolexeclib_LTLIBRARIES): Add libgcj-noncore.la if building sublibs.
	(libgcj_noncore_la_LIBADD_SUBOBJECTS): New variable.
	(libgcj_la_LIBADD_SUBOBJECTS): Likewise.
	(libgcj_la_LDFLAGS_NOUNDEF): Likewise.
	(libgij_la_LDFLAGS): Add DLL-related options.
	(libgcj_la_LDFLAGS): Use libgcj_la_LDFLAGS_NOUNDEF and
	libgcj_la_LIBADD_SUBOBJECTS.
	(libgcj_la_DEPENDENCIES): Adjust to match.
	(libgcj_noncore_la_SOURCES, libgcj_noncore_la_LDFLAGS,
	libgcj_noncore_la_LIBADD, libgcj_noncore_la_DEPENDENCIES,
	libgcj_noncore_la_LINK): New automake variables for sublibrary.
	(libgcj_tools_la_LDFLAGS): Add DLL-related flags.
	(libgcj_tools_la_LIBADD): New variable.
	(libjvm_la_LDFLAGS): Add DLL-related flags.
	(lib_gnu_awt_xlib_la_LDFLAGS): Likewise.
	(libgcj_bc_la_LDFLAGS): Likewise.
	* Makefile.in: Regenerate.

  It bootstraps - modulo the parallel build bug - on i686-pc-cygwin, and
passes make check with no regressions (and apparently fixes the PR16923 test
compilation FAIL in passing, but I haven't looked at how or why yet, it could
be some other recent change).

  Apart from the two known issues, what else do I need to fix up before this
is good to apply?

    cheers,
      DaveK

-------------- next part --------------
A non-text attachment was scrubbed...
Name: java-sublibs-draft.diff
Type: text/x-c
Size: 16671 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090828/2683933a/attachment.bin>


More information about the Gcc-patches mailing list