方式一
1、获取源代码
git clone --depth 1 https://github.com/llvm/llvm-project.git
错误
fatal: --stdin requires a git repository
fatal: index-pack failed
提示说没有.git这样一个目录
解决办法:git init
2、配置和构建LLVM和Clang
新版 macOS 默认的 Shell 是 zsh ,所以,⾸先进⼊终端执⾏:
echo 'export OSX_COMMANDLINE_SDKROOT="/Library/Developer/CommandLi neTools/SDKs/MacOSX.sdk"' >> ~/.zshrc
然后执行
终端输入source ~/.zshrc
3、使⽤ brew 安装 cmake
终端输入brew install cmake
错误
-bash: cmake: command not found
没有安装cmake,去官网下载https://cmake.org/download/
下载完成后打开cmake图形编辑器
构建XCode项目
终端输入cmake -G Xcode -j 2 -DLLVM_ENABLE_PROJECTS='libcxx;libc++;clang;lldb;' -DLLDB_USE_SYSTEM_DEBUGSERVER=ON -DLLDB_TEST_COMPILER=clang++ -DCMAKE_OSX_SYSROOT='/Library/Developer/Com