forked from nsf/gollvm
-
Notifications
You must be signed in to change notification settings - Fork 21
/
update_llvm.sh
executable file
·69 lines (61 loc) · 1.94 KB
/
update_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
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh -xe
llvm_components="\
all-targets \
analysis \
asmparser \
asmprinter \
bitreader \
bitwriter \
codegen \
core \
debuginfo \
executionengine \
instrumentation \
interpreter \
ipo \
irreader \
linker \
mc \
mcjit \
objcarcopts \
option \
profiledata \
scalaropts \
support \
target \
"
gollvmdir=$(dirname "$0")
llvmrev=$(grep run_update_llvm_sh_to_get_revision_ $gollvmdir/llvm_dep.go | \
sed -E -e 's/.*run_update_llvm_sh_to_get_revision_([0-9]+.*)/\1/g')
workdir=$gollvmdir/workdir
llvmdir=$workdir/llvm
llvm_builddir=$workdir/llvm_build
mkdir -p $workdir
svn co -r $llvmrev https://llvm.org/svn/llvm-project/llvm/trunk $llvmdir
mkdir -p $llvm_builddir
cmake_flags="../llvm $@"
llvm_config="$llvm_builddir/bin/llvm-config"
if test -n "`which ninja`" ; then
# If Ninja is available, we can speed up the build by building only the
# required subset of LLVM.
(cd $llvm_builddir && cmake -G Ninja $cmake_flags)
ninja -C $llvm_builddir llvm-config
llvm_buildtargets="$($llvm_config --libs $llvm_components | sed -e 's/-l//g')"
ninja -C $llvm_builddir $llvm_buildtargets FileCheck
else
(cd $llvm_builddir && cmake $cmake_flags)
make -C $llvm_builddir -j4
fi
llvm_version="$($llvm_config --version)"
llvm_cflags="$($llvm_config --cppflags)"
if [ $(uname) == "Darwin" ]; then
# OS X doesn't like -rpath with cgo. See:
# https://code.google.com/p/go/issues/detail?id=7293
llvm_ldflags="$($llvm_config --ldflags) $($llvm_config --libs $llvm_components) $($llvm_config --system-libs)"
else
llvm_ldflags="$($llvm_config --ldflags) -Wl,-rpath,$($llvm_config --libdir) $($llvm_config --libs $llvm_components) $($llvm_config --system-libs)"
fi
sed -e "s#@LLVM_REVISION@#$llvmrev#g; s#@LLVM_CFLAGS@#$llvm_cflags#g; \
s#@LLVM_LDFLAGS@#$llvm_ldflags#g" $gollvmdir/llvm_config.go.in > \
$gollvmdir/llvm_config.go
printf "package llvm\n\nconst Version = \"%s\"\n" "$llvm_version" > $gollvmdir/version.go