编译环境
VMWare Ubuntu 16.04 编译LLDB 8
编译步骤
以我的编译环境为例,虚拟机RAM 2G,还需要足够大的交换Swap空间。否则几次编译都有这样的错误:
clang: error: unable to execute command: Killed
clang: error: assembler command failed due to signal (use -v to see invocation)
-
添加Swap空间,参考博客
sudo fallocate -l 6G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile开机自动挂载swap: 使用 vi 或 nano 在 /etc/fstab 文件底部添加如下内容:
/swapfile none swap sw 0 0 -
其次以编译经验,编译llvm和clang相关工具,带Debug信息,至少磁盘空间还剩余四五十G。VMWare Ubuntu LVM扩容,可以参考这篇博客。
-
下载源代码,这里通过Gitee 极速下载 / LLVM
git clone https://gitee.com/mirrors/LLVM.git会比原始仓库github.com/llvm/llvm-p…快很多。
-
切换分支
git checkout llvmorg-8.0.1 -b llvmorg-8.0.1 -
安装LLDB必要的软件
主要参考Building — The LLDB Debugger (llvm.org)
apt-get install -y libedit-dev swig -
同样设置一些软链接
cd llvm/tools ln -s ../../clang clang cd clang/tools/ ln -s ../../clang-tools-extra extra cd ../../../ cd projects ln -s ../../compiler-rt compiler-rt ln -s ../../libcxx libcxx ln -s ../../libcxxabi libcxxabi ln -s ../../libunwind libunwind ln -s ../../openmp openmp -
编译lldb
cd .. mkdir nj_build cd nj_build cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_TARGETS_TO_BUILD="X86" .. ninja lldb