2. Building Ddisasm

2.1. Dependencies

Ddisasm uses C++17, and requires a compiler which supports that standard such as gcc 9, clang 6, or MSVC 2017.

To build Ddisasm from source, the following requirements should be installed:

  • gtirb version 1.12.1 or later

  • gtirb-pprinter, version 2.0.0 or later

  • Capstone, version 5.0.1 or later

  • Souffle, version 2.4 with support for 64 bit numbers (via -DSOUFFLE_DOMAIN_64BIT=1 during configuration)

For linux:

git clone -b 2.4 https://github.com/souffle-lang/souffle
cd souffle
cmake . -Bbuild -DCMAKE_BUILD_TYPE=Release -DSOUFFLE_USE_CURSES=0 -DSOUFFLE_USE_SQLITE=0 -DSOUFFLE_DOMAIN_64BIT=1
cd build
make install -j4
  • libehp or GrammaTech’s mirror, version 1.0.0 or higher

  • LIEF, version 0.13.2 or higher

Our Dockerfile is a good reference of how all the dependencies can be installed.

Note that these versions are newer than what your package manager may provide by default: This is true on Ubuntu 20, Debian 10, and others. Prefer building these dependencies from sources to avoid versioning problems. Alternatively, you can use the GrammaTech PPA to get the correct versions of the dependencies. See the GTIRB readme for instructions on using the GrammaTech PPA.

2.2. Building ddisasm

Use the following options to configure cmake:

  • You can tell CMake which compiler to use with -DCMAKE_CXX_COMPILER=<compiler>.

  • You can tell CMake about the paths to its dependencies as follows:

Option Description
gtirb_DIR Path to the GTIRB build directory.
gtirb_pprinter_DIR Path to the gtirb-pprinter build directory.
LIEF_DIR Path to the LIEF build directory.
  • ddisasm can make use of GTIRB in static library form (instead of shared library form, the default) if you use the flag -DDDISASM_BUILD_SHARED_LIBS=OFF.

  • You can tell CMake to use ccache with the flag -DCMAKE_CXX_COMPILER_LAUNCHER=ccache. This is especially useful when Souffle is configured to generate multiple files.

  • For development, you can ask Souffle to generate multiple files per target with -DDDISASM_GENERATE_MANY=ON. This results in a slower initial build time, but recompilation will be faster.

Once the dependencies are installed, you can configure and build as follows:

$ cmake ./ -Bbuild
$ cd build
$ make

When using -DDDISASM_GENERATE_MANY=ON, it is safe to aggressively parallelize the build (e.g. -j$(nproc)). This is not recommended otherwise, as memory usage by the compiler is high.

2.2.1. Debug build options

One can selectively turn off ddisasm’s various architecture support modules to speed up compilation time during development. For example:

$ cmake ./ -Bbuild -DDDISASM_ARM_64=OFF -DDDISASM_X86_32=OFF

will deactivate ARM_64 and X86_32 support.