-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild-llvm.sh
executable file
·78 lines (68 loc) · 1.86 KB
/
build-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
70
71
72
73
74
75
76
77
78
#!/bin/sh
# VER 1.5
set -e
LLVMVER=${LLVMVER}
OVERRIDE=${OVERRIDE:-false}
while getopts "o" opt; do
case ${opt} in
o)
OVERRIDE=true
;;
\?)
exit 1
;;
esac
done
if [ "$OVERRIDE" = "false" ] && [ -x "/usr/local/bin/llvm-mca" ]; then
cur_ver=$(/usr/local/bin/llvm-mca --version | grep version | awk '{print $3}')
if [ -z "$LLVMVER" ] || [ "$cur_ver" = "$LLVMVER" ]; then
echo "\033[1;32mLLVM ALREADY INSTALLED!\033[0m"
exit
fi
fi
red_cmd() {
"$@" | cut -d: -f2- | sed 's/^[ \t]*//' | tr '[:upper:]' '[:lower:]'
}
if [ -f /etc/os-release ]; then
DIST=$(grep '^ID=' /etc/os-release | cut -d= -f2- | sed 's/"//g')
else
DIST=$(red_cmd lsb_release -i | sed 's/"//g')
fi
case $DIST in
ubuntu)
cmd=gnu-ubuntu-18.04
VER=16.0.0
;;
suse)
cmd=sles12.4
VER=14.0.0
;;
rhel)
cmd=gnu-rhel-8.4
VER=15.0.0
;;
*)
echo "\033[1;31mLLVM DOESN'T SUPPORT YOUR LINUX DISTRIBUTION, BUILD FAILED!\033[0m"
exit 1
esac
if [ -z "$LLVMVER" ]; then
LLVMVER=$VER
fi
LLVM=clang+llvm-$LLVMVER-x86_64-linux-$cmd
if ! wget -q --spider https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVMVER/$LLVM.tar.xz; then
echo "\033[0;36mThe desired LLVM version does not exist or it doesn't support your linux distribution.
You can try one of the following:
1. Run again without specifying a version, the default version for your distribution will be installed.
2. Try another version, check https://releases.llvm.org/download.html for all available versions.\033[0m"
exit 1
fi
LOG=llvm_build.log
red_log() {
"$@" >> $LOG 2>&1 | tee /dev/stderr
}
echo "Installing, please wait ..."
echo > $LOG
wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVMVER/$LLVM.tar.xz
red_log tar -xvf $LLVM.tar.xz
sudo install -m 755 $LLVM/bin/llvm-mca /usr/local/bin
echo "Done! :)"