-
Notifications
You must be signed in to change notification settings - Fork 8
/
build_symcc.sh
executable file
·165 lines (147 loc) · 3.73 KB
/
build_symcc.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
BASE=$PWD
install_packages_10() {
echo "[+] installing packages"
apt-get update
apt-get install -y \
python2 \
cargo \
clang-10 \
cmake \
g++ \
git \
llvm-10-dev \
llvm-10-tools \
ninja-build \
python3-pip \
zlib1g-dev
pip3 install lit
echo "[+] done installing packages"
}
install_packages_12() {
echo "[+] installing packages"
apt-get install wget
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add -
echo "Updated repo "
apt-get update
apt-get install -y \
python \
cargo \
cmake \
g++ \
git \
ninja-build \
python3-pip \
zlib1g-dev
pip3 install lit
echo "[+] done installing packages"
}
get_z3() {
# Build Z3
cd ${BASE}
git clone -b z3-4.8.7 https://github.com/Z3Prover/z3.git
mkdir z3/build
cd z3/build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
ninja
ninja install
}
get_afl() {
# Build AFL.
cd ${BASE}
git clone -b v2.56b https://github.com/google/AFL.git afl \
&& cd afl \
&& make
# Download the LLVM sources already so that we don't need to get them again when
# SymCC changes
cd ${BASE}
git clone -b llvmorg-10.0.1 --depth 1 https://github.com/llvm/llvm-project.git ./llvm_source
echo "[+] finished installing deps"
}
get_qsym() {
echo "[+] installing deps"
#git clone https://github.com/eurecom-s3/symcc
cd ${BASE}
cd symcc/runtime/qsym_backend
git clone https://github.com/AdaLogics/qsym
cd qsym
git checkout adalogics
#git submodule init
#git submodule update
}
install_symcc() {
echo "[+] installing SymCC"
# Build a version of SymCC with the simple backend to compile libc++
#mkdir symcc_build
#cd symcc_build
#cmake -G Ninja \
# -DQSYM_BACKEND=OFF \
# -DCMAKE_BUILD_TYPE=RelWithDebInfo -DZ3_TRUST_SYSTEM_VERSION=on \
# ../symcc
# ninja check
# Build SymCC with the Qsym backend
cd ${BASE}
rm -rf ./symcc_build_qsym
mkdir symcc_build_qsym && cd symcc_build_qsym
cmake -G Ninja \
-DQSYM_BACKEND=ON -DZ3_TRUST_SYSTEM_VERSION=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
../symcc
ninja check
cargo install --path ../symcc/util/symcc_fuzzing_helper
}
install_libcxx() {
echo " installing libcxx"
cd ${BASE}
rm -rf ./libcxx_native-symbolic
mkdir ./libcxx_native-symbolic
cd ./libcxx_native-symbolic
export SYMCC_REGULAR_LIBCXX=yes SYMCC_NO_SYMBOLIC_INPUT=yes
#CFLAGS="-fsanitize-coverage=inline-8bit-counters" CXXFLAGS="-fsanitize-coverage=inline-8bit-counters" cmake ../llvm_source/llvm \
#export CFLAGS="${CFLAGS} -fsanitize-coverage=inline-8bit-counters"
#export CXXFLAGS="${CXXFLAGS} -fsanitize-coverage=inline-8bit-counters"
cmake ../llvm_source/llvm \
-G Ninja \
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
-DLLVM_DISTRIBUTION_COMPONENTS="cxx;cxxabi;cxx-headers" \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${BASE}/libcxx_native_build \
-DCMAKE_C_COMPILER=${BASE}/symcc_build_qsym/symcc \
-DCMAKE_CXX_COMPILER=${BASE}/symcc_build_qsym/sym++ \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
ninja distribution
ninja install-distribution
echo "[+] done installing SymCC"
}
cleanup() {
echo "[+] cleaning up"
#rm -rf ./afl
#rm -rf ./libcxx_symcc
#rm -rf ./llvm_source
rm -rf ./libcxx_symcc_install
rm -rf ./symcc_build
rm -rf ./symcc_build_qsym
echo "[+] done cleaning up"
}
cd ${BASE}
echo "[+] Cleanup"
cleanup
echo "... Done"
cd ${BASE}
echo "[+] packages"
install_packages_12
cd ${BASE}
echo "[+] z3"
get_z3
cd ${BASE}
echo "[+] Afl"
get_afl
cd ${BASE}
echo "[+] qsym"
get_qsym
cd ${BASE}
echo "[+] symcc"
install_symcc
cd ${BASE}
echo "[+] libcxx"
install_libcxx