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 llvm
mkdir llvm-cmake
cd llvm-cmake
cmake -DCMAKE_BUILD_TYPE:STRING=ReleaseWithDebInfo \
make install
cd ..
hg clone
cd icedtea6
cd ..
mkdir icedtea6-shark-build
cd icedtea6-shark-build
../icedtea6/configure --enable-zero --enable-shark --disable-docs --disable-bootstrap


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

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
sudo make install
sudo ldconfig
cd ..
tar zxvf icedtea6-1.10.1.tar.gz
cd icedtea6-1.10.1
wget -O icedtea6-1.10-shark-llvm-2.9.patch
patch -p1 < icedtea6-1.10-shark-llvm-2.9.patch
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


  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:
    JamVM are currently the most well tested jvm to use on the iPhone, try it!

    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!

    Cheers and have a great day!

    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/'
    make[6]: *** [the_vm] Error 2
    make[6]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/'
    make[5]: *** [productshark] Error 2
    make[5]: Leaving directory `/home/locpx/zafena/icedtea6-shark-build/'
    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:
    The TargetSelect header have been moved to a new location.
    This patch are a pain, basically all LLVM types have dropped const in LLVM 3.0.

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

  5. Roman Kennke have picked up maintenance of shark:

    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