Sunday, March 3, 2013

Building Jikes RVM on Ubuntu 12.04 / 64 bit from source

Jikes RVM is a research virtual machine, built using Java. Building Jikes RVM from the source (trunk) is pretty interesting.


Installing the pre-requisites

Mercurial is the version control system of Jikes RVM. (To learn the basics of Mercurial, please refer to this article.) Jikes RVM is built using Apache Ant. Make sure to install these.
sudo apt-get install mercurial ant

Install gcc, g++, gcc-multilib, and g++-multilib
sudo apt-get install gcc-multilib g++-multilib


Checking out the source

Checkout the source code of Jikes RVM.
hg clone http://hg.code.sourceforge.net/p/jikesrvm/code jikesrvm

Updating the source
If you have already checked out the source code sometime back, you may have to update it to reflect the later changes.
To view the information of the working directory, such as the version number, from the root directory,
hg log -l1


To update,
hg pull

hg update



Building using Ant
Find the target architecture of your system.
uname -m
x86_64


Build using Ant from jikesrvm (the root directory of Jikes RVM).
 ant -Dconfig.name=prototype -Dhost.name=x86_64-linux -Dtarget.name=x86_64-linux

Here,
1) host.name and target.name entries should match the names of the properties files present in the directory jikesrvm/build/hosts (without the suffix, .properties).

2) config.name entry should match the names of the properties files present in the directory jikesrvm/build/configs (without the suffix, .properties).

You may alternatively build Jikes using the buildit tool that is included in the project.
 bin/buildit -j $JAVA_HOME localhost production


Common Exceptions

1) You may encounter the below exceptions, if you have 32-bit GTK libraries installed on a 64-bit machine.
     [exec] checking for X... no
     [exec] configure: error: GTK+ peers requested but no X library available

BUILD FAILED
/home/pradeeban/jikesrvm/build.xml:266: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build.xml:272: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/classpath.xml:305: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/base.xml:70: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/base.xml:76: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/classpath.xml:254: exec returned: 1
Passing the flag -Dcp.enable.gtk-peer="--disable-gtk-peer" will fix this issue.

 ant -Dconfig.name=prototype -Dhost.name=x86_64-linux -Dtarget.name=x86_64-linux -Dcp.enable.gtk-peer="--disable-gtk-peer"

2) You may encounter the below exceptions, if you miss gcc-multilib and g++-multilib in your system.

build:
     [exec] checking build system type... Invalid configuration `x86_64-unknown-linux-': machine `x86_64-unknown-linux' not recognized
     [exec] configure: error: /bin/bash ./config.sub x86_64-unknown-linux- failed

BUILD FAILED
/home/pradeeban/jikesrvm/build.xml:266: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build.xml:272: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/classpath.xml:305: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/base.xml:70: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/base.xml:76: The following error occurred while executing this line:
/home/pradeeban/jikesrvm/build/components/classpath.xml:254: exec returned: 1

Running Jikes RVM
Once built, you will find the complete rvm runtime directory at ${dist.dir}/${config.name}_${target.name} (For me, it was dist/prototype_x86_64-linux, as I built with 'prototype' configuration). Now you should be able to run the rvm from the directory. A Java class can be run as below.
javac HelloWorld.java
./rvm HelloWorld

5 comments:

  1. Thanks a lot ayye, I was trying to build JikesRVM in my Ubuntu 12.10 64 bit installation and this guide really helped me.

    ReplyDelete
  2. wow.. really.. I am glad to hear that a blog post helped my friend within a day I wrote it.. :)

    ReplyDelete
  3. I really recommend using the 'buildit' script. You can pass additional arguments to ant from buildit using the flag --build-arg.

    Either way, if you have arguments for ant that you always use, you can put them in .ant.properties in the current directory, rather than enter them on the command line.

    ReplyDelete
  4. thanks Pradeeban, i just build done but how is build correctly?

    ReplyDelete

You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.