Toolchain from sources
These instructions have been tested on Ubuntu 12.10.
1. Edit $HOME/.bashrc and add these lines (modify these variables as you wish):
export PREFIX=$HOME/arm/opt/bf-tools export PATH=$PATH:$PREFIX/bin export TARGET=x86_64-pc-barrelfish export TOOLS=$HOME/bsc/bf-tools export BF_BUILD=$HOME/arm/bf/build
PREFIX is where the toolchain will be installed
TOOLS is the initially empty working directory
BF_BUILD is the Barrelfish build directory
TARGET is the cross compiler target. It can be:
- x86_64-pc-barrelfish
- i586-pc-barrelfish
- i586-scc-barrelfish
We exit the shell and run it again to load these variables.
2. Download and build Barrelfish for x86_64, x86_32 or scc target (this step may have been done previously). The Barrelfish release tested is 2012-11-03:
cd $TOOLS hg clone http://hg.barrelfish.org bf mkdir bf/build cd bf/build ../hake/hake.sh -a x86_64 -s .. make
3. Then, we need to install needed packages to build the toolchain:
sudo apt-get install texinfo flex gcc libgmp-dev libmpfr-dev libmpc-dev
These steps have been done using the system compiler (gcc version 4.7.2).
4. Build and install binutils: Save file binutils-2.21-bf.patch file attached in this page to the TOOLS directory
cd $TOOLS wget http://mirrors.usc.edu/pub/gnu/binutils/binutils-2.21.tar.bz2 tar xjvf binutils-2.21.tar.bz2 cd binutils-2.21/ patch -p1 < ../binutils-2.21-bf.patch cd .. mkdir binutils-2.21-build cd binutils-2.21-build/ ../binutils-2.21/configure --prefix=$PREFIX --target=$TARGET make make install
5. Build and install gcc and g++: Save file gcc-4.5.2-bf.patch file attached in this page to the TOOLS directory
cd $TOOLS wget http://ftp.gnu.org/gnu/gcc/gcc-4.5.2/gcc-4.5.2.tar.bz2 tar xjvf gcc-4.5.2.tar.bz2 cd gcc-4.5.2/ patch -p1 < ../gcc-4.5.2-bf.patch
Now we need to edit the files gcc/config/i386/bf-*.h and change the first two lines:
BF_SRC holds the directory of Barrelfish source.
BF_BUILD is the Barrelfish build directory.
Then we proceed with the compilation:
cd $TOOLS mkdir gcc-4.5.2-build cd gcc-4.5.2-build/ ../gcc-4.5.2/configure --prefix=$PREFIX --target=$TARGET --disable-nls --enable-languages=c,c++ --disable-libssp make make install
6. We can try the C++ compiler by creating a simple program test.cc and running it in Barrelfish:
#include <iostream> int main(int argc, char *argv[]) { std::cout << "Hello!" << std::endl; return 0; }
We compile it with:
x86_64-pc-barrelfish-g++ test.cc -o test
Then we copy the executable to the Barrelfish build directory and add the line to menu.lst:
cp test $BF_BUILD/x86_64/sbin cd $BF_BUILD echo "module /x86_64/sbin/test" >> menu.lst make sim