OpenWrt Forum Archive

Topic: troubles building SableVM a portable JVM

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Because I am not familiar with cross building I am using the rules script included in ipkg.skel.tar.gz. to compile sablevm. Unfortunatly the configure script can not locate the libffi, a required lib. For those who are interested I could not build libffi-1.20 for mipsel with the rules script. libffi from the gcc cvs was the version I found that would build for mipsel with the rules script.

I have tried to edit the rules script in what I thought would be the correct area to no avail.

# Package specific flags
PKG_LDFLAGS=/mnt/extra/buildroot/sablevm-1.1.9/lib/
PKG_CFLAGS=/mnt/extra/buildroot/sablevm-1.1.9/include/
PKG_LD_LIBRARY_PATH=/mnt/extra/buildroot/sablevm-1.1.9/lib/

I have also tried placing the libs and inlcude file in some different places without any luck.

If someone could detail the buildprocess step by step without the rules script I think it would be a great help to the community. Of course a jvm package would also be convienent.
sablevm is availible at : http://sablevm.org

Thank you for your time.

If someone could detail the buildprocess step by step without the rules script I think it would be a great help to the community. Of course a jvm package would also be convienent.

What's in the rules script highly depends on what you need to do to build the software you want to package. Basically, it's a "wrapper" makefile which executes all commands which are needed to compile (and install into a temporary directory) the software you intend to package.

So, if you need to tell sablevm where its dependencies live, you will have to take a look at the options the buildprocess of sablevm takes.

That said, it looks like sablevm's configure script isn't very smart. So your best bet is to meddle with CFLAGS and LDFLAGS to point the compiler to the proper include and library dirs.

On a side note, you need:

libffi (download from the sablevm page)
libltdl (part of libtool)
libpopt (part of popt)

When I make these includes and libraries available, sablevm's configure script finds them, but still bombs out on libltdl because it keeps looking for it in /usr/lib (which is the regular x86 version of it, hence the compile fails).

Weird

Hi all,

you can find a minimal working sablevm here :

root@ap4:~# sablevm -V
SableVM version 1.1.9
- compile date and time: 2005-02-27 15:14:52 UTC
- gcc version: 3.3.3
- 'real life brokenness' features enabled
- copying garbage collection
- bidirectional object layout
- direct-threaded interpreter

I'll post details later on how to build the beast.
What should go next ? sablevm-classpath ?

--
Nico

I appreciate you building this package but could you please explain how you built this ? something about making fires and catching fish.....

Thanks in advance.

provolone,

basically, i took the dependencies mentionned : · libffi-sable, patched to be used with gcc and mipsel (see attachment)
· lipopt
· libltdl (libtool)
· zlib

I installed each of them in $(STAGING_DIR)/usr, with headers going to $(STAGING_DIR)/usr/include and libs going to $(STAGING_DIR)/usr/lib.

SableVM is then configured like this :

$(TARGET_CONFIGURE_OPTS) 
CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" 
LDFLAGS="$(TARGET_CFLAGS) -L$(STAGING_DIR)/usr/lib" 
./configure 
  --target=$(GNU_TARGET_NAME) 
  --host=$(GNU_TARGET_NAME) 
  --build=$(GNU_HOST_NAME) 
  --prefix=/usr 
  --exec-prefix=/usr 
  --bindir=/usr/bin 
  --datadir=/usr/share 
  --includedir=/usr/include 
  --infodir=/usr/share/info 
  --libdir=/usr/lib 
  --libexecdir=/usr/lib 
  --localstatedir=/var 
  --mandir=/usr/share/man 
  --sbindir=/usr/sbin 
  --sysconfdir=/etc 
  $(DISABLE_NLS) 

You can look at the *-dev packages to see what's included and even install them into your $(STAGING_DIR)...

--
Nico

provolone,

basically, i took the dependencies mentionned : · libffi-sable, patched to be used with gcc and mipsel (see attachment)
· lipopt
· libltdl (libtool)
· zlib

Yeah, I spotted the dependency on zlib later.

I installed each of them in $(STAGING_DIR)/usr, with headers going to $(STAGING_DIR)/usr/include and libs going to $(STAGING_DIR)/usr/lib.

SableVM is then configured like this :

$(TARGET_CONFIGURE_OPTS) 
CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" 
LDFLAGS="$(TARGET_CFLAGS) -L$(STAGING_DIR)/usr/lib" 
./configure 
  --target=$(GNU_TARGET_NAME) 
  --host=$(GNU_TARGET_NAME) 
  --build=$(GNU_HOST_NAME) 
  --prefix=/usr 
  --exec-prefix=/usr 
  --bindir=/usr/bin 
  --datadir=/usr/share 
  --includedir=/usr/include 
  --infodir=/usr/share/info 
  --libdir=/usr/lib 
  --libexecdir=/usr/lib 
  --localstatedir=/var 
  --mandir=/usr/share/man 
  --sbindir=/usr/sbin 
  --sysconfdir=/etc 
  $(DISABLE_NLS) 

Yeah, that's what I have too. However, I get problems with the linking. For some reason or another the sablevm build script manages to "forget" that I've added a -L, and bums out with not finding the proper libraries. Even though I do see the proper parameters supplied to gcc. Did you do anything special to sablevm to make it build?

PolarWolf,

What I've done is first build all libraries, install them into $(STAGING_DIR) using ipkg and the *-dev packages and then build sablevm. That's all...

I just uploaded the sources and build logs for all components, so that you can check what's done differently.

--
Nico

Hi all,

updated sablevm packages are available for testing :

· libffi-sable
· libltdl
· libpopt
· libpthread
· sablevm
· sablevm-classpath-mini
· zlib


The "sablevm" package contains the JVM and the "sablevm-classpath-mini" contains the minimum set of classes needed to run a sample "Hello World !" java program. Any help determining which class should be embedded in a decent sablevm-classpath package would be appreciated.

Feedback welcome, Happy testing !

Hi Nico, Hi All,

I have tested the sablevm package on my WL500g and first I got the error message:

java-sablevm -v  HelloWorld
[verbose jni: JNI_CreateJavaVM]
[verbose gc: allocating initial heap (16777216 bytes)]
sablevm: cannot create vm

I searched for the reason and find out that the problem was caused by allocating of 16M
through the garbage collector. Allocating of 16M fails because on the WL500g there is not
enough memory available per default.

cat /proc/meminfo shows there are only 3.5M available:

        total:    used:    free:  shared: buffers:  cached:
Mem:  14721024 11145216  3575808        0   528384  5185536
Swap:        0        0        0

To solve the problem I found two possibilities:

1 Creating swap space
2 Adapting  the file  ..../sablevm-1.11.3/src/libsablevm/system.h

  This file contains the defines for the heap size:

  #define SVM_HEAP_DEFAULT_MIN_SIZE 16777216
  #define SVM_HEAP_DEFAULT_MAX_SIZE 0     //  0 means no limit
  #define SVM_HEAP_DEFAULT_ALLOCATION_INCREMENT 1048576

When reducing the min heap size for example to

#define  SVM_HEAP_DEFAULT_MIN_SIZE 1048576
   
then the „HelloWorld“ example is running also without swap space.

Regards,
Dex

Dex,

a patch for this problem was in my old package archive (http://nthill.free.fr/openwrt/sources/s … 1.3-1.diff), but never went into the source repository - dunno why

If you are going to play with sablevm, I am still interested in finding the minimal set of classes required to have a "working" JVM on the router.

Thanks for your help


PS : please use TRAC to report bugs !

I included Sablevm etc. in my Openwrt build, it seemed to build just fine
but I can't get it to run HelloWorld. I tried both my own HelloWorld, and
the one from nico. I did patch libsablevm/system.h to reduce heap demand,
as suggested by Dex. I'm running it on an Asus WL-500GD.

Everything seems to compile and install fine, but I can't get it to actually run.
It does seem to load the vm.

root@asus:~#sablevm -s HelloWorld.class
...
...
[verbose class: loading "gnu/java/security/provider/DefaultPolicy"]
[verbose class: loading "HelloWorld/class"]
[verbose class: loading "java/lang/ClassNotFoundException"]
[verbose class: creating "[Ljava/lang/StackTraceElement;"]
[verbose class: loading "java/lang/Throwable$StaticData"]
java.lang.ClassNotFoundException: HelloWorld.class not found in java.lang.ClassLoader$1{urls=[file:/root/./], parent=null}
   at java.net.URLClassLoader.findClass (URLClassLoader.java:841)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:360)
   at java.lang.ClassLoader$1.loadClass (ClassLoader.java:1285)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:304)
   at java.lang.VirtualMachine.main (VirtualMachine.java:99)

Am I missing something really obvious?

Paul Hilton

Update:
I loaded the newer svn openwrt WhiteRussian, recompiled and now it all works fine.
I still have no idea what the problem was, but now it's moot.

Paul Hilton

The discussion might have continued from here.