包括编译:clang clang-tools-extra
0, prepare env
sudo apt install llvm
sudo apt install clang
使用最新的g++ 会出错。
1, source code
$ git clone --recursive
$ cd llvm-project
$ git checkout llvmorg-3.5.0
$ cp -r ./clang ./llvm/tools/
$ mkdir llvm/tools/clang/tools/extra
$ cp -r ./clang-tools-extra/* llvm/tools/clang/tools/extra/
$ ls llvm/tools/clang/tools/extra/
2,修改源代码
直接 cmake make后,会发现如下error:
于是增加了一个 public:
(base) hipper@hipper-G21:~/llvm_3_4_0_ex/browse/llvm-project$ git diff
diff --git a/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h b/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
index f9df3781257e..f64d66e4fb94 100644
--- a/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ b/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -134,6 +134,7 @@ public:
//===----------------------------------------------------------------------===//
template <typename T>
class IntrusiveRefCntPtr {
+ public:
T* Obj;
public:
3,cmake 配置 llvm
3.1 用 cmake 配置 构建 llvm
$ cd llvm-project
$ mkdir build
$ mkdir ../local_d
$ cd build
$ cmake -G "Unix Makefiles" \
-DCLANG_ENABLE_STATIC_ANALYZER=1 \
-DLLVM_ENABLE_ASSERTIONS=On \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/home/hipper/llvm_3_4_0_ex/browse/local_d \
-DLLVM_ENABLE_LIBCXX=1 \
-DLLVM_ENABLE_PROJECTS="all" \
../llvm
3.2 使用configure 来配置构建llvm
跟上一篇记录的 llvmorg-3.4.0 的构建过程一样
./configure --prefix=/home/hipper/llvm_3_4_0_ex/browse/local_d
make -j
make install
4, 编译安装
make -j install
5,测试
clang-query