Size: 11298
Comment:
|
Size: 11324
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 44: | Line 44: |
* You may also need to install the libgmp3-dev package | * You may also need to install the libgmp3-dev and the libghc-random-dev package |
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 information
- 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/barrelfish
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/barrelfish
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. Please, read section GHC Versions for more details.
- Packages
- libghc-ghc-paths-dev
- libghc-parsec2-dev (libghc-parsec3-dev seems to work as well)
- You may also need to install the libgmp3-dev and the libghc-random-dev package
GHC Versions
- 7.4.1 is the version we use internally, so this is expected to always work
7.4.2 is currently not working works thanks to a patch from Wang Nan (wangnan0 at huawei.com), which is included in our tree (see commit 69a1577d21a7).
7.6 is not supported in our tree. Wang Nan (wangnan0 at huawei.com) kindly provided a patch for this:
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))
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
or
../hake/hake.sh -s .. -a arm_gem5
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
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:
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
Note: This is deprecated. GHC 6 is not supported on recent barrelfish versions
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.
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.