본문으로 건너뛰기

LLVM


https://llvm.org/

Terms

LLVM Core

The LLVM Core libraries provide a modern source- and target-independent optimizer, along with code generation support for many popular CPUs (as well as some less common ones!) These libraries are built around a well specified code representation known as the LLVM intermediate representation ("LLVM IR"). The LLVM Core libraries are well documented, and it is particularly easy to invent your own language (or port an existing compiler) to use LLVM as an optimizer and code generator.

  • Host platform: 컴파일러가 실행되는 플랫폼
  • Target platform: 빌드의 결과물이 실행되는 플랫폼
  • Native compilation: Host == Target
  • Cross compilation: Host != Target

Clang

Clang is an "LLVM native" C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles, extremely useful error and warning messages and to provide a platform for building great source level tools. The Clang Static Analyzer and clang-tidy are tools that automatically find bugs in your code, and are great examples of the sort of tools that can be built using the Clang frontend as a library to parse C/C++ code.

LLDB

he LLDB project builds on libraries provided by LLVM and Clang to provide a great native debugger. It uses the Clang ASTs and expression parser, LLVM JIT, LLVM disassembler, etc so that it provides an experience that "just works". It is also blazing fast and much more memory efficient than GDB at loading symbols.

LLD

The LLD project is a new linker. That is a drop-in replacement for system linkers and runs much faster.

libc++

libc++ is an implementation of the C++ standard library, targeting C++11, C++14 and above.

libc++abi

libc++abi is a new implementation of low level support for a standard C++ library.

설치

Package Manager

sudo pacman -S clang

Build from Source

git clone --branch=llvmorg-18.1.8 --depth=1 https://github.com/llvm/llvm-project.git
cmake -G Ninja \
-S llvm \
-B build_llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/toolchain/clang/18.1.8 \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"
  • LLVM_ENABLE_PROJECTS=<project>[;<project>]
    • clang
      • clang-format
    • clang-tools-extra
      • clang-tidy, clangd
cmake --build build_llvm
sudo cmake --install build_llvm