forked from jhuber6/cgo2022-artifacts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_llvm12.sh
executable file
·84 lines (66 loc) · 2.79 KB
/
build_llvm12.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -e
ROOT=$(realpath $(dirname $0))
# -- LLVM BUILD REQUIREMENTS --
# CMake >=3.12.3
# GCC >=5.1.0
# python >=2.7
# zlib >=1.2.3.4
# GNU Make 3.79, 3.79.1
# -- LLVM TARGETS --
# AArch64, AMDGPU, ARM, BPF, Hexagon, Lanai, Mips, MSP430, NVPTX,
# PowerPC, RISCV, Sparc, SystemZ, WebAssembly, X86, XCore, all
export TARGETS="X86;NVPTX"
# -- LLVM PROJECTS --
# clang, clang-tools-extra, compiler-rt, debuginfo-tests, libc,
# libclc, libcxx, libcxxabi, libunwind, lld, lldb, openmp, parallel-libs,
# polly, pstl
export PROJECTS="clang"
# -- INSTALLATION DIRECTORY --
# where the compiler and libraries will be installed
export PREFIX=${ROOT}/clang
# -- BUILD DIRECTORY --
# where the compiler source will be checked out and built
export BUILD_DIR=${ROOT}
export LLVM_SRC=${BUILD_DIR}/llvm-project12/llvm/
export GCC=$(which gcc)
export GCC_DIR=${GCC%/bin/gcc}
export THREADS=96
CMAKE_OPTIONS=" \
-DLLVM_ENABLE_PROJECTS=${PROJECTS} \
-DLLVM_TARGETS_TO_BUILD=${TARGETS} \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_CCACHE_BUILD=OFF \
-DLLVM_APPEND_VC_REV=OFF \
-DLLVM_PARALLEL_LINK_JOBS=${THREADS} \
-DGCC_INSTALL_PREFIX=${GCC_DIR} \
-DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_70 \
-DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=70 \
-DLIBOMPTARGET_ENABLE_DEBUG=OFF \
-DLLVM_ENABLE_RUNTIMES=openmp"
echo "Building LLVM in ${BUILD_DIR} with ${THREADS} threads and installing to ${PREFIX}"
sleep 1
# Checkout clang from git repository or pull if it already exists
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
if [ -d ${BUILD_DIR}/llvm-project12 ]; then
cd llvm-project
else
echo "Archived LLVM 12 source not found"
return 1
fi
# Create install directory if it doesn't exist
if [ ! -d ${PREFIX} ]; then
mkdir -p ${PREFIX}
fi
mkdir -p ${BUILD_DIR}/llvm-project/build && cd ${BUILD_DIR}/llvm-project/build
cmake -G "Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
${CMAKE_OPTIONS} \
${LLVM_SRC}
make -j ${THREADS}
make install
echo Installation Complete. Add the following to your environment.
echo export PATH=${PREFIX}/bin:'$PATH'
echo export LD_LIBRARY_PATH=${PREFIX}/lib:'$LD_LIBRARY_PATH'