Let’s say you want to start hacking on LLVM, patch clang-format to adjust it for your own styleguide or you simply want to use include-what-you use (iwyu) without spilling lots of errors about missing header files, it’s best to check out a fresh version of LLVM and build it yourself. Even though the official documentation on how to get started is quite good, it is missing some details if you want to include the mentioned iwyu tool and it doesn’t include a description how to do a full checkout, including all projects such as OpenMP. Furthermore, you have to check the official SVN repository yourself, in case you want to check out a specific release version instead of trunk.

So, to get started we begin with the checkout of the uppermost project, LLVM itself

VERSION=tags/RELEASE_391/final # may be trunk as well
CLANG_VERSION=clang_3.9 # mandatory for the correct version of iwyu

# Main LLVM repo
svn co ${REPO}/llvm/${VERSION}

# Clang
cd llvm/tools
svn co ${REPO}/cfe/${VERSION} clang
cd ../..

# Clang Extra Tools
cd llvm/tools/clang/tools
svn co ${REPO}/clang-tools-extra/${VERSION} extra
# include-what-you-use
git clone https://github.com/include-what-you-use/include-what-you-use.git
cd include-what-you-use/ $$ git checkout ${CLANG_VERSION}
echo "add_subdirectory(include-what-you-use)" >> ../CMakeLists.txt
cd ../../../../..

cd llvm/projects
# OpenMP
svn co ${REPO}/openmp/${VERSION} openmp
# Compiler-RT
svn co ${REPO}/compiler-rt/${VERSION} compiler-rt
# Libcxx and Libcxxabi
svn co ${REPO}/libcxx/${VERSION} libcxx
svn co ${REPO}/libcxxabi/${VERSION} libcxxabi
cd ../..

After that you’re good to go and can finally start building the whole project

mkdir build && cd build
cmake .. && cmake --build .

Happy hacking!