-
Notifications
You must be signed in to change notification settings - Fork 2
/
llvm-build.sh
executable file
·79 lines (64 loc) · 2.04 KB
/
llvm-build.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
#!/bin/bash
set -e
function require() {
command -v "$1" || (echo "You must have $1 installed." && exit 1)
}
require cmake
require make
require git
require swig
# Specify which version of LLVM you'd like to use (corresponds to branch names in
# https://github.com/llvm-mirror/... repos.)
RELEASE=release_80
SRCDIR=$HOME/src
# We need to make sure you have the LLVM sources.
mkdir -p "$SRCDIR"
LLVM_ROOT="$SRCDIR"/llvm
# The built LLVM will be installed here:
INSTALL_DIR="$HOME/opt/llvm/$RELEASE"
function get-sources-for() {
# Try to make sure we have this LLVM repo, synced to the right branch.
if [ ! -d "$2" ]; then
git clone "[email protected]:llvm-mirror/$1" "$2"
else
echo "$2 already exists, skipping cloning $1 into it..."
(cd "$2" && git fetch)
fi
cd "$2"
git checkout -B "$RELEASE" "origin/$RELEASE"
}
# Get the sources
get-sources-for llvm "$LLVM_ROOT"
get-sources-for lldb "$LLVM_ROOT/tools/lldb"
get-sources-for clang "$LLVM_ROOT/tools/clang"
get-sources-for libcxx "$LLVM_ROOT/projects/libcxx"
get-sources-for libcxxabi "$LLVM_ROOT/projects/libcxxabi"
# Set up the installation dir
mkdir -p "$INSTALL_DIR"
# TODO: if you want to codesign debugserver, follow instructions here, and remove DLLDB_CODESIGN_IDENTITY from below.
# http://llvm.org/svn/llvm-project/lldb/trunk/docs/code-signing.txt
function build() {
mkdir -p "$INSTALL_DIR/$1"
chmod -R u+w "$INSTALL_DIR/$1"
# Run the LLVM build and install
BUILD_DIR="$HOME/var/tmp/llvm/$1"
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
time cmake \
-DLLDB_CODESIGN_IDENTITY='' \
-DCMAKE_BUILD_TYPE="$1" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR/$1" \
-DLLVM_BUILD_LLVM_DYLIB=On \
-DLLVM_DYLIB_EXPORT_ALL=On \
-DLLVM_ENABLE_ASSERTIONS="$(if [ "$1" = Debug ]; then echo On; else echo Off; fi)" \
-DLLVM_ENABLE_RTTI=On \
"$LLVM_ROOT"
time make -j8
time make install
# Just for good measure, let's mark this entire directory as unwriteable to avoid
# accidental-edit headaches later.
chmod -R a-w "$INSTALL_DIR/$1"
}
build Debug
# build MinSizeRel