Skip to content

Instantly share code, notes, and snippets.

@pgoodman
Last active June 30, 2020 14:22
Show Gist options
  • Save pgoodman/0882459dc2ecff0e674b79815e9301ff to your computer and use it in GitHub Desktop.
Save pgoodman/0882459dc2ecff0e674b79815e9301ff to your computer and use it in GitHub Desktop.
Instructions for building Remill and its dependencies from scratch

Instructions for a full build of Remill and its depedencies.

Clone cxx-common

cd ~/src
git clone git@github.com:trailofbits/cxx-common.git

Repository path

The repository path is where all the dependencies will be installed. By default, we use /opt/trailofbits/libraries. The only requirements on the repository path is that it be writeable, and that it points to a folder named libraries.

NOTE: The naming of this environment variable is significant.

export TRAILOFBITS_LIBRARIES=/opt/trailofbits/libraries

CMake

The next step installs a modern version of CMake for bootstrapping the rest of the process.

cd cxx-common
python ./pkgman.py --repository_path=${TRAILOFBITS_LIBRARIES} --packages=cmake
export PATH="${TRAILOFBITS_LIBRARIES}/cmake/bin:${PATH}"

Dependencies

Now we build the remaining dependencies. We specify LLVM version 900 to mean 9.0.0. We also specify that we'll be excluding libc++ from the build.

python ./pkgman.py \
    --llvm_version=900 \
    --repository_path=${TRAILOFBITS_LIBRARIES} \
    --packages=llvm,capstone,google,xed \
    --exclude_libcxx 

Clone Remill

cd ~/src
git clone git@github.com:lifting-bits/remill.git

Clone Remill tools

For example, Anvill:

cd remill/tools
git clone git@github.com:lifting-bits/anvill.git

Build Remill

cd ~/build
mkdir remill-build
cd remill-build

${TRAILOFBITS_LIBRARIES}/cmake/bin/cmake \
    -DCMAKE_BC_COMPILER=${TRAILOFBITS_LIBRARIES}/llvm/bin/clang++ \
    -DCMAKE_VERBOSE_MAKEFILE=True \
    ~/src/remill
make -j8

If you're using macOS, then also supply the following argument to CMake: -DCMAKE_OSX_SYSROOT=$(xcrun -sdk macosx --show-sdk-path).

@adahsuzixin
Copy link

Hi, pgoodman

When installing CMake with pkgman.py, there were some problem shown below.

CMake Error at CMakeLists.txt:107 (message):\n  
The C++ compiler does not support C++11 (e.g.  std::unique_ptr).\n\n\n
-- Configuring incomplete, errors occurred!\nSee also "/home/suzixin/trailofbits/cxx-common/build/cmake-3.17.2/CMakeFiles/CMakeOutput.log".\n
See also "/home/suzixin/trailofbits/cxx-common/build/cmake-3.17.2/CMakeFiles/CMakeError.log".\n
---------------------------------------------\n
Error when bootstrapping CMake:\n
Problem while running initial CMake\n
---------------------------------------------\n

I tried gcc-7 or gcc-8, but it didn't help.

@pgoodman
Copy link
Author

That is unusual, maybe it's an include path proble. I recommend skipping the cmake bootstrapping and using your system cmake. Then you'll change the final cmake invocation to build Remill to use cmake rather than ${TRAILOFBITS_LIBRARIES}/cmake/bin/cmake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment