This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch [ecj]: Fix cross-configury issues / compile ecj.jar for non-shared builds
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: java-patches at gcc dot gnu dot org
- Cc: Adam Megacz <adam at megacz dot com>, tromey at redhat dot com
- Date: Thu, 07 Dec 2006 01:55:48 -0600
- Subject: Patch [ecj]: Fix cross-configury issues / compile ecj.jar for non-shared builds
- Reply-to: gnustuff at thisiscool dot com
Hi All,
This patch unbreaks the (linux,mingw) cross build and also
allows building the native Windows compiler on Linux. It
attempts to address the following issues we've discussed
previously.
- ecj1 and ecjx should be built with a build-x-host compiler,
not a build-x-target compiler as is currently being done
- ecj.jar should be compiled for non-shared and cross builds
and not interpreted
This patch probably doesn't properly handle the selection of
the build-x-host compiler. It simply picks the name based on
$with_cross_host instead of doing the proper configure tests
for it. This was a bit over my head and I rationalized it away
by saying to myself that we don't properly test for the proper
functioning of other things like gcjh, but this is a pretty
shallow rationalization. Anyway, it unbreaks the cross build
and renders it functional.
I didn't do the --whole-archive thing. With libtool in the
picture, this appears to be a pain in the *@($. The only
straightforward way of doing this with libtool seems to be
if libgcj were in a convenience library, which as far as I
can see, isn't the case.
http://gcc.gnu.org/ml/java-patches/2005-q1/msg00402.html
In any case, the statically-linked ecj1 seems to work okay,
so I guess we dodged a bullet here for now.
I tested this on the following (build,host,target) combinations:
- (i686-pc-linux-gnu,i686-pc-linux-gnu,i686-pc-linux-gnu)
- (i686-pc-linux-gnu,i686-pc-linux-gnu,i686-pc-mingw32)
- (i686-pc-linux-gnu,i686-pc-mingw32,i686-pc-mingw32)
...and everything seemed to work properly - it preserves
the original behavior for a Linux native build. I want to
do build these combinations once again completely from
scratch (after which I'll upload my MinGW ecj build).
Let me know what you think (and also whether I can check in
the PATH_SEPARATOR patch).
I'm feeling a bit burned out, so I'm not going to get to fixing
this up:
http://gcc.gnu.org/ml/java-patches/2006-q4/msg00209.html
...right away. (See the followups for Andrew's feedback.)
If anyone (<cough>Adam</cough>) wants to take this from me,
be my guest. Otherwise, I'll get to it next week or so.
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
2006-12-07 Mohan Embar <gnustuff@thisiscool.com>
* configure, Makefile.in: Rebuilt.
* configure.ac: (GCJ_FOR_ECJX) New substitution.
(host_exeext): Likewise.
(ENABLE_SHARED): New conditional,
* Makefile.am: Added GCJ_FOR_ECJX and GCJ_FOR_ECJX_LINK.
(install-exec-hook): Correctly rename ecjx to ecj1.
(ecjx_LINK, ecjx_LDFLAGS, ecjx_LDADD, ecjx_DEPENDENCIES): Define
as a function of whether we're doing a native and/or shared build.
Index: configure.ac
===================================================================
--- configure.ac (revision 119567)
+++ configure.ac (working copy)
@@ -308,19 +308,23 @@
NATIVE=yes
-# Which gcj do we use?
+# Which gcj and host gcj (for ecjx) do we use?
which_gcj=default
+host_exeext=${ac_exeext}
+GCJ_FOR_ECJX=
built_gcc_dir="`cd ${builddotdot}/../../${host_subdir}/gcc && ${PWDCMD-pwd}`"
if test -n "${with_cross_host}"; then
# We are being configured with a cross compiler. We can't
# use ac_exeext, because that is for the target platform.
NATIVE=no
cross_host_exeext=
+ GCJ_FOR_ECJX="${with_cross_host}-gcj"
case "${with_cross_host}" in
*mingw* | *cygwin*)
cross_host_exeext=.exe
;;
esac
+ host_exeext=${cross_host_exeext}
if test -x "${built_gcc_dir}/gcj${cross_host_exeext}"; then
if test x"$build_noncanonical" = x"$with_cross_host"; then
# Ordinary cross (host!=target and host=build)
@@ -367,7 +371,9 @@
;;
esac
+AC_SUBST(GCJ_FOR_ECJX)
AC_SUBST(GCJH)
+AC_SUBST(host_exeext)
# Create it, so that compile/link tests don't fail
test -f libgcj.spec || touch libgcj.spec
@@ -1317,6 +1323,7 @@
AC_SUBST(IEEESPEC)
AM_CONDITIONAL(NATIVE, test "$NATIVE" = yes)
+AM_CONDITIONAL(ENABLE_SHARED, test "$enable_shared" = yes)
AM_CONDITIONAL(NEEDS_DATA_START, test "$NEEDS_DATA_START" = yes && test "$NATIVE" = yes)
AC_SUBST(GCC_UNWIND_INCLUDE)
Index: Makefile.am
===================================================================
--- Makefile.am (revision 119567)
+++ Makefile.am (working copy)
@@ -105,6 +105,8 @@
GCJLINK = $(LIBTOOL) --tag=GCJ --mode=link $(GCJ) -L$(here) $(JC1FLAGS) \
$(LDFLAGS) -o $@
+GCJ_FOR_ECJX = @GCJ_FOR_ECJX@
+GCJ_FOR_ECJX_LINK = $(GCJ_FOR_ECJX) -o $@
LIBLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXX) -L$(here) $(JC1FLAGS) \
$(LDFLAGS) $(extra_ldflags_libjava) -o $@
@@ -441,8 +443,13 @@
rm $(toolexeclibdir)/libgcj_bc.la;
endif
if BUILD_ECJ1
- mv $(DESTDIR)$(libexecsubdir)/ecjx $(DESTDIR)$(libexecsubdir)/ecj1
-endif
+if NATIVE
+ mv $(DESTDIR)$(libexecsubdir)/ecjx$(EXEEXT) $(DESTDIR)$(libexecsubdir)/ecj1$(host_exeext)
+else !NATIVE
+## Undo the prepending of the target prefix
+ mv $(DESTDIR)$(libexecsubdir)/$(target_noncanonical)-ecjx$(EXEEXT) $(DESTDIR)$(libexecsubdir)/ecj1$(host_exeext)
+endif !NATIVE
+endif BUILD_ECJ1
## Install the headers. It is fairly ugly that we have to do this by
## hand.
@@ -672,13 +679,34 @@
## We use the BC ABI here so that we don't need to compile ecj.jar.
## Hopefully the user has compiled it into his system .db.
## However, even if not it will run reasonably quickly.
-ecjx_LDFLAGS = -findirect-dispatch \
- --main=org.eclipse.jdt.internal.compiler.batch.GCCMain \
- -Djava.class.path=$(ECJ_JAR)
+
+ECJX_BASE_FLAGS = -findirect-dispatch \
+ --main=org.eclipse.jdt.internal.compiler.batch.GCCMain
+
+if NATIVE
+
ecjx_LINK = $(GCJLINK)
+
+if ENABLE_SHARED
+## Use ecj.jar at runtime.
+ecjx_LDFLAGS = $(ECJX_BASE_FLAGS) -Djava.class.path=$(ECJ_JAR)
+else !ENABLE_SHARED
+## Use ecj.jar at compile time.
+ecjx_LDFLAGS = $(ECJX_BASE_FLAGS) $(ECJ_BUILD_JAR)
+endif !ENABLE_SHARED
+
ecjx_LDADD = -L$(here)/.libs libgcj.la
ecjx_DEPENDENCIES = libgcj.la libgcj.spec
+else !NATIVE
+
+ecjx_LINK = $(GCJ_FOR_ECJX_LINK)
+ecjx_LDFLAGS = $(ECJX_BASE_FLAGS) $(ECJ_BUILD_JAR)
+ecjx_LDADD =
+ecjx_DEPENDENCIES =
+
+endif !NATIVE
+
## This is a dummy definition.
gappletviewer_SOURCES =
gappletviewer_LDFLAGS = --main=gnu.classpath.tools.appletviewer.Main \