2009年4月22日

Porting JVM to Embedded Device

Using Infineon Wildpass as target platform. "http://www.linux-mips.org/wiki/Adm5120#ADM8668_-_WildPass".
The compilation(host) platform is Fedora 10 installed in VMware.

Files:
classpath-0.97.2.tar.gz (classpath-0.98.tar.gz, Not recommend.)
fastjar-0.97.tar.gz
libtool-1.5.20.tar.gz (libtool-2.2.6.tar.gz, Not recommend.)
zziplib-0.13.50.tar.bz2
kaffe-1.1.9.tar.bz2

Define PREFIX as "TARGET/ramdisk/usr".
Define TARGET as "mipsel-linux".
Define HOST as "i386-redhat-linux".

Building Procedure:

1. Untar all files and run "./configure; make; make install" to install programs to host machine. It will reduce some compiling troubles.

2. Compile classpath-0.97.2.tar.gz
# ./configure --prefix=${PREFIX} --target=${TARGET} --host=${TARGET} --build=${HOST} CC=${IFX_CC} CFLAGS=-O2 --disable-gtk-peer --disable-gconf-peer --disable-plugin
# make CC=${IFX_CC} STRIP=${IFX_STRIP} LD=${IFX_LD} AR=${IFX_AR} RANLIB=${IFX_RANLIB} IFX_CFLAGS="${IFX_CFLAGS}" IFX_LDFLAGS="${IFX_LDFLAGS}"
# make install

3. Compile fastjar-0.97.tar.gz, libtool-2.2.6a.tar.gz and zziplib-0.13.50.tar.bz2
# ./configure --prefix=${PREFIX} --host=${TARGET} --build=${HOST} CC=${IFX_CC} CFLAGS=-O2
# make CC=${IFX_CC} STRIP=${IFX_STRIP} LD=${IFX_LD} AR=${IFX_AR} RANLIB=${IFX_RANLIB} IFX_CFLAGS="${IFX_CFLAGS}" IFX_LDFLAGS="${IFX_LDFLAGS}"

# make install


4. Compile kaffe-1.1.9.tar.bz2
# ./configure --prefix=${IFX_ROOTFS_DIR}JVM --host=${TARGET} --build=${HOST} CC=${IFX_CC} CFLAGS=-O2 ZZIP_CFLAGS=-I${IFX_ROOTFS_DIR}JVM/include ZZIP_LIBS=-L${IFX_ROOTFS_DIR}JVM/lib
# make CC=${IFX_CC} STRIP=${IFX_STRIP} LD=${IFX_LD} AR=${IFX_AR} RANLIB=${IFX_RANLIB} IFX_CFLAGS="${IFX_CFLAGS}" IFX_LDFLAGS="${IFX_LDFLAGS}"
# make install


Issues Solved:

1. With the latest libtool-2.2.6a, kaffe may fail in configuring as:
#checking for library containing lt_dlcaller_register... no
#configure: error: Can't find the libltdl library.
Thus, to vanish the configuring error, here we install an old version, libtool-1.5.20, for building kaffe.

2. The two ZZIP related arguments are used to solve:
#checking for ZZIP... configure: error: Package requirements (zziplib >= 0.13.24) were not met: #No package 'zziplib' found

3. If you encounter cross-compiling error as following, please install kaffe to host first.
# configure: error: please set KAFFEH to the full pathname of a locally executable kaffeh
Reference from: "http://www.kaffe.org/pipermail/kaffe/2002-October/177793.html".

While compiling kaffe for host machine, you may see make failure due to "CPStringBuilder" issue.
#ERROR in java/lang/reflect/Constructor.java (at line 235)
# Modifier.toString(getModifiers(), sb).append(' ');
^^^^^^^^
#The method toString(int, CPStringBuilder) in the type Modifier is not applicable for the #arguments (int, StringBuilder)
In my case, this issue comes with classpath-0.98.tar.gz package, but it is vanished after downgrade to classpath-0.97.2.tar.gz. Maybe 0.98 version is too new?

4. Issue prompt while cross-compiling kaffe:
# trampolines.S:33:11: invalid preprocessing directive #needed # trampolines.S:46:11: invalid preprocessing directive #$fp
Commenting/removing those two lines to pass the compilation.
(Is it a correct fix? Not sure.)

5. Issue prompt while cross-compiling kaffe:
# : undefined reference to `lt_preloaded_symbols'
# ../../kaffe/kaffevm/.libs/libkaffe.so: undefined reference to `isfinite'
# ../../kaffe/kaffevm/.libs/libkaffe.so: undefined reference to `signbit'
# ../../kaffe/kaffevm/.libs/libkaffe.so: undefined reference to `g_atomic_pointer_compare_and_exchange'

Still ongoing ...