Differences between revisions 1 and 19 (spanning 18 versions)
Revision 1 as of 2011-07-11 13:55:09
Size: 1496
Editor: wwwcache
Comment:
Revision 19 as of 2011-11-01 15:06:52
Size: 7926
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
The goal of this article is to guide you through compiling and running Barrelfish inside Qemu and also with writing and running programs on Barrelfish itself.
The instructions below assume you are using a recent version of Linux.
## page was renamed from Getting Started
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 Ubuntu.

=== Requirements ===
Barrelfish requires the following tools to compile correctly:
 * GCC 4.x
    4.4.5 and 4.5.2 are known to work. However, 4.4.5 throws compile warnings when building the current release as it does not support flags used by the Makefile, so 4.5.x is recommended.
 * GNU binutils 2.19 and 2.20 are known to work
 * GNU make
 * GHC and some additional libraries
      Some versions of GHC are not supported. See [[#ghc|Section on GHC]] for more informations
 * Non-kvm QEMU. The kvm version causes runtime errors, see known issues.
Line 6: Line 17:
First we need to get the latest version of Barrelfish from the mercurial repository, use the following command: First we need to get the latest version of Barrelfish from the mercurial repository. Use the following command:
Line 10: Line 21:
or, if you are using an HTTP proxy or, if you are using an HTTP proxy:
Line 12: Line 23:
hg --config http_proxy.host=ipOfYourProxyServer:portOfYourProxyServer --config http_proxy.user=user --config http_proxy.passwd=password pull http://hg.barrelfish.org hg --config http_proxy.host=ipOfYourProxyServer:portOfYourProxyServer --config http_proxy.user=user --config http_proxy.passwd=password clone http://hg.barrelfish.org
Line 15: Line 26:
Once you have cloned the repository cd into it and create a build directory and enter it === Configuring ===

Once you have cloned the repository, cd into it, create a build directory, and enter it:
Line 22: Line 35:
Then create the required makefile === Prepare for build: The hake build system ===
<<Anchor(ghc)>>

We use [[http://barrelfish.org/TN-003-Hake.pdf|hake]] to build barrelfish.

    * You need ghc. See the [[http://hg.barrelfish.org/file/tip/README|README]] file for a list of supported versions. In case your version of GHC is not supported: read section [[#ghcInstall|GHC Installation]]
    * Packages
      * libghc6-ghc-paths-dev
      * libghc6-parsec2-dev
    * You may also need to install the libgmp3-dev package

==== GHC Installation ====
<<Anchor(ghcInstall)>>

As described in the [[http://hg.barrelfish.org/file/tip/README|README]] file, some GHC versions have a bug and therefore cause problems building Barrelfish.
This section describes how to get version GHC 6.1.0.4 from the haskell website. You should skip this section if you already have a supported version of GHC.

On Ubuntu 11.10 (64 Bit) you might have to install `libgmp3c2` in order to configure and make install the downloaded ghc.

Ubuntu Lucid for example is shipped with version 6.12.1 of GHC. We are going to install an older version of the compiler, GHC 6.10.4, which is known to work.

 1. Fetch binary archive from [[http://www.haskell.org/ghc/download_ghc_6_10_4.html|haskell.org]] and set it up
 1. Install "cabal-install" (e.g. apt-get). As "normal" user (not root), execute:
  a. cabal update
  a. cabal install ghc-paths

Now, GHC 6.10.4 is the default version for the current user. Therefore, there is nothing more to do.

=== Build barrelfish ===

Then create the required makefile:
Line 26: Line 69:
or, if you wish to build the 32-bit version or, if you wish to build the 32-bit version:
Line 30: Line 73:
Valid arm targets are:
{{{{
../hake/hake.sh -s .. -a arm
}}}}
or
{{{{
../hake/hake.sh -s .. -a arm11mp
}}}}
Line 31: Line 82:
Now we can build Barrelfish '''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: [[https://lists.inf.ethz.ch/pipermail/barrelfish-users/attachments/20110519/833cc2f8/attachment.obj|Main.hs.patch]]

=== Compiling ===

Now we can build Barrelfish:
Line 36: Line 96:
To speed things up you can specify a number of jobs, this should be roughly the same as the number of cores, so on a 4-core machine you could use 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:
Line 38: Line 98:
make -j 4 make -j 5
Line 41: Line 101:
Once that has completed, you can issue the following command to run Barrelfish on Qemu Once that has completed, you can issue the following command to run Barrelfish on QEMU:
Line 45: Line 105:
To allocate more cores to Qemu, instead of the default 2, you can edit the symbolic_targets.mk file in the build directory. Editing the QEMU_CMD line for the architecture you have built Barrelfish for. 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.1/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}
}}}}
See [[#ghcInstall|this section]] on how to fix this.

=== GCC 4.6.x ===
Compilation will fail due to new warnings which have been introduced in GCC 4.6.x, these warnings can be suppressed with two flags:
{{{{
-Wno-unused-but-set-variable -Wno-format
}}}}
These must be added to the build rules file for the architecture you are building for. These are all contained in hake/. For example, for the x86_64 target, the file is X86_64.hs. The variables which must have the flags added to them are '''ourCommonFlags''' and '''kernelCFlags'''. After modifying the file, just run make and the necessary files will be recompiled and the makefile will be regenerated and compilation will resume.

'''Note:''' these flags cannot simply be added to ArchDefaults.hs as the kernel flags are specified individually for each architecture. However, this may be simpler if you are compiling Barrelfish for multiple architectures.

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 Ubuntu.

Requirements

Barrelfish requires the following tools to compile correctly:

  • GCC 4.x
    • 4.4.5 and 4.5.2 are known to work. However, 4.4.5 throws compile warnings when building the current release as it does not support flags used by the Makefile, so 4.5.x is recommended.
  • GNU binutils 2.19 and 2.20 are known to work
  • GNU make
  • GHC and some additional libraries
    • Some versions of GHC are not supported. See Section on GHC for more informations

  • Non-kvm QEMU. The kvm version causes runtime errors, see known issues.

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

Prepare for build: The hake build system

We use hake to build barrelfish.

  • You need ghc. See the README file for a list of supported versions. In case your version of GHC is not supported: read section GHC Installation

  • Packages
    • libghc6-ghc-paths-dev
    • libghc6-parsec2-dev
  • You may also need to install the libgmp3-dev package

GHC Installation

As described in the README file, some GHC versions have a bug and therefore cause problems building Barrelfish. This section describes how to get version GHC 6.1.0.4 from the haskell website. You should skip this section if you already have a supported version of GHC.

On Ubuntu 11.10 (64 Bit) you might have to install libgmp3c2 in order to configure and make install the downloaded ghc.

Ubuntu Lucid for example is shipped with version 6.12.1 of GHC. We are going to install an older version of the compiler, GHC 6.10.4, which is known to work.

  1. Fetch binary archive from haskell.org and set it up

  2. Install "cabal-install" (e.g. apt-get). As "normal" user (not root), execute:
    1. cabal update
    2. cabal install ghc-paths

Now, GHC 6.10.4 is the default version for the current user. Therefore, there is nothing more to do.

Build barrelfish

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.1/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}

See this section on how to fix this.

GCC 4.6.x

Compilation will fail due to new warnings which have been introduced in GCC 4.6.x, these warnings can be suppressed with two flags:

-Wno-unused-but-set-variable -Wno-format

These must be added to the build rules file for the architecture you are building for. These are all contained in hake/. For example, for the x86_64 target, the file is X86_64.hs. The variables which must have the flags added to them are ourCommonFlags and kernelCFlags. After modifying the file, just run make and the necessary files will be recompiled and the makefile will be regenerated and compilation will resume.

Note: these flags cannot simply be added to ArchDefaults.hs as the kernel flags are specified individually for each architecture. However, this may be simpler if you are compiling Barrelfish for multiple architectures.

BarrelfishWiki: Getting_Started (last edited 2016-12-22 21:49:03 by MoritzHoffmann)