Eclipse Native Compilation using GCJ

November 23, 2006

I have been experimenting with Eclipse and Gcj. Here is a procedure to compile Eclipse as native binary using Gcj tools.

1. Download Eclipse and necessary plugins.
2. Go to eclipse installation directory and run the following script.

#!/bin/sh
libdir=${libdir:-lib-native}
if ! test -e eclipse.db; then
    gcj-dbtool -n eclipse.db
    recreate_db=yes
else
    recreate_db=no
fi
for JAR_FILE in `find -iname "*.jar"`; do
    thislib_destdir=${libdir}/$(dirname ${JAR_FILE}.so)
    thislib_destfile=${libdir}/${JAR_FILE}.so
    if ! test -e ${thislib_destfile}; then
        test -e ${thislib_destdir} || mkdir -p ${thislib_destdir}
        echo -n "Compiling ${JAR_FILE} to native ... "
        gcj -shared -findirect-dispatch -Wl,-Bsymbolic -fjni -fPIC
            -o ${thislib_destfile} ${JAR_FILE}
        echo -n "adding to eclipse.db ... "
        gcj-dbtool -a eclipse.db ${JAR_FILE} ${thislib_destfile}
        echo "[OK]"
    else
        echo -n "${JAR_FILE} already compiled"
        if test "x${recreate_db}" = xyes; then
            echo -n ", but not in eclipse.db, adding ... "
            gcj-dbtool -a eclipse.db ${JAR_FILE} ${thislib_destfile}
            echo "[OK]"
        else
            echo " and in eclipse.db, [OK]"
        fi
    fi
done

3. Execute the script

#chmod +x ./eclipse-gcj-lib.sh
#./eclipse-gcj-lib.sh

4. Run native compiled Eclipse with following command –

./eclipse -consoleLog -debug -vm gij -vmargs -Dgnu.gcj.precompiled.db.path=eclipse.db

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: