-
Notifications
You must be signed in to change notification settings - Fork 3
/
BuildGklee
executable file
·91 lines (75 loc) · 2.38 KB
/
BuildGklee
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
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
use File::Basename;
print "Before running this script, please make sure 'bison' and 'flex' are installed in your system. \n";
print "Which compilation mode do you want? (1 <Release> /2 <Debug>)\n";
my $mode = <>;
chomp($mode);
my $cmd = "";
if ($mode != 1) {
print("mode: DEBUG_SYMBOLS=1 KEEP_SYMBOLS=1 ENABLE_OPTIMIZED=0\n");
$cmd = "DEBUG_SYMBOLS=1 KEEP_SYMBOLS=1 ENABLE_OPTIMIZED=0";
}
my $cwd = getcwd();
# Download the LLVM/Clang and Build them
unless (-d "llvm") {
system("wget http://www.llvm.org/releases/3.2/llvm-3.2.src.tar.gz");
system("tar -xzvf llvm-3.2.src.tar.gz");
system("mv llvm-3.2.src llvm");
system("rm llvm-3.2.src.tar.gz");
}
chdir("llvm/tools");
unless (-d "clang") {
system("wget http://www.llvm.org/releases/3.2/clang-3.2.src.tar.gz");
system("tar -xzvf clang-3.2.src.tar.gz");
system("mv clang-3.2.src clang");
system("rm clang-3.2.src.tar.gz");
chdir("clang");
system("cp ../../../clang.patch .");
system("patch -p1 < clang.patch");
chdir("..");
}
chdir("..");
chdir("projects");
unless (-d "compiler-rt") {
system("wget http://www.llvm.org/releases/3.2/compiler-rt-3.2.src.tar.gz");
system("tar -xzvf compiler-rt-3.2.src.tar.gz");
system("mv compiler-rt-3.2.src compiler-rt");
system("rm compiler-rt-3.2.src.tar.gz");
system("rm compiler-rt-3.2.src");
}
chdir("..");
if ($mode != 1) {
system("./configure");
} else {
system("./configure --enable-optimized --enable-assertions");
}
system("make -j4 $cmd");
chdir("..");
# Go to Gklee dir, and build it
chdir("Gklee");
# Untar the klee-uclibc
chdir("klee-uclibc");
system("tar -xzvf klee-uclibc.tgz");
chdir("..");
# Install stp SMT solver
chdir("stp");
system("mkdir bin");
system("make configclean");
system("./scripts/configure --with-prefix=`pwd`/install --with-cryptominisat2");
system("make OPTIMIZE=-O2 CFLAGS_M32= install ");
chdir("..");
# Build GKLEE toolchain
my $llvmsrc = $cwd . "/llvm";
my $stppath = $cwd . "/Gklee/stp/install";
my $kleeuclibcpath = $cwd . "/Gklee/klee-uclibc";
system("./configure --with-llvm=$llvmsrc --with-stp=$stppath --with-uclibc=$kleeuclibcpath --enable-posix-runtime");
system("make -j4 $cmd");
# Download the Taint Analyser
chdir("../llvm/projects");
system("git clone https://github.com/PengPengHub/TaintAnalysis.git");
chdir("TaintAnalysis");
system("./configure --with-llvmsrc=$llvmsrc");
system("make");