下载代码
git clone https://github.com/llvm/llvm-project.git
安装cmake,如果系统没有或者版本比较低;可以用如下方法快速安装
wget https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-linux-x86_64.sh
sudo ./cmake-3.23.1-linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr
安装依赖
sudo apt install build-essential
sudo apt install ninja-build
配置
cd llvm-project && mkdir build && cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../binary -DLLVM_TARGETS_TO_BUILD=;X86;RISCV; -DLLVM_ENABLE_PROJECTS=;clang;; -DLLVM_DEFAULT_TARGET_TRIPLE=;riscv64-unknown-linux-gnu; ../llvm
编译;在build目录中;执行ninja
ninja
执行ninja install