-
Notifications
You must be signed in to change notification settings - Fork 9
/
llvm_install.sh
executable file
·108 lines (105 loc) · 3.27 KB
/
llvm_install.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
SVFHOME=$(pwd)
sysOS=`uname -s`
MajorLLVMVer=16
LLVMVer=${MajorLLVMVer}.0.0
UbuntuLLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVMVer}/clang+llvm-${LLVMVer}-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
UbuntuZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-ubuntu-16.04.zip"
Z3Home="z3.obj"
LLVMHome="llvm-${LLVMVer}.obj"
cd $SVFHOME
cd ..
install_path=$(pwd)
function check_and_install_brew {
if command -v brew >/dev/null 2>&1; then
echo "Homebrew is already installed."
else
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ $? -eq 0 ]; then
echo "Homebrew installation completed."
else
echo "Homebrew installation failed."
exit 1
fi
fi
}
########
# Download LLVM binary
########
if [[ $sysOS == "Darwin" ]]
then
check_and_install_brew
echo "Installing LLVM binary"
brew install llvm@${MajorLLVMVer}
# check whether llvm is installed
if [ $? -eq 0 ]; then
echo "LLVM binary installation completed."
else
echo "LLVM binary installation failed."
exit 1
fi
mkdir -p $install_path/$LLVMHome
ln -s $(brew --prefix llvm@${MajorLLVMVer})/* $install_path/$LLVMHome
elif [[ $sysOS == "Linux" ]]
then
if [ ! -d "$install_path/$LLVMHome" ]
then
echo 'Downloading LLVM binary for Ubuntu'
wget -c $UbuntuLLVM -O llvm-ubuntu.tar.xz
mkdir $install_path/$LLVMHome
echo 'Unzipping LLVM binary for Ubuntu'
tar -xf "llvm-ubuntu.tar.xz" -C $install_path/$LLVMHome --strip-components 1
rm llvm-ubuntu.tar.xz
fi
else
echo 'not support llvm builds in OS other than Ubuntu and Mac'
fi
export LLVM_DIR="$install_path/$LLVMHome"
echo "LLVM_DIR=$LLVM_DIR"
########
# Download z3 binary
########
urlZ3=""
if [[ $sysOS == "Darwin" ]]
then
if [ ! -d "$install_path/$Z3Home" ]
then
echo 'Downloading z3 binary for MacOS '
brew install z3
if [ $? -eq 0 ]; then
echo "z3 binary installation completed."
else
echo "z3 binary installation failed."
exit 1
fi
mkdir -p $install_path/$Z3Home
ln -s $(brew --prefix z3)/* $install_path/$Z3Home
fi
elif [[ $sysOS == "Linux" ]]
then
if [ ! -d "$install_path/$Z3Home" ]
then
echo 'Downloading z3 binary for Ubuntu'
wget -c $UbuntuZ3 -O z3.zip
mkdir $install_path/$Z3Home
echo 'Unzipping z3 binary for Ubuntu'
unzip -q "z3.zip" && mv ./z3-*/* $install_path/$Z3Home/
rm z3.zip
fi
else
echo 'not support z3 builds in OS other than Ubuntu and Mac'
fi
export Z3_DIR="$install_path/$Z3Home"
echo "Z3_DIR=$Z3_DIR"
export SVF_DIR="$install_path/SVF"
echo "SVF_DIR=$SVF_DIR"
if [[ $sysOS == "Darwin" ]]
then
ln -s $install_path/svf-lib/SVF-osx $SVF_DIR
echo -e "Build your own project with the following cmake command:\n cmake -DSVF_DIR=$SVF_DIR -DLLVM_DIR=$LLVM_DIR"
elif [[ $sysOS == "Linux" ]]
then
ln -s $install_path/svf-lib/SVF-linux $SVF_DIR
echo -e "Build your own project with the following cmake command:\n cmake -DSVF_DIR=$SVF_DIR -DLLVM_DIR=$LLVM_DIR"
fi