Contact Search RSS Feed

Filter: Yearly view
Filter (Chronologic, Yearly view)
2010>>
January(1)
February
March(1)
April(1)
May(1)
June
July
August
September
October
November
December

Building a Pharo/Squeak VM from first Principles

I've been building and modifying Squeak VMs for a couple of years, but each time I started afresh it took me considerable amount of time to set up a working toolchain. Changes in Pharo, VMMaker, platform C code, make files, in system libraries etc. can introduce subtle problems and the official documentation typically is obsolete. To help me – and others – be faster next time, I wrote the following step-by-step guide to build a Unix VM on OSX 10.6.

0. Preparation

Make sure you have xcode installed (http://developer.apple.com/tools/xcode/).
Install cmake >= 2.6.2 from http://www.cmake.org/

Create a work directory on your desktop (it is important it has no spaces!):

mkdir ~/Desktop/vmbuilding; cd ~/Desktop/vmbuilding

Let’s download a fresh Pharo image for later testing. In case you are behind a proxy, set the variable http_proxy to make wget work.

export http_proxy=http://<proxy server>
wget http://gforge.inria.fr/frs/download.php/25397/Pharo1.0-10508-rc2dev10.01.2.zip
unzip Pharo1.0-10508-rc2dev10.01.2.zip

Next we check out the VM platform-specific C sources and make files

svn co http://squeakvm.org/svn/squeak/trunk/platforms/ -r 2151

Note the use of hardcoded revision numbers to make sure these instructions still work in the future.

1. Compile from existing source

We start by compiling the source that come with Subversion. This allows us to test the basic setup without the sources we will generate ourselves.

cd platforms; mkdir build; cd build
../unix/cmake/configure --without-RomePlugin --without-vm-display-Quartz
make

If you got here without any errors you can try to start the new VM. Since Quartz does not work anymore on Snow Leopard, we use X11 as display driver and hence have to start up X11 first:

open /Applications/Utilities/X11.app
./squeak ~/Desktop/vmbuilding/Pharo1.0-10508-rc2dev10.01.2/Pharo1.0-10508-rc2dev10.01.2.image &

The Pharo image should start up now. Print “SmalltalkImage current vmVersion”, which shows the version of the image from which the VM source was built.
The result should be 'Squeak3.10.2 of ''5 June 2008'' [latest update: #7179]'.

Print and store the result of “1 tinyBenchmarks” then quit the image.

2. Install VMMaker

Start up the same image with your Mac VM:
open ~/Desktop/vmbuilding/Pharo1.0-10508-rc2dev10.01.2/Pharo1.0-10508-rc2dev10.01.2.image

In a workspace in the Pharo image do the following. If you are behind a proxy first let Pharo know. Then load VMMaker through the following Metacello config (thanks Torsten!):

HTTPSocket useProxyServerNamed: '<proxy server>' port: <port>.
Gofer new
      squeaksource: 'MetacelloRepository';
      package: 'ConfigurationOfVMMaker';
      load.
((Smalltalk at: #ConfigurationOfVMMaker) project version: '1.2') load

This takes some time. When it finished loading, we open the VMMaker GUI:

Preferences disable: #raiseDeprecatedWarnings.
VMMakerTool openInWorld

3. Configure VMMaker and generate sources

First let’s backup the original sources

mv ../unix/src ../unix/src_original

In the VMMaker GUI:
Change path to platform code: /Users/<user>/Desktop/vmbuilding/platforms
Change path to generated sources: /Users/<user>/Desktop/vmbuilding/platforms/unix/src
Don’t forget to accept the changed field by cmd-s. Leave the other settings unchanged.

Make all plugins internal (right-click in list of plugins). Then select as not built (you can drag and drop between lists): Aio, FFT, FT2, InternetConfig, MacMenubar, Mpeg3, QuickTime, Security, Sound, TestOSA

Select as external:  B3DAccelerator, FFI, FileCopy, HostWindow, MIDI, UUID, XDisplayControl.

Note, that I haven't cared to make Freetype work and have just excluded it above. In a related blog post, Laurent describes how to patch Freetype to compile on Linux.

Evaluate the following expression to force the use of LF for line breaks (else the awk script triggered by cmake does not properly work).

MultiByteFileStream defaultToLF.

Click the button Entire to generate the VM sources in the directory ./unix/src/. After the VMMaker has completed, save and quit the image.

4. Compile the new sources

We create a new build directory and compile the source we created in step 3.

mkdir ../build_new; cd ../build_new
../unix/cmake/configure --without-vm-display-Quartz
make
./squeak ~/Desktop/vmbuilding/Pharo1.0-10508-rc2dev10.01.2/Pharo1.0-10508-rc2dev10.01.2.image &

If you get here without an error, you made it! Congrats! ;)

5. Benchmarks

A good way to test the healthiness of a new VM is to run the tiny benchmarks.

1 tinyBenchmarks

The result should be similar to the ones you obtained in step 1.

On my MacBook Pro 10.6.2 with 2.4GHz Intel Core 2 Duo, gcc 4.2.1 I got
479400749 bytecodes/sec; 12303286 sends/sec.

Posted by Adrian Lienhard on March 11, 2010


Archive

Filter (Chronologic, Yearly view)
2010>>
January(1)
February
March(1)
April(1)
May(1)
June
July
August
September
October
November
December

Tweets

CMSBOX Powered by cmsbox