Differences between revisions 43 and 53 (spanning 10 versions)
Revision 43 as of 2015-09-22 09:14:39
Size: 7545
Editor: zgerd
Comment:
Revision 53 as of 2016-12-22 21:49:03
Size: 4915
Comment: correct apt-get syntax
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
To run Barrelfish on the Pandaboard, have a look at [[PandaBoard]].
Line 7: Line 9:
 * GCC 4.8.2
 * GNU binutils 2.24 are known to work
 * GCC 5.4.0
 * GNU binutils 2.26.1 are known to work
Line 13: Line 15:
We are running nightly build tests on the latest Ubuntu LTS release (14.04.1) and are ensuring Barrelfish always builds using the Ubuntu versions of the above-mentioned tools. You can get a full build environment on Ubuntu by running the following command We are running nightly build tests on the latest Ubuntu LTS release (16.04.x) and are ensuring Barrelfish always builds using the Ubuntu versions of the above-mentioned tools. You can get a full build environment on Ubuntu by running the following command
Line 16: Line 18:
$ sudo apt-get install build-essential bison flex cmake gcc-multilib qemu-system-x86 qemu-system-arm ghc libghc-src-exts-dev libghc-ghc-paths-dev libghc-parsec3-dev libghc-random-dev libghc-ghc-mtl-dev libghc-src-exts-dev libghc-async-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libgmp3-dev cabal-install $ sudo apt-get install build-essential bison flex cmake qemu-system-x86 qemu-system-arm ghc libghc-src-exts-dev libghc-ghc-paths-dev libghc-parsec3-dev libghc-random-dev libghc-ghc-mtl-dev libghc-src-exts-dev libghc-async-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libgmp3-dev cabal-install curl freebsd-glue libelf-freebsd-dev libusb-1.0-0-dev qemu-utils gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
Line 20: Line 22:
Note: Sometimes cabal fails because its repository, [[hackage.haskell.org]], is down. In this case a mirror can be used, for example as documented in [[https://www.fpcomplete.com/blog/2015/03/hackage-mirror]].
Line 42: Line 45:
    * Packages     * Packages (already installed if you've followed the steps in the requirement section)
Line 49: Line 52:
      * libghc-random-dev
      * freebsd-glue
      * libelf-freebsd-dev
Line 50: Line 56:
    * You may also need to install the libgmp3-dev and the libghc-random-dev package
Line 54: Line 59:
    * 7.6.3 is the version we use internally (read: the version Ubuntu 14.04 LTS ships). We integrated the patch below which was kindly provided by Wang Nan ''(wangnan0 at huawei.com)'' into the main tree to enable support for this (see commit 7e4905a).

{{{{
diff --git a/hake/Main.hs b/hake/Main.hs
index 8a42a3b..bf0c75b 100644
--- a/hake/Main.hs
+++ b/hake/Main.hs
@@ -19,7 +19,7 @@ import System.Directory
 import System.Exit
 import GHC hiding (Target)
 import GHC.Paths ( libdir )
-import DynFlags ( defaultLogAction,
+import DynFlags ( defaultFatalMessager, defaultFlushOut,
                   xopt_set,
                   ExtensionFlag (Opt_DeriveDataTypeable) )
 import Data.Dynamic
@@ -362,7 +362,7 @@ evalHakeFiles o allfiles hakefiles =
                     ".",
                     (opt_bfsourcedir o) ./. "hake" ]
     in do
- defaultErrorHandler defaultLogAction $ do
+ defaultErrorHandler defaultFatalMessager defaultFlushOut $ do
          runGhc (Just libdir) $ do
            dflags <- getSessionDynFlags
           let dflags1 = foldl xopt_set dflags [ Opt_DeriveDataTypeable ]
diff --git a/tools/mackerel/Fields.hs b/tools/mackerel/Fields.hs
index 267cd5e..4d2e860 100644
--- a/tools/mackerel/Fields.hs
+++ b/tools/mackerel/Fields.hs
@@ -121,11 +121,11 @@ make_ftype t@(TypeRef _ _) dn = Just (TN.fromRef t dn)
 -- are polymorphic so that they don't need to know how large the total
 -- load unit is (32 bits? 8 bits?) etc.
 --
-extract_mask :: (Bits a) => Rec -> Integer -> a
+extract_mask :: (Num a, Bits a) => Rec -> Integer -> a
 extract_mask f sz =
     foldl setBit 0 (enumFromTo (fromInteger $ offset f)
                                (fromInteger $ (offset f) + (size f) - 1))
-insert_mask :: (Bits a) => Rec -> Integer -> a
+insert_mask :: (Num a, Bits a) => Rec -> Integer -> a
 insert_mask f sz =
     foldl complementBit (extract_mask f sz) (enumFromTo 0 (fromInteger sz - 1))

diff --git a/tools/mackerel/Main.hs b/tools/mackerel/Main.hs
index 3a8e55d..6a3e0a7 100644
--- a/tools/mackerel/Main.hs
+++ b/tools/mackerel/Main.hs
@@ -26,6 +26,7 @@ import qualified BitFieldDriver
 import qualified ShiftDriver
 import Checks
 import Dev
+import Control.Exception

 --
 -- Command line options and parsing code
diff --git a/tools/mackerel/ShiftDriver.hs b/tools/mackerel/ShiftDriver.hs
index 2a2161b..4ea09f2 100644
--- a/tools/mackerel/ShiftDriver.hs
+++ b/tools/mackerel/ShiftDriver.hs
@@ -306,12 +306,12 @@ snputs_like_call s = snprintf_like_call "snprintf" [ C.StringConstant $ percent_
 --
 -- Functions to generate masks to select or deselect a subfield of bits
 --
-select_mask :: (Bits a) => Integer -> Integer -> Integer -> a
+select_mask :: (Num a, Bits a) => Integer -> Integer -> Integer -> a
 select_mask word_size start width =
     foldl setBit 0 (enumFromTo (fromInteger $ start)
                                (fromInteger $ start + width - 1))

-deselect_mask :: (Bits a) => Integer -> Integer -> Integer -> a
+deselect_mask :: (Num a, Bits a) => Integer -> Integer -> Integer -> a
 deselect_mask word_size start width =
     foldl complementBit (select_mask word_size start width)
               (enumFromTo 0 (fromInteger word_size - 1))

}}}}
7.10.3 is the version we use internally (read: the version Ubuntu 16.04 LTS ships). Note that Haskell/GHC tends to be not very backwards compatible even for different minor versions. Therefore, it is strongly recommended to use the version that Ubuntu LTS is currently shipping.
Line 138: Line 68:
or, if you wish to build the 32-bit version:
{{{{
../hake/hake.sh -s .. -a x86_32
}}}}
Line 144: Line 71:
../hake/hake.sh -s .. -a arm ../hake/hake.sh -s .. -a armv7
Line 146: Line 73:
or or (experimental)
Line 148: Line 75:
../hake/hake.sh -s .. -a arm11mp
}}}}
or
{{{{
../hake/hake.sh
-s .. -a arm_gem5
../hake/hake.sh -s .. -a armv8
Line 155: Line 78:
'''Note:''' If you get the following error: To see what make targets are available for building Barrelfish run
Line 157: Line 80:
../hake/Main.hs:369:25:
    Not in scope: data constructor `Opt_DeriveDataTypeable'
make help-platforms
Line 160: Line 82:
Apply the following patch to hake/Main.hs: [[https://lists.inf.ethz.ch/pipermail/barrelfish-users/attachments/20110519/833cc2f8/attachment.obj|Main.hs.patch]]
To see what make targets are available for running Barrelfish run
{{{{
make help-boot
}}}}
Line 170: Line 97:
Now we can build Barrelfish: Now we can build Barrelfish. The following target builds the basic binaries for X86.
Line 172: Line 99:
make make X86_64_Basic
Line 177: Line 104:
make -j 5 make -j 5 X86_64_Basic
Line 182: Line 109:
make sim make qemu_x86_64
Line 184: Line 111:
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.
To change options for QEMU, such as allocating more cores, you might want to execute the '''tools/qemu_wrapper.sh''' directly.
The following commands allocates 4 cores.
{{{{
../tools/qemu-wrapper.sh --menu ./platforms/x86/menu.lst.x86_64 --arch x86_64 --smp 4
}}}}

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.

To run Barrelfish on the Pandaboard, have a look at PandaBoard.

Requirements

Barrelfish requires the following tools to compile correctly:

  • GCC 5.4.0
  • GNU binutils 2.26.1 are known to work
  • GNU make
  • GHC and some additional libraries
    • Some versions of GHC are not supported. See Section on GHC for more information

We are running nightly build tests on the latest Ubuntu LTS release (16.04.x) and are ensuring Barrelfish always builds using the Ubuntu versions of the above-mentioned tools. You can get a full build environment on Ubuntu by running the following command

$ sudo apt-get install build-essential bison flex cmake qemu-system-x86 qemu-system-arm ghc libghc-src-exts-dev libghc-ghc-paths-dev libghc-parsec3-dev libghc-random-dev libghc-ghc-mtl-dev libghc-src-exts-dev libghc-async-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libgmp3-dev cabal-install curl freebsd-glue libelf-freebsd-dev libusb-1.0-0-dev qemu-utils gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
$ cabal install bytestring-trie

Note: Sometimes cabal fails because its repository, hackage.haskell.org, is down. In this case a mirror can be used, for example as documented in https://www.fpcomplete.com/blog/2015/03/hackage-mirror.

Getting Barrelfish

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

git clone git://git.barrelfish.org/git/barrelfish

Configuring

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

cd barrelfish
mkdir build
cd build

Prepare for build: The hake build system

We use hake to build barrelfish.

  • You need ghc. See the README. Please, read section GHC Versions for more details.

  • Packages (already installed if you've followed the steps in the requirement section)
    • libghc-ghc-paths-dev
    • libghc-parsec3-dev
    • libghc-ghc-mtl-dev
    • libghc-src-exts-dev
    • libghc-async-dev
    • libghc-src-exts-dev
    • libghc-random-dev
    • freebsd-glue
    • libelf-freebsd-dev
    • and via Cabal: bytestring-trie

GHC Versions

7.10.3 is the version we use internally (read: the version Ubuntu 16.04 LTS ships). Note that Haskell/GHC tends to be not very backwards compatible even for different minor versions. Therefore, it is strongly recommended to use the version that Ubuntu LTS is currently shipping.

Build barrelfish

Then create the required makefile:

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

Valid arm targets are:

../hake/hake.sh -s .. -a armv7

or (experimental)

../hake/hake.sh -s .. -a armv8 

To see what make targets are available for building Barrelfish run

make help-platforms

To see what make targets are available for running Barrelfish run

make help-boot

Note: If you get the following error:

stack overflow: use +RTS -K<size> to increase it

Try to avoid having the build directory in the source tree

Compiling

Now we can build Barrelfish. The following target builds the basic binaries for X86.

make X86_64_Basic

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 X86_64_Basic

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

make qemu_x86_64

To change options for QEMU, such as allocating more cores, you might want to execute the tools/qemu_wrapper.sh directly. The following commands allocates 4 cores.

../tools/qemu-wrapper.sh --menu ./platforms/x86/menu.lst.x86_64 --arch x86_64  --smp 4

Known Issues

Gold linker

GNU binutils includes an ELF linker named "gold" which is faster than the default BFD linker for large C++ applications. However, when linking Barrelfish's CPU driver you may see the following error:

/usr/bin/ld: fatal error: -pie and -static are incompatible
collect2: error: ld returned 1 exit status
make: *** [x86_64/sbin/cpu] Error 1

To fix this issue uninstall the binutils-gold package. For further details on why this occurs see this discussion.

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