Department of Computer Science and Technology

TESLA

Building FreeBSD

Within the FreeBSD Perforce repository, there is a TESLA branch located at //depot/projects/ctsrd/tesla/src.

To build the FreeBSD base system with TESLA instrumentation, first set up your environment, then move some LLVM-generated headers out of the way to prevent conflicts with FreeBSD system ones:

cd $LLVM_BUILD_DIR/lib/clang/3.3 mkdir unsafe mv *.h unsafe/ mv unsafe/*intrin*.h unsafe/mm3dnow.h unsafe/mm_malloc.h .

You then need to set some environment variables. With sh/bash/zsh, set:

export TESLA_SOURCE_DIR=/path/to/tesla export TESLA_BUILD_DIR=$TESLA_SOURCE_DIR/build # or wherever you ran cmake export PATH=$LLVM_BUILD_DIR/bin:$PATH:$TESLA_SOURCE_DIR/scripts

Or in csh/tcsh:

setenv TESLA_SOURCE_DIR /path/to/tesla setenv TESLA_BUILD_DIR $TESLA_SOURCE_DIR/build # or wherever you ran cmake setenv PATH $LLVM_BUILD_DIR/bin:$PATH:$TESLA_SOURCE_DIR/scripts

You then need to build the FreeBSD kernel toolchain, either by itself:

$ make -jXX kernel-toolchain

or as part of the normal buildworld process:

$ make -jXX buildworld

(where XX is the number of parallel jobs you'd like 'make' to run)

Then run make in the FreeBSD source tree with the fbsdmake wrapper script from the $TESLA_SOURCE_DIR/scripts directory:

$ fbsdmake -jXX buildkernel

This script works by setting environment variables (XCC, XCXX, etc.) that describe the TESLA toolchain and calling make, passing through command-line arguments like -jXX and buildkernel above. The result is an instrumented kernel in $OBJDIR/sys/TESLA.