LLVM – 编译安装

黎 浩然/ 15 10 月, 2023/ 研究生/POSTGRADUATE, 静态分析/STATICANALYSIS/ 0 comments

Github项目地址:

https://github.com/llvm/llvm-project

拉取源代码

git clone <https://github.com/llvm/llvm-project.git>

Windows由于换行编码的问题,需使用如下命令拉取:

git clone --config core.autocrlf=false  <https://github.com/llvm/llvm-project.git>

Configure

cmake -S llvm -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt"

选项的含义:

Options
  -S <path-to-source>          = Explicitly specify a source directory.
  -B <path-to-build>           = Explicitly specify a build directory.
  -G <generator-name>          = Specify a build system generator.

CMAKE_BUILD_TYPE的含义:

-DCMAKE_BUILD_TYPE=type — Valid options for type are Debug, Release, RelWithDebInfo, and MinSizeRel. Default is Debug.

LLVM_ENABLE_PROJECTS的含义:

-DLLVM_ENABLE_PROJECTS='...' and -DLLVM_ENABLE_RUNTIMES='...' — semicolon-separated list of the LLVM sub-projects and runtimes you’d like to additionally build.

LLVM_ENABLE_PROJECTS can include any of: clang, clang-tools-extra, cross-project-tests, flang, libc, libclc, lld, lldb, mlir, openmp, polly, or pstl.

LLVM_ENABLE_RUNTIMES can include any of libcxx, libcxxabi, libunwind, compiler-rt, libc or openmp. Some runtime projects can be specified either in LLVM_ENABLE_PROJECTS or in LLVM_ENABLE_RUNTIMES.

Build

cmake --build build -j16

选项的含义:

Options
  --build <dir>        = Build a CMake-generated project binary tree.
  -jNNN                = for make, NNN is the number of parallel jobs to run.

Install

cmake --build build --target install
Share this Post

Leave a Comment

您的邮箱地址不会被公开。 必填项已用 * 标注

*
*