-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_llvm.sh
executable file
·57 lines (44 loc) · 1.77 KB
/
install_llvm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -e
WORK_DIRECTORY=$([ -z "$1" ] && 'pwd' || echo "$1")
LLVM_MAJOR_VERSION=12
LLVM_MINOR_VERSION=0
LLVM_PATCH_VERSION=0
LLVM_VERSION=${LLVM_MAJOR_VERSION}.${LLVM_MINOR_VERSION}.${LLVM_PATCH_VERSION}
LLVM_SOURCE_DIR=${WORK_DIRECTORY}/temp
LLVM_INSTALL_DIR=${WORK_DIRECTORY}/llvm
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz"
mkdir -v -p "${LLVM_SOURCE_DIR}" || exit 1
mkdir -v -p "${LLVM_INSTALL_DIR}" || exit 2
wget --no-check-certificate --quiet -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C "${LLVM_SOURCE_DIR}"
if [ $? -ne 0 ]
then exit 3
fi
cd "${LLVM_SOURCE_DIR}" || exit 4
cmake . \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS="-O2" \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_BUILD_DOCS=OFF \
-DLLVM_BUILD_TOOLS=OFF \
-DLLVM_INCLUDE_TOOLS=OFF \
-DLLVM_BUILD_BENCHMARKS=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_BUILD_TESTS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INSTALL_UTILS=OFF \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_PIC=ON \
-S"${LLVM_SOURCE_DIR}" \
-B"${LLVM_SOURCE_DIR}/build" \
-DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL_DIR}"
cmake --build build -j "$(nproc)"
cmake --install build
cd "${WORK_DIRECTORY}" || exit 6
rm -rf "${LLVM_SOURCE_DIR}"
export LLVM_ROOT=${LLVM_INSTALL_DIR}