zafena development

October 16, 2009

From time to time I get the question: How do I make a native build of Icedtea6 using Shark and LLVM on ARM?
Here is how I do it:

First all dependencies needed to build llvm and openjdk needs to be installed, if you are using Ubuntu then this can be satisfied quite easily by typing in these two lines.

apt-get build-dep openjdk-6-jdk llvm
apt-get install cmake mercurial subversion-tools openjdk-6-jdk ccache

The next little script does all the magic, it download the sources using subversion and mercurial, configures and starts the building!

svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
mkdir llvm-cmake
cd llvm-cmake
cmake -DCMAKE_BUILD_TYPE:STRING=ReleaseWithDebInfo \
-DLLVM_BUILD_TOOLS:BOOL=ON \
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
-DLLVM_ENABLE_ASSERTIONS:BOOL=ON \
-DLLVM_TARGETS_TO_BUILD:STRING=ARM ../llvm
make
make install
cd ..
hg clone http://icedtea.classpath.org/hg/icedtea6
cd icedtea6
./autogen.sh
cd ..
mkdir icedtea6-shark-build
cd icedtea6-shark-build
../icedtea6/configure --enable-zero --enable-shark --disable-docs --disable-bootstrap
make

Enjoy!

#Shark can also be built using a LLVM shared library:
#here i will configure LLVM using configure instead of cmake.

wget http://llvm.org/releases/2.9/llvm-2.9.tgz
tar zxvf llvm-2.9.tgz
mkdir llvm-2.9-build
cd llvm-2.9-build
../llvm-2.9/configure --enable-targets=arm,powerpc,x86 --enable-shared --enable-assertions -enable-optimized --enable-docs=no --enable-debug-symbols=yes
make
sudo make install
sudo ldconfig
cd ..
wget http://icedtea.classpath.org/download/source/icedtea6-1.10.1.tar.gz
tar zxvf icedtea6-1.10.1.tar.gz
cd icedtea6-1.10.1
wget http://icedtea.classpath.org/bugzilla/attachment.cgi?id=511 -O icedtea6-1.10-shark-llvm-2.9.patch
patch -p1 < icedtea6-1.10-shark-llvm-2.9.patch
./autogen.sh
cd ..
mkdir icedtea6-1.10.1-shark
cd icedtea6-1.10.1-shark
../icedtea6-1.10.1/configure --enable-zero --enable-shark --disable-docs --disable-bootstrap
make

5 Comments »

  1. Hum, interesting. Since LLVM can target the iPhone, would it be possible to compile JVM bytecode for the iPhone using a Shark/Zero/LLVM/iPhone toolchain ?

    That would make developing applications for iPhone in Java possible, which would be really cool :)

    Comment by Cédric Vidal — November 4, 2009 @ 20:43

  2. Hi Cédric!

    Guillaume Legris have made some great progress getting JavaME applications running on the iPhone using MIDPath, you should check it out its awesome: http://bloggl.thenesis.org/2009/03/midpath-on-iphone.html
    JamVM are currently the most well tested jvm to use on the iPhone, try it!
    http://draenog.blogspot.com/2008/11/jamvmgnu-classpathiphone-roundup.html

    Ok back to your question: Yes, LLVM have great support for Darwin so I see no issues compiling it for the iPhone and MIDPath can be configured to use JavaSE JVM’s like hotspot and Zero/Shark so you should be able to get some GUI’s up and running as well!

    The only issue that I can see are that hotspot JVM using Zero/Shark are currently only known to compile and run on Linux therefore some more porting work are required to get it running under Darwin as well. The OpenJDK BSD porters are the ones to team up with to make it happen!
    http://landonf.bikemonkey.org/2008/08/20
    http://landonf.bikemonkey.org/static/soylatte/
    http://mail.openjdk.java.net/mailman/listinfo/bsd-port-dev

    Cheers and have a great day!
    Xerxes

    Comment by xerxes — November 4, 2009 @ 21:58

  3. I got this error at the last step:
    /home/locpx/zafena/icedtea6-shark-build/openjdk/hotspot/src/share/vm/shark/llvmHeaders.hpp:54:38: fatal error: llvm/Target/TargetSelect.h: No such file or directory
    compilation terminated.
    make[7]: *** [compileBroker.o] Error 1
    make[7]: *** Waiting for unfinished jobs….
    make[7]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/openjdk.build/hotspot/outputdir/linux_i486_shark/product’
    make[6]: *** [the_vm] Error 2
    make[6]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/openjdk.build/hotspot/outputdir/linux_i486_shark/product’
    make[5]: *** [productshark] Error 2
    make[5]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/openjdk.build/hotspot/outputdir’
    make[4]: *** [generic_buildshark] Error 2
    make[4]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/openjdk/hotspot/make’
    make[3]: *** [productshark] Error 2
    make[3]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/openjdk/hotspot/make’
    make[2]: *** [hotspot-build] Error 2
    make[2]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/openjdk’
    make[1]: *** [build_product_image] Error 2
    make[1]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/openjdk’
    make: *** [stamps/icedtea.stamp] Error 2

    Could you help to fix it?
    Thank you very much.

    Comment by locpx — May 7, 2012 @ 16:26

  4. The Shark codebase currently only support building against LLVM 2.6-2.9.

    You are building shark against a too new version of LLVM (3.0 and later).
    There exist some patches on the zero-dev mailinglist to update Shark to support LLVM 3.0 and later, consider this work in progress:
    http://mail.openjdk.java.net/pipermail/zero-dev/2011-August/000399.html
    0-sharkllvm30-targetselect-138450.patch:
    The TargetSelect header have been moved to a new location.
    1-sharkllvm30-de-const-type-135375.patch:
    This patch are a pain, basically all LLVM types have dropped const in LLVM 3.0.

    http://mail.openjdk.java.net/pipermail/zero-dev/2011-August/000400.html
    2-sharkllvm30-PHI-128537-Call-ArrayRef-135265-v2.patch

    http://mail.openjdk.java.net/pipermail/zero-dev/2011-August/000402.html
    3-sharkllvm30-MCJIT-v3.patch

    http://mail.openjdk.java.net/pipermail/zero-dev/2012-January/000411.html
    shark-removed-intrinsics.patch

    Comment by xerxes — June 18, 2012 @ 11:34

  5. Roman Kennke have picked up maintenance of shark:
    http://rkennke.wordpress.com/2012/11/20/the-return-of-the-shark/
    http://rkennke.wordpress.com/2012/11/28/the-return-of-the-shark-part-ii-howto/

    Comment by Xerxes Rånby — May 30, 2013 @ 09:21

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress