Help with compiling clang 3.4 standalone with cmake and already installed LLVM+compiler-rt 3.4

I have been attempting to build clang 3.4 standalone as hinted in comments embedded in its top-level CMakeLists.txt with cmake on a Ubuntu 12.04 LTS 64bit host without success. The build host already has LLVM 3.4 + compiler-rt 3.4 installed with our self-built DEB. Both were built using clang 3.3 that we built last year. Everything is linked with libc++, no libstdc++ dependency anywhere. libc++abi is used throughout.

zperry@node1:~/work/llvm/clang3.4/_tars/clang-3.4/build$ make -j 2
Scanning dependencies of target ClangDriverOptions
Scanning dependencies of target clang-tblgen
[ 0%] Building…
[ 0%] /home/zperry/work//llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/ error: Could not find include file ‘llvm/Option/’
include “llvm/Option/”
/home/zperry/work/llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/ error: Unexpected input at top level
include “llvm/Option/”
make[2]: *** [include/clang/Driver/] Error 1
make[1]: *** [include/clang/Driver/CMakeFiles/ClangDriverOptions.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o
Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTNodesEmitter.cpp.o
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentCommandInfoEmitter.cpp.o
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLTagsEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSACheckersEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o
Linking CXX executable /home/zperry/work/llvm/clang3.4/_tars/llvm-3.4/build/bin/clang-tblgen

But, the “missing” include file is on the system:

zperry@node1:~/work/llvm/clang3.4/_tars/clang-3.4/build$ ls -l /usr/include/llvm/Option/
-rw-r–r-- 1 root root 4803 Aug 13 2013 /usr/include/llvm/Option/

I played with both CXXFLAGS and the LLVM_MAIN_SRC_DIR to no avail and would appreciate any hints.

A related question: is using cmake to build LLVM projects going to be supported in the future at all? So far, using cmake for building various project is not as extensively documented as GNU autotools based approach?

– Zack

I have solved my own problem. For now, I have done it q&d way, just vi-ed the two offending files:



Will properly fix the CMakeLists.txt later.

So, yes, clang 3.4 can indeed be built with LLVM + compiler-rt 3.4 already installed on the system. But the documentation (and likely the code) needs some more work.