Compiling JamVM + Classpath to avoid segfault

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Compiling JamVM + Classpath to avoid segfault

Robert Dodier
Administrator
Hello,

I believe I have found a combination of JamVM + Classpath + other stuff
which does not trigger a segfault (a bug which has been reported by
various people). Here are my notes. I hope this is useful to someone.

There is some stuff about wifi in there. You can ignore that.

Robert Dodier

PS. The caps-lock stuff is to help me remember. 8^)

------------------------- cut here -------------------------
YOU NEED TO EXECUTE MAKE AT LEAST THREE TIMES. FIRST TIME TO BUILD A VANILLA
BASE SYSTEM, SECOND TIME TO BUILD SPECIAL-PURPOSE PACKAGES. MY EXPERIENCE HAS
BEEN THAT IT WILL FAIL IF YOU TRY TO BUILD THE SPECIAL-PURPOSE STUFF AND BASE
SYSTEM ALL IN ONE GO.

SUMMARY: Gumstix svn -r1089 (includes Linux kernel 2.6.17) + uClibc 0.9.28.3 +
Classpath 0.90 + JamVM 1.4.2. (I tried MANY other combinations and this is the
only one which works reliably in my experience.)

Before executing make for the first time:

   1. svn co -r1089 http://svn.gumstix.com/gumstix-buildroot/trunk
gumstix-buildroot-r1089
          * ... and then cd to the new sandbox directory
   2. Toolchain options via make menuconfig
          * Verify that uClibc daily snapshot is unselected
          * Verify that gcc 3.4.5 (not any gcc 4.x version) is selected
   3. uClibc version
          * Edit toolchain/uClibc/uclibc.mk and change 0.9.28 to 0.9.28.3
   4. Copy toolchain/uClibc/uClibc-revert-ptfork-malloc-lock.patch (shown below)
          * Subversion log for ptfork.c is unclear as to purpose of the malloc
lock stuff. Comments in code suggest it is just a hack. I don't know of any bad
effects of reverting the malloc lock stuff; I haven't observed any and I haven't
read of any.
   5. Remove toolchain/uClibc/uClibc-gcc-41-raise-error.patch
          * The patched code has changed, so the patch fails. I tried to adjust
the patch accordingly but could not make it succeed. Gcc 3.4.5 is selected (see
above) so any gcc 4.x patch is irrelevant, so I just erased it.
   6. Busybox (multi-purpose executable) customization
          * Edit target/device/Gumstix/basix-connex/busybox.config to customize
(NOT package/busybox/busybox.config, that file is ignored!)
                o Enable nohup via CONFIG_NOHUP=y
   7. Linux kernel configuration
          * Linux kernel version is chosen by svn revision number (r1089 =>
Linux 2.6.17)


Now run make (for the first time, you'll need to run make again later).

After first make succeeds and before second make:

   1. Package selection via make menuconfig
          * Select jamvm, classpath, and zlib headers
          * Select ntp, strace, and tcpdump
          * Select wifistix and wireless tools
   2. Apply patch to classpath.mk to cause Classpath to be compiled with Jikes
(Java compiler)
          * classpath.mk patch is shown below
          * In addition to enabling compile by Jikes, patch also removes
dependency of Classpath on GUI libraries
          * Requires Jikes installation.
               1. Download jikes via ftp from rpmfind.net in
linux/fedora/extras/5/SRPMS/jikes-1.22-5.fc5.src.rpm
               2. Unpack & rebuild srpm, install new jikes rpm


Now run make again.

After second make succeeds:

   1. Modify build_arm_nofpu/root/etc/network/interfaces with your Wifi key and
essid.
          * Final line needs to be something like: pre-up /sbin/iwconfig $IFACE
key <MY-KEY> key open essid <MY-ESSID> txpower 100mW where <MY-KEY> and
<MY-ESSID> represent the key and essid for the device, respectively. Note that
$IFACE is a literal dollar-sign followed by IFACE.
   2. Need to generate shared object (.so) libraries from .a libraries for
Classpath (Java implementation).
         1. CC=`pwd`/build_arm_nofpu/staging_dir/bin-ccache/arm-linux-uclibc-gcc
         2. pushd ./build_arm_nofpu/root/usr/lib/classpath
         3. mkdir /tmp/FOO
         4. d=`pwd`
         5. for f in io lang langreflect net nio util; do pushd /tmp/FOO; ar x
$d/libjava$f.a; $CC --shared *.o; mv a.out $d/libjava$f.so; rm *.o; popd; done
         6. rm libjava*.a libjava*.la
         7. popd


Now run make yet again after these changes (so they are incorporated into the
filesystem image)

You're done!! Now burn the filesystem image onto your Gumstix. Have fun!!

Patch for classpath.mk

Save the following as /tmp/classpath.mk-patch and replace all <TAB> with literal
tab characters. The resulting should have md5sum =
88b0338fe4e365592c35e5b3614c7cf1. Then apply the patch by cat
/tmp/classpath.mk-patch | patch -p0.

--- package/classpath/classpath.mk<TAB>(revision 1089)
+++ package/classpath/classpath.mk<TAB>(working copy)
@@ -24,10 +24,10 @@
 $(CLASSPATH_DIR)/.configured: $(CLASSPATH_DIR)/.unpacked
 <TAB>(cd $(CLASSPATH_DIR); rm -rf config.cache; \
 <TAB><TAB>$(TARGET_CONFIGURE_OPTS) CC_FOR_BUILD=$(HOSTCC) \
-<TAB><TAB>CFLAGS="$(TARGET_CFLAGS)" \
+<TAB><TAB>CFLAGS="$(TARGET_CFLAGS) -msoft-float -fPIC" \
 <TAB><TAB>./configure \
 <TAB><TAB>--target=$(GNU_TARGET_NAME) \
-<TAB><TAB>--host=$(GNU_TARGET_NAME) \
+<TAB><TAB>--host=arm \
 <TAB><TAB>--build=$(GNU_HOST_NAME) \
 <TAB><TAB>--prefix=/usr \
 <TAB><TAB>--exec-prefix=/usr \
@@ -39,6 +39,12 @@
 <TAB><TAB>--localstatedir=/var \
 <TAB><TAB>--mandir=/usr/man \
 <TAB><TAB>--infodir=/usr/info \
+<TAB><TAB>--with-jikes \
+<TAB><TAB>--without-gcj \
+<TAB><TAB>--without-x \
+<TAB><TAB>--disable-qt-peer \
+<TAB><TAB>--disable-gconf-peer \
+<TAB><TAB>--disable-plugin \
 <TAB><TAB>--disable-gtk-peer \
 <TAB>);
 <TAB>touch  $(CLASSPATH_DIR)/.configured



New patch for uClibc, toolchain/uClibc/uClibc-revert-ptfork-malloc-lock.patch

Save the following and replace all <TAB> with literal tab characters, and
<SPACE> with a literal space character. The resulting should have md5sum =
11d2de2cde8f3378635f2838189e933c.

--- uClibc/libpthread/linuxthreads/ptfork.c<TAB>2007/01/26 00:33:53<TAB>17533
+++ uClibc/libpthread/linuxthreads/ptfork.c<TAB>2007/01/26 00:47:48<TAB>17534
@@ -26,15 +26,6 @@
 #include "pthread.h"
 #include "internals.h"
<SPACE>
-#warning hack alert... should be sufficent for system(), but what about other
libc mutexes?
-#include <bits/uClibc_mutex.h>
-
-__UCLIBC_MUTEX_EXTERN(__malloc_lock);
-
-#define __MALLOC_LOCK<TAB><TAB>__UCLIBC_MUTEX_LOCK(__malloc_lock)
-#define __MALLOC_UNLOCK<TAB><TAB>__UCLIBC_MUTEX_UNLOCK(__malloc_lock)
-#warning hack alert block end
-
 struct handler_list {
   void (*handler)(void);
   struct handler_list * next;
@@ -100,18 +91,9 @@
   parent = pthread_atfork_parent;
   pthread_mutex_unlock(&pthread_atfork_lock);
   pthread_call_handlers(prepare);
-
-#warning hack alert
-  __MALLOC_LOCK;
-
   pid = __libc_fork();
-
-#warning hack alert
-  __MALLOC_UNLOCK;
-
   if (pid == 0) {
     __pthread_reset_main_thread();
-#warning need to reconsider __fresetlockfiles!
     __fresetlockfiles();
     pthread_call_handlers(child);
   } else {

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Compiling JamVM + Classpath to avoid segfault

Jason Cox-4
Robert,
        I just went thru your patch and found that on 1410, the only thing that
is needed is the patch to classpath.mk and to install jikes on my build
machine (free-java-sdk on ubuntu). dosnt seam to require the uClib patch
Jason


On Wed, 2007-05-16 at 14:44 -0600, [hidden email] wrote:

> Hello,
>
> I believe I have found a combination of JamVM + Classpath + other stuff
> which does not trigger a segfault (a bug which has been reported by
> various people). Here are my notes. I hope this is useful to someone.
>
> There is some stuff about wifi in there. You can ignore that.
>
> Robert Dodier
>
> PS. The caps-lock stuff is to help me remember. 8^)
>
> ------------------------- cut here -------------------------
> YOU NEED TO EXECUTE MAKE AT LEAST THREE TIMES. FIRST TIME TO BUILD A VANILLA
> BASE SYSTEM, SECOND TIME TO BUILD SPECIAL-PURPOSE PACKAGES. MY EXPERIENCE HAS
> BEEN THAT IT WILL FAIL IF YOU TRY TO BUILD THE SPECIAL-PURPOSE STUFF AND BASE
> SYSTEM ALL IN ONE GO.
>
> SUMMARY: Gumstix svn -r1089 (includes Linux kernel 2.6.17) + uClibc 0.9.28.3 +
> Classpath 0.90 + JamVM 1.4.2. (I tried MANY other combinations and this is the
> only one which works reliably in my experience.)
>
> Before executing make for the first time:
>
>    1. svn co -r1089 http://svn.gumstix.com/gumstix-buildroot/trunk
> gumstix-buildroot-r1089
>           * ... and then cd to the new sandbox directory
>    2. Toolchain options via make menuconfig
>           * Verify that uClibc daily snapshot is unselected
>           * Verify that gcc 3.4.5 (not any gcc 4.x version) is selected
>    3. uClibc version
>           * Edit toolchain/uClibc/uclibc.mk and change 0.9.28 to 0.9.28.3
>    4. Copy toolchain/uClibc/uClibc-revert-ptfork-malloc-lock.patch (shown below)
>           * Subversion log for ptfork.c is unclear as to purpose of the malloc
> lock stuff. Comments in code suggest it is just a hack. I don't know of any bad
> effects of reverting the malloc lock stuff; I haven't observed any and I haven't
> read of any.
>    5. Remove toolchain/uClibc/uClibc-gcc-41-raise-error.patch
>           * The patched code has changed, so the patch fails. I tried to adjust
> the patch accordingly but could not make it succeed. Gcc 3.4.5 is selected (see
> above) so any gcc 4.x patch is irrelevant, so I just erased it.
>    6. Busybox (multi-purpose executable) customization
>           * Edit target/device/Gumstix/basix-connex/busybox.config to customize
> (NOT package/busybox/busybox.config, that file is ignored!)
>                 o Enable nohup via CONFIG_NOHUP=y
>    7. Linux kernel configuration
>           * Linux kernel version is chosen by svn revision number (r1089 =>
> Linux 2.6.17)
>
>
> Now run make (for the first time, you'll need to run make again later).
>
> After first make succeeds and before second make:
>
>    1. Package selection via make menuconfig
>           * Select jamvm, classpath, and zlib headers
>           * Select ntp, strace, and tcpdump
>           * Select wifistix and wireless tools
>    2. Apply patch to classpath.mk to cause Classpath to be compiled with Jikes
> (Java compiler)
>           * classpath.mk patch is shown below
>           * In addition to enabling compile by Jikes, patch also removes
> dependency of Classpath on GUI libraries
>           * Requires Jikes installation.
>                1. Download jikes via ftp from rpmfind.net in
> linux/fedora/extras/5/SRPMS/jikes-1.22-5.fc5.src.rpm
>                2. Unpack & rebuild srpm, install new jikes rpm
>
>
> Now run make again.
>
> After second make succeeds:
>
>    1. Modify build_arm_nofpu/root/etc/network/interfaces with your Wifi key and
> essid.
>           * Final line needs to be something like: pre-up /sbin/iwconfig $IFACE
> key <MY-KEY> key open essid <MY-ESSID> txpower 100mW where <MY-KEY> and
> <MY-ESSID> represent the key and essid for the device, respectively. Note that
> $IFACE is a literal dollar-sign followed by IFACE.
>    2. Need to generate shared object (.so) libraries from .a libraries for
> Classpath (Java implementation).
>          1. CC=`pwd`/build_arm_nofpu/staging_dir/bin-ccache/arm-linux-uclibc-gcc
>          2. pushd ./build_arm_nofpu/root/usr/lib/classpath
>          3. mkdir /tmp/FOO
>          4. d=`pwd`
>          5. for f in io lang langreflect net nio util; do pushd /tmp/FOO; ar x
> $d/libjava$f.a; $CC --shared *.o; mv a.out $d/libjava$f.so; rm *.o; popd; done
>          6. rm libjava*.a libjava*.la
>          7. popd
>
>
> Now run make yet again after these changes (so they are incorporated into the
> filesystem image)
>
> You're done!! Now burn the filesystem image onto your Gumstix. Have fun!!
>
> Patch for classpath.mk
>
> Save the following as /tmp/classpath.mk-patch and replace all <TAB> with literal
> tab characters. The resulting should have md5sum =
> 88b0338fe4e365592c35e5b3614c7cf1. Then apply the patch by cat
> /tmp/classpath.mk-patch | patch -p0.
>
> --- package/classpath/classpath.mk<TAB>(revision 1089)
> +++ package/classpath/classpath.mk<TAB>(working copy)
> @@ -24,10 +24,10 @@
>  $(CLASSPATH_DIR)/.configured: $(CLASSPATH_DIR)/.unpacked
>  <TAB>(cd $(CLASSPATH_DIR); rm -rf config.cache; \
>  <TAB><TAB>$(TARGET_CONFIGURE_OPTS) CC_FOR_BUILD=$(HOSTCC) \
> -<TAB><TAB>CFLAGS="$(TARGET_CFLAGS)" \
> +<TAB><TAB>CFLAGS="$(TARGET_CFLAGS) -msoft-float -fPIC" \
>  <TAB><TAB>./configure \
>  <TAB><TAB>--target=$(GNU_TARGET_NAME) \
> -<TAB><TAB>--host=$(GNU_TARGET_NAME) \
> +<TAB><TAB>--host=arm \
>  <TAB><TAB>--build=$(GNU_HOST_NAME) \
>  <TAB><TAB>--prefix=/usr \
>  <TAB><TAB>--exec-prefix=/usr \
> @@ -39,6 +39,12 @@
>  <TAB><TAB>--localstatedir=/var \
>  <TAB><TAB>--mandir=/usr/man \
>  <TAB><TAB>--infodir=/usr/info \
> +<TAB><TAB>--with-jikes \
> +<TAB><TAB>--without-gcj \
> +<TAB><TAB>--without-x \
> +<TAB><TAB>--disable-qt-peer \
> +<TAB><TAB>--disable-gconf-peer \
> +<TAB><TAB>--disable-plugin \
>  <TAB><TAB>--disable-gtk-peer \
>  <TAB>);
>  <TAB>touch  $(CLASSPATH_DIR)/.configured
>
>
>
> New patch for uClibc, toolchain/uClibc/uClibc-revert-ptfork-malloc-lock.patch
>
> Save the following and replace all <TAB> with literal tab characters, and
> <SPACE> with a literal space character. The resulting should have md5sum =
> 11d2de2cde8f3378635f2838189e933c.
>
> --- uClibc/libpthread/linuxthreads/ptfork.c<TAB>2007/01/26 00:33:53<TAB>17533
> +++ uClibc/libpthread/linuxthreads/ptfork.c<TAB>2007/01/26 00:47:48<TAB>17534
> @@ -26,15 +26,6 @@
>  #include "pthread.h"
>  #include "internals.h"
> <SPACE>
> -#warning hack alert... should be sufficent for system(), but what about other
> libc mutexes?
> -#include <bits/uClibc_mutex.h>
> -
> -__UCLIBC_MUTEX_EXTERN(__malloc_lock);
> -
> -#define __MALLOC_LOCK<TAB><TAB>__UCLIBC_MUTEX_LOCK(__malloc_lock)
> -#define __MALLOC_UNLOCK<TAB><TAB>__UCLIBC_MUTEX_UNLOCK(__malloc_lock)
> -#warning hack alert block end
> -
>  struct handler_list {
>    void (*handler)(void);
>    struct handler_list * next;
> @@ -100,18 +91,9 @@
>    parent = pthread_atfork_parent;
>    pthread_mutex_unlock(&pthread_atfork_lock);
>    pthread_call_handlers(prepare);
> -
> -#warning hack alert
> -  __MALLOC_LOCK;
> -
>    pid = __libc_fork();
> -
> -#warning hack alert
> -  __MALLOC_UNLOCK;
> -
>    if (pid == 0) {
>      __pthread_reset_main_thread();
> -#warning need to reconsider __fresetlockfiles!
>      __fresetlockfiles();
>      pthread_call_handlers(child);
>    } else {
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> gumstix-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Loading...