Building Squeak for the gumstix

Squeak is a Smalltalk interpreter that runs on a variety of platforms, including linux. Out of the box, it builds fine if you have a self hosted environment. For my gumstix, I'm using a cross compiler, and I don't have X Windows support, so I needed to modify the build process slightly.

Self Hosted Build

  • Download the squeak tarball.
  • Unpack it
  • Perform these steps:
    cd Squeak-3.6-3 (or whatever version you're using)
    mkdir bld
    cd bld
    ../platforms/unix/config/configure
    make
    su -c 'make install'
    

Building with buildroot

I put together a buildroot package. Create a directory call squeak inside the gumstix-buildroot/packages directory, and then copy all of the files from http://www.DaveHylands.com/squeak/buildroot/ into it. Edit the packages/Config.in file and add the following line:

     source "package/squeak/Config.in"
The packages are in alphabetical order, so I placed it just before the entry for sqlite. In the event that the http://piumarta.com website is down, I put a copy of the squeak tarball over here. Copy it into gumstix-buildroot/dl.

Testing squeak

The buildroot makefile will create the following files on the gumstix filesystem:
     /usr/bin/squeak (symlink to /usr/lib/squeak/3.6-3/squeak)
     /usr/lib/squeak/3.6-3/squeak
     /usr/lib/squeak/3.6-3/vm-display-null
     /usr/lib/squeak/3.6-3/vm-sound-null
     /usr/lib/squeak/3.6-3/vm-sound-OSS
     /usr/lib/squeak/3.6-3/UnixOSProcessPlugin
Copy run.sh and headlessTest.image onto the gumstix. Run the run.sh file, and it should exit shortly, creating a file imageReport.txt. If everything was successful, then the imageReport.txt file will contain "If you can read this, Squeak is working!"

Cross Compiler Build

Using the cross compiler requires some changes to the configure script, since it assumes that it can compile some C code and execute the resulting code. The simple way to do this is to create a modified configure.ac script.

IMPORTANT NOTE: The steps below work for the gumstix. I determined what to do by taking the snippets of code that configure tries to use and I manually cross-compiled and executed them on the gumstix to verify what was going to happen.

  • If you don't have autoconf version 2.5 or newer, then download it, build it and install it. I used 2.57 since that was the version used to create the configure script that came with 3.6-3. I found older versions of autoconf here.
  • Change to the directory containing configure.ac
         cd Squeak-3.6-3/platforms/unix/config
    
  • Copy configure.ac to configure-gumstix.ac and replace the following lines in configure-gumstix.ac:
         AC_REQUIRE_SIZEOF(int,    4)
         AC_REQUIRE_SIZEOF(time_t, 4)
         AC_REQUIRE_SIZEOF(double, 8)
         AC_CHECK_INT64_T
    
    with:
         #AC_REQUIRE_SIZEOF(int,    4)
         #AC_REQUIRE_SIZEOF(time_t, 4)
         #AC_REQUIRE_SIZEOF(double, 8)
         #AC_CHECK_INT64_T
         SQUEAK_INT64_T="long long"
         AC_DEFINE_UNQUOTED(squeakInt64, long long)
    
    Comment out these two lines:
         AC_C_DOUBLE_ALIGNMENT
         AC_C_DOUBLE_ORDER
    
    and add the AC_DEFINE to become:
         #AC_C_DOUBLE_ALIGNMENT
         #AC_C_DOUBLE_ORDER
         AC_DEFINE(DOUBLE_WORD_ORDER)
    
    Change this line:
         disabled_plugins=""
    
    with:
         disabled_plugins="vm-display-fbdev SqueakFFIPrims"
    
  • We need to make one minor tweak to Makefile.in. Find these lines:
         $(squeak) : config.sh $(SQLIBS) version.o
                 $(LINK) $(squeak) $(SQLIBS) version.o $(LIBS) [plibs] vm/vm.a
                 @echo
                 @size $(squeak)
                 @echo
                 @./$(squeak) -version
                 @echo
    
    and comment out the last two lines. Trying to execute squeak will fail since it's been built for the ARM rather than the native platform. Commenting out the call to squeak allows the rest of the build process to continue.
         $(squeak) : config.sh $(SQLIBS) version.o
                 $(LINK) $(squeak) $(SQLIBS) version.o $(LIBS) [plibs] vm/vm.a
                 @echo
                 @size $(squeak)
                 @echo
                 #@./$(squeak) -version
                 #@echo
    
  • Setup the plugins:
        ./mkacinc > acplugins.m4
        autoconf -o configure-gumstix configure-gumstix.ac
        rm acplugins.m4
    
  • Fix some source files. Recent versions of uClibc add a function prototype for a function called clone. This conflicts with a function called clone in the squeak sources. In the src/vm/interp.c file replace all occurences of clone with sq_clone. In platforms/Cross/vm/sqVirtualMachine.c, replace all occurences of clone with sq_clone except for this one: "VM->clone".
  • Make sure that arm-linux-uclibc-gcc is in your path. I added /home/dhylands/gumstix/gumstix-buildroot/build_arm/staging_dir/bin to my path. For whatever reason, I had to use a fully qualified path and couldn't use one with ~ in it or make wouldn't recognize it.
  • Now run the configure-gumstix script. Note the --no-builtin-xxx stuff was needed with version 0.9.27 of uClibc and may or may not be needed with newer versions. Without these, I got linker errors about expf, sinf, and cosf all being missing functions.
         cd ../../..   (into the Squeak-3.6-3 directory)
         mkdir bld-gumstix
         cd bld-gumstix
         CC=arm-linux-uclibc-gcc CFLAGS='--no-builtin-exp --no-builtin-cos --no-builtin-sin -O3' \
             ../platforms/unix/config/configure-gumstix --without-x --without-npsqueak \
             --without-rfb --without-ffi --host=arm-linux --prefix=/usr/squeak
         make
         su -c 'make install'
    
  • copy all of the files from /usr/squeak/lib/squeak/3.6-3/ onto the gumstix. Due to the size, you'll need to use an MMC card, since there's only about 1.2 Mb of free space in the flash image on the gumstix.

I discovered that with gcc 3.4.2 that not all of the optimization flags were capable of producing working VMs. Here's a small table that shows what I observed:
FlagsStripped
Executable Size
Bytecodes/secSends/sec
none1,442,1087,912,957267,270
-O1850,980--
-O2786,996--
-O3944,98821,798,365784,482
-Os752,540--
The entries with - in them all failed due to an illegal instruction. The bytecodes/sec and sends/sec came from tinyBenchmark.


Home - linux - gumstix

Copyright 2007 by Dave Hylands