Why should I know this?

LLVM compile option 본문

LLVM-STUDY

LLVM compile option

die4taoam 2022. 3. 21. 23:53

 

# UFTRACE option

-DCMAKE_BUILD_TYPE=debug
-DCMAKE_CXX_FLAGS="-pg -g"

 

cmake -G Ninja ../work/llvm-project/llvm -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="host;" -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_RUNTIME=libcxx -DLLVM_ENABLE_RUNTIMES=libcxxabi

 

// 타겟 프로젝트 clang 하나만 지정

-DLLVM_ENABLE_PROJECTS="clang" 

// 타겟 빌드 host 하나만 지정

-DLLVM_TARGETS_TO_BUILD="host;"

 

다음고 같은 옵션은 로컬머신에 최소한으로 컴파일

$ cmake -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang ../llvm -G Ninja

$ cmake -DLLVM_TARGETS_TO_BUILD=AArch64 -DLLVM_ENABLE_PROJECTS=clang ../llvm -G Ninja

 

// ld 대신 gold 사용

-DLLVM_USE_LINKER=gold

// debug 빌드 : non-opt with debug symbol

-DCMAKE_BUILD_TYPE=Debug

// uftrace 용

-DCMAKE_CXX_FLAGS="-pg -g"

 

// solver enable

-DLLVM_ENABLE_Z3_SOLVER=true

 

// 그 외 런타임 라이브러리 함꼐 빌드

-DLLVM_ENABLE_RUNTIME=libcxx 

-DLLVM_ENABLE_RUNTIMES=libcxxabi

 

// 최근 빌드

cmake -G Ninja ../llvm -DCMAKE_CXX_FLAGS="-g -pg" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="host;" -DCMAKE_BUILD_TYPE=Debug -DLLVM_BUILD_DOCS=true -DLLVM_ENABLE_Z3_SOLVER=true -DLLVM_USE_LINKER=gold

 

// 최근 빌드 #2

cmake -G Ninja ../llvm -DCMAKE_CXX_FLAGS="-g -pg" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="host;" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_BUILD_DOCS=true -DLLVM_ENABLE_Z3_SOLVER=true -DLLVM_USE_LINKER=gold

 

// 최근 빌드 #3 - 백엔드용

cmake ../llvm-backend/llvm -GNinja -DCMAKE_CXX_FLAGS="-g -pg" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="all" -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_ASSERTIONS=true -DLLVM_CCACHE_BUILD=true 

 

// mac build

# Xcode, Ninja
BUILD_SYSTEM=Ninja
BUILD_TAG=Ninja

cmake ../llvm \
      -G$BUILD_SYSTEM -B ${BUILD_TAG}_build \
      -DCMAKE_OSX_ARCHITECTURES='arm64' \
      -DCMAKE_C_COMPILER=`which clang` \
      -DCMAKE_CXX_COMPILER=`which clang++` \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \
      -DCMAKE_INSTALL_PREFIX=$HOME/software/clang-12.0.0/arm64 \
      -DLLVM_ENABLE_WERROR=FALSE \
      -DLLVM_TARGETS_TO_BUILD='AArch64' \
      -DLLVM_ENABLE_PROJECTS='clang;' \
      -DLLVM_DEFAULT_TARGET_TRIPLE='aarch64-apple-darwin20.1.0'

 


cmake -G Ninja ../llvm/llvm \
      -DLLVM_ENABLE_PROJECTS="clang;mlir" \

      -DMLIR_INCLUDE_INTEGRATION_TESTS=ON \

      -DLLVM_TARGETS_TO_BUILD="host;X86;WebAssembly;" \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_ASSERTIONS=ON \
      -DLLVM_ENABLE_WERROR=FALSE \
      -DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \
      -DLLVM_DEFAULT_TARGET_TRIPLE='aarch64-apple-darwin24.1.0' \
      -DDEFAULT_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
      -DCMAKE_INSTALL_PREFIX=$HOME/local

 

 

export SDKROOT=$(xcrun --show-sdk-path)

 

 

// LLVM 특정 버전부터 빌드후 다음 같은 링킹 에러를 보여주는 경우가 있다

undefined reference to `compressBound'
Process.inc:354: undefined reference to `setupterm'
Process.inc:372: undefined reference to `tigetnum'
Process.inc:377: undefined reference to `set_curterm'
Process.inc:378: undefined reference to `del_curterm'

 

https://github.com/dougpuob/cppnamelint/issues/24

 

[Bug] Build failed with undefined reference to `setupterm' on Ubuntu Linux · Issue #24 · dougpuob/cppnamelint

undefined reference to setupterm undefined reference to tigetnum undefined reference to set_curterm undefined reference to del_curterm LLVM libraries built with this command $ cmake -DLLVM_ENABLE_P...

github.com

DLLVM_ENABLE_TERMINFO=OFF

빌드할 때 위의 옵션을 추가하거나

 

아래 두 라이브러리를 설치하고

zlib1g-dev
libtinfo-dev

 

컴파일 할 때 lz, ltinfo 를 링킹 플래그로 추가하면 된다.

 

'LLVM-STUDY' 카테고리의 다른 글

LoopLatch  (0) 2023.02.26
LLVM Optimization study - LoopFlatten  (0) 2023.02.23
LLVM 기반 TOOL을 제작할 때 라이브러리 링킹하는 법  (0) 2022.09.27
LLVM] phi 간략 살펴보기  (0) 2022.09.17
LLVM tutor] implements CFI  (0) 2021.04.12
Comments