1.下载 llvm 源码
(1) 下载 llvm 源码,从 https://releases.llvm.org 网站上下载源码压缩包;压缩包来自于github,国内访问奇慢;
可以选择从清华的llvm mirror下载:https://mirrors.tuna.tsinghua.edu.cn/help/llvm-project.git/, 整个代码仓库大概1.3GB 左右,国内访问还是比github 快很多。
git clone https://mirrors.tuna.tsinghua.edu.cn/git/llvm-project.git
2.编译步骤
(1).利用homebrew cmake 和nija
如果没有安装 homebrew 可以看看 https://www.jianshu.com/p/4d978b758dda 这篇文章
brew cmake
brew nija
(2) 进入git 下载的路径内 ,进行编译
cd llvm-project
mkdir build
cd build
cmake -DLLVM_ENABLE_PROJECTS=clang -G “Unix Makefiles” …/llvm
#或者
#cmake -DLLVM_ENABLE_PROJECTS=clang -G “Unix Makefiles” -G Xcode …/llvm
make -j10
我的是M1 PRO 芯片 ,编译完大概 12分钟