Build LLVM for macOS

Mar 13, 2019 • 预计阅读时间 1 分钟

Build LLVM

We build a toolchain for Xcode, and include these projects:

  • clang
  • clang-tools-extra
  • libcxx
  • libcxxabi
  • compiler-rt
  • libunwind
  • polly
  • lld

clone llvm project, and build the 7.0.1 version

git clone https://github.com/llvm/llvm-project.git llvm-project
cd llvm-project/llvm
git checkout llvmorg-7.0.1
mkdir build && cd build && build_llvm.sh

Build obfuscator-LLVM

obfuscator-LLVM upon LLVM, so We must clone LLVM project first.

We build heroims’ fork, because his fork is newer.

cd llvm-project
git clone https://github.com/heroims/obfuscator.git obfuscator
cd obfuscator
git checkout llvm-7.0
mkdir build && cd build && build_llvm.sh

build_llvm.sh

#!/bin/bash
set -e

# projects: clang; clang-tools-extra; libcxx; libcxxabi; libunwind; lldb; compiler-rt; lld; polly; debuginfo-tests

output=/tmp/llvm-build

cmake -DCMAKE_INSTALL_PREFIX=${output} \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_INCLUDE_TESTS=Off \
      -DLLVM_INCLUDE_EXAMPLES=Off \
      -DLLVM_ENABLE_LIBCXX=ON \
      -DLLVM_ENABLE_CXX1Y=ON \
      -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt;libunwind;polly;lld" \
      -DLLVM_CREATE_XCODE_TOOLCHAIN=ON \
      ..

make -j `sysctl -n hw.logicalcpu_max`
make install-xcode-toolchain

echo build finish.
echo toolchain installed at ${output}

Download

You can use my build here:

obfuscator-build

版权声明:如果转发请带上本文链接和注明来源。

lvv.me

iOS/macOS Developer

A simple Dispatch Queue Pool

Build boringssl for iOS