The goal of this article is to guide you through compiling and running Barrelfish inside QEMU, and to write and run programs on Barrelfish itself. The instructions below assume you are using a recent version of Linux.

Requirements

Barrelfish requires the following tools to compile correctly:

Getting Barrelfish

First we need to get the latest version of Barrelfish from the mercurial repository. Use the following command:

hg clone http://hg.barrelfish.org

or, if you are using an HTTP proxy:

hg --config http_proxy.host=ipOfYourProxyServer:portOfYourProxyServer --config http_proxy.user=user --config http_proxy.passwd=password clone http://hg.barrelfish.org

Configuring

Once you have cloned the repository, cd into it, create a build directory, and enter it:

cd hg.barrelfish.org
mkdir build
cd build

Then create the required makefile:

../hake/hake.sh -s .. -a x86_64

or, if you wish to build the 32-bit version:

../hake/hake.sh -s .. -a x86_32

Valid arm targets are:

../hake/hake.sh -s .. -a arm

or

../hake/hake.sh -s .. -a arm11mp

Note: If you get the following error:

../hake/Main.hs:369:25:
    Not in scope: data constructor `Opt_DeriveDataTypeable'

Apply the following patch to hake/Main.hs: Main.hs.patch

Compiling

Now we can build Barrelfish:

make

To speed things up you can specify a number of jobs. This should ideally be slightly more than the number of cores, so on a 4-core machine you could use:

make -j 5

Once that has completed, you can issue the following command to run Barrelfish on QEMU:

make sim

To allocate more cores to QEMU, instead of the default 2, you can edit the symbolic_targets.mk file in the build directory. Do this by editing the QEMU_CMD line for the architecture you've chosen for Barrelfish.

Known Issues

QEMU-kvm

If you get the following error when booting Barrelfish:

ERROR: pci.0 in AcpiOsInstallInterruptHandler() ../usr/pci/acpica_osglue.c:831
ERROR: failed to route interrupt
Failure: (            pci) Unknown global system interrupt number [PCI_ERR_UNKNOWN_GSI]
Assertion failed on core 0 in pci: r == 0, function init_acpi, file ../usr/pci/acpi.c, line 725.
Aborted

This is most likely due to Barrelfish being run inside QEMU-kvm. To fix this you can add '-no-kvm' to the QEMU_CMD in build/symbolic_targets.mk Alternatively, if you have an intel CPU, you can issue the following command as root: 'rmmod kvm_intel kvm'

GHC 6.12.2

There is a bug in some versions of GHC 6.12.2 on ubuntu and GHC 6.12.1 which causes the Barrelfish build to fail. If you see errors like the following:

../tools/fof/IL/FoF/Compile.lhs:71:18:
    Can't find interface-file declaration for variable freshVar
      Probable cause: bug in .hi-boot file, or inconsistent .hi file
      Use -ddump-if-trace to get an idea of which file caused the error
    In the expression: freshVar binding
    In the definition of `loc': loc = freshVar binding
    In the definition of `getFreshVar':
        getFreshVar binding
                      = (loc, binding1)
                      where
                          loc = freshVar binding
                          binding1 = binding {freshVar = loc + 1}
 
../tools/fof/IL/FoF/Compile.lhs:72:23:
    Can't find interface-file declaration for variable freshVar
      Probable cause: bug in .hi-boot file, or inconsistent .hi file
      Use -ddump-if-trace to get an idea of which file caused the error
    In the expression: binding {freshVar = loc + 1}
    In the definition of `binding1':
        binding1 = binding {freshVar = loc + 1}
    In the definition of `getFreshVar':
        getFreshVar binding
                      = (loc, binding1)
                      where
                          loc = freshVar binding
                          binding1 = binding {freshVar = loc + 1}
 
../tools/fof/IL/FoF/Compile.lhs:92:6:
    Can't find interface-file declaration for variable freshVar
      Probable cause: bug in .hi-boot file, or inconsistent .hi file
      Use -ddump-if-trace to get an idea of which file caused the error
    In the expression:
        stableBinding
          {freshVar = freshVar upBinding, defStructs = defStructs upBinding,
           defUnions = defUnions upBinding, defEnums = defEnums upBinding}
    In the definition of `passFreshVar':
        passFreshVar upBinding stableBinding
                       = stableBinding
                           {freshVar = freshVar upBinding, defStructs = defStructs upBinding,
                            defUnions = defUnions upBinding, defEnums = defEnums upBinding}

Upgrade your version of GHC if possible, or compile and install a newer version of GHC from source and prepend the path where it is installed to your PATH variable.