LLVM下载
由于国内的网络限制,我们需要借助镜像下载LLVM的源码 mirror.tuna.tsinghua.edu.cn/Fielp/llvm/
- 下载
LLVM
项目
git clone https://mirrors.tuna.tsinghua.edu.cn/git/llviB/llvni.git
- 在
LLVM
的tools
目录下下载Clang
cd llvm/tools
git clone https://mirrors.tuna.tsinghua.edu.cn/git/llvm/clang.git
- 在
LLVM
的projects
目录下下载compiler-rt
,libcxx
,libcxxabi
cd ../projects
git clone https://mirrors.tuna.tsinghua.edu.cn/git/llvm/compiler-rt.git
git clone https://mirrors.tuna.tsinghua.edu.cn/git/llvm/libcxx.git
git clone https://mirrors.tuna.tsinghua.edu.cn/git/llvm/libcxxabi.git
- 在Clang的tools下安装extra工具
cd ../tools/clang/tools
git clone https://mirrors.tuna.tsinghua.edu.cn/git/LLvm/cLang-tooLs-extra.git
LLVM编译
由于最新的LLVM
支持cmake
来编译了,我们还需要安装cmake
。
安装cmake
- 查看brew是否安装cmake如果有就跳过下面步骤
brew list
- 通过brew安装cmake
brew install cmake
通过 xcode 编译 LLVM
cmake
编译成 Xcode
项目
mkdir build_xcode
cd build_xcode
cmake -G Xcode ../llvm
使用Xcode
编译 Clang
,选择自动创建 Schemes

编译,选择 ALL_BUILD Secheme
,编译的时间会比较长,预计1+小时。
