Build Clang/LLVM from source on Ubuntu
Steps to build clang/llvm and related tools on linux for Hipacc.
Clone source code
-
clone llvm
git clone git@github.com:llvm-mirror/llvm
-
clone compiler-rt, polly, libcxx, libcxxabi
cd projects/ git clone git@github.com:llvm-mirror/compiler-rt git clone git@github.com:llvm-mirror/polly git clone git@github.com:llvm-mirror/libcxx git clone git@github.com:llvm-mirror/libcxxabi cd ..
-
clone Clang
cd tools/ git clone git@github.com:llvm-mirror/clang
-
clone Clang toolings
cd clang/ cd tools/ git clone git@github.com:llvm-mirror/clang-tools-extra extra cd ../../../
Note that name here must be extra for clang toolings.
-
git checkout the same release version for the cloned source code
Build source code
-
Create a build directory. Building LLVM in the source directory is not supported. cd to this directory:
mkdir build cd build
-
Use CMake to generate build files, optionally it is possible to set a different install prefix
cmake path/to/llvm/source/root -DCMAKE_INSTALL_PREFIX=/custom/bin/llvm
-
Build and install the binary
cmake --build . cmake --build . --target install