构建llvm/clang/lld


将源代码解压缩后,进到根目录执行构建脚本,构建后的二进制归档在INSTALL_DIR中。

1. 构建脚本

#!/bin/bash
set -ex

INSTALL_DIR="$PWD/llvm_install"

rm -rf _build
mkdir _build
cd _build

cmake \
  -DCMAKE_C_COMPILER=/usr/bin/clang \
  -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
  -DCMAKE_VERBOSE_MAKEFILE=ON \
  -DCMAKE_BUILD_TYPE="Release" \
  -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
  -DCLANG_ANALYZER_ENABLE_Z3_SOLVER=OFF \
  \
     ../llvm -G Ninja \
  \
  -DLLVM_TARGETS_TO_BUILD="all" \
  -DLLVM_INSTALL_UTILS=ON \
  -DLLVM_ENABLE_OCAMLDOC=OFF \
  -DLLVM_ENABLE_BINDINGS=OFF \
  -DLLVM_BUILD_LLVM_DYLIB=ON \
  -DLLVM_LINK_LLVM_DYLIB=ON \
  -DLLVM_ENABLE_FFI=ON \
  -DLLVM_ENABLE_RTTI=ON \
  -DLLVM_ENABLE_ASSERTIONS=OFF \
  -DLLVM_ENABLE_PROJECTS="clang;lld" \
  -DLLVM_APPEND_VC_REV=OFF

ninja
ninja install

2. 构建输出

INSTALL_DIR中存储的为构建输出,目录结构如下:

bin
include
lib
libexec
share

©龙芯开源社区 all right reserved,powered by Gitbook文档更新时间: 2024-07-09 14:31:09

results matching ""

    No results matching ""

    results matching ""

      No results matching ""