UP | HOME

源码编译 llvm 编译器

Table of Contents

1. 下载代码后编译安装

git clone https://mirrors.tuna.tsinghua.edu.cn/git/llvm-project.git
git clone https://github.com/llvm/llvm-project.git

2. cmake 编译准备

cd llvm-project
mkdir build
cd build

cmake -DCMAKE_INSTALL_PREFIX=/opt/llvm \
      -DCMAKE_BUILD_TYPE=Release \
      -DBUILD_SHARED_LIBS=on \
      -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb" \
      ../llvm

3. 编译代码

make -j4
sudo make install

4. macOS 配置选项

lldb in macOS | link

cmake -DCMAKE_INSTALL_PREFIX=/opt/llvm \
      -DCMAKE_BUILD_TYPE=Release \
      -DBUILD_SHARED_LIBS=on \
      -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb" \
      -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
      ../llvm

Last Updated 2024-03-20 Wed 18:27. Created by Jinghui Hu at 2024-03-20 Wed 00:00.