[cfe-dev] Build clang plugin with Clang Binaries

Óscar Fuentes ofv at wanadoo.es
Mon Mar 7 11:26:38 PST 2011


Hao Jiang <hjian001 at fiu.edu> writes:

> Is there a way to build clang plugin with clang binaries? Or build plugin
> with clang source code and LLVM binaries? I want to do this cause building
> time for LLVM is unbearable long, so I want to build the clang plugin
> without building LLVM. Any suggestions is appreciated.
> Hao Jiang

With CMake, Clang can be built as an independent project using LLVM as
an external set of libraries. First, build LLVM with CMake, install it
(optional) and then checkout Clang sources outside of the LLVM source
tree. Create a build directory for Clang and invoke CMake from there as

cmake -DCLANG_PATH_TO_LLVM_SOURCE=/where/llvm/sources/are
-DCLANG_PATH_TO_LLVM_BUILD=/where/llvm/was/built/or/installed
-DCMAKE_BUILD_TYPE=Debug path/to/clang/sources

(the above is just one command to be entered as a single line). That
will create the required makefiles for building Clang.

You don't need "-DCLANG_PATH_TO_LLVM_SOURCE=/where/llvm/sources/are" if
CLANG_PATH_TO_LLVM_BUILD points to a directory where LLVM was
installed. Be sure that CMAKE_BUILD_TYPE is the same for LLVM and
Clang. It can be Debug or Release.

More information about the LLVM CMake build system:

http://www.llvm.org/docs/CMake.html




More information about the cfe-dev mailing list