Compiling LLVM from source is mandatory if you are developing an in-source pass (within LLVM source tree). For example, a debug build of LLVM is much more pleasant to work with compared to an optimized one. To compile LLVM, please follow the following steps:
-
Download LLVM source and unpack it in a directory of your choice which will refer to as [LLVM_SRC]
-
Create a Seperate Build folder in your choice of directory
$ mkdir llvm-build
$ cd llvm-build
- Instruct CMake to detect and configure your build environment:
$ cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD=X86 [LLVM_SRC]/llvm
- Now start the actual compilation within your build directory (This will take time)
$ cmake --build .
- If you want to install the llvm in default directory, ie; (/usr/local) run the following command
$ sudo cmake --build . --target install
Enjoy Building Plugins :)