build.md
October 1, 2025 ยท View on GitHub
How to build FoxDec (for developers)
- Install Graphviz and make sure
dotis accessible by updating thePATHenvironment variable. - Install Stack, the build tool used for developping FoxDec.
- Update the
PATHvariable:PATH=$PATH:$HOME/.local/bin - Install Capstone 4.0.1 (git), by downloading it and running
./make.shand thensudo ./make.sh install.
IMPORTANT: it must specifically be version 4.0.1, do not install Capstone using apt-get or brew as that will install a newer version. - Clone into the git
git clone git@github.com:ssrg-vt/FoxDec.git. - Go to directory
./foxdec/. - Run
stack build --haddock --haddock-arguments --odir=docs/haddock. This builds the application and generates documentation using Haddock. - Run
stack install. This copies executables to accessible locations. - Run
-c ./config/config.dhall -d examples/wc_small/ -n wc -v -i BINARY --Gmetrics. This runs FoxDec on thewcexample.
We use some tools that are assumed to be standard available and accessible (i.e., added to the PATH environment variable). For Linux, these are readelf and objdump (latter is optional but convenient).
For Mac, these are otool and nm.
With profiling enabled:
stack build --profile
time stack exec --profile -- foxdec-exe -c ./config/config.dhall -d examples/wc_small/ -n wc -v -i BINARY --Gmetrics +RTS -p
less foxdec-exe.prof
M1 ARM64 architectures
(DEPRECATED)
Regrettably, the Haskell environment is not yet up-to-date wrt. ARM64 architectures such as the M1 chip in new MacBooks. We cannot use our preferred build-tool Stack, but have a setup working using cabal. A drawback of this approach is that it may interfere with an existing installation of the Haskell environment. Also, the installation is way more involved. Specifically, it requires an edit in a .h file of MacOs' XCode Command Line Tools, which is unstable and comes with risk. As soon as Stack supports ARM64, we will revert to that approach. If there are any issues, do not hesitate to contact us.
The GitHub page is here.
-
Install the Xcode Command Line tools:
xcode-select --installConfirm the pop-up message. There is no need to install XCode in its entirety.
-
Install Graphviz and make sure
dotis accessible by updating thePATHenvironment variable. -
Install
ghcandcabalusing ghcup. Thecurl-command they provide interactively asks you which things to install; there is no need to installstackas it it is ARM64 incompatible. We have installedghc 8.10.7. -
Install
LLVM(version between 9 and 13, we have installed version 13.0.1) using homebrew:brew install llvm -
Update the
PATHvariable:export PATH="/opt/homebrew/opt/llvm/bin:$PATH" -
Install Capstone 4.0.1 (git), by downloading it and running
./make.shand thensudo ./make.sh install.
IMPORTANT: it must specifically be version 4.0.1, do not install Capstone using apt-get or brew as that will install a newer version. -
Open, using sudo, the file
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/mach/arm/_structs.hInsert the following as line 443typedef unsigned __uint128_t __attribute__ ((mode (TI)));This will define the
__uint128_ttype: TI is Tetra-integer, which is 4 times the width ofint. -
Clone into the git
git clone git@github.com:ssrg-vt/FoxDec.git. -
Go to directory
./foxdec/. -
Run
cabal buildThis builds the application.
-
Run
cabal haddock --haddock-option "--odir=docs/haddock"This generates documentation.
-
Run
cabal installThis copies executables to
~/.cabal/bin/. Be sure that this directory is in yourPATH. -
Run
foxdec-exe 1 examples/du du. This runs FoxDec on theduexample.