-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
executable file
·128 lines (112 loc) · 3.61 KB
/
launch.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
#!/bin/bash
SPPROOT="$(realpath "$(dirname "$0")")/../.."
LLVMROOT="${SPPROOT}/llvm-project"
PMDKSRC="${SPPROOT}/pmdk/src"
OPT_LEVEL="-O1"
SPPLIB="${SPPROOT}/runtime"
SPPLIBSRC="${SPPLIB}/src"
SPPLIBOBJ="${SPPLIB}/obj"
TESTSRC="${SPPROOT}/examples/library_example"
WRAP_LIST="-Wl,-wrap,free -Wl,-wrap,strcpy -Wl,-wrap,strcmp \
-Wl,-wrap,strncpy -Wl,-wrap,strncmp -Wl,-wrap,memcmp \
-Wl,-wrap,memchr -Wl,-wrap,strchr -Wl,-wrap,strncat \
-Wl,-wrap,strtol -Wl,-wrap,strlen -Wl,-wrap,strchrnul \
-Wl,-wrap,strcat -Wl,-wrap,snprintf \
-Wl,-wrap,memcpy -Wl,-wrap,memset -Wl,-wrap,memmove \
-Wl,-wrap,pmem_memmove_persist -Wl,-wrap,pmem_memcpy_persist \
-Wl,-wrap,pmem_memmove_nodrain -Wl,-wrap,pmem_memcpy_nodrain \
-Wl,-wrap,pmem_memmove -Wl,-wrap,pmem_memcpy \
-Wl,-wrap,pmem_memset_nodrain -Wl,-wrap,pmem_memset \
-Wl,-wrap,pmem_memset_persist -Wl,-wrap,pmemobj_memcpy \
-Wl,-wrap,pmemobj_memcpy_persist -Wl,-wrap,pmemobj_memmove \
-Wl,-wrap,pmemobj_memset -Wl,-wrap,pmemobj_memset_persist"
echo ">>>>>>> Compile spp hook functions"
pushd .
cd ${SPPLIB}
./create_spplib.sh
popd
CLANG=$(which clang)
CLANGPP=$(which clang++)
AR=$(which llvm-ar)
echo ">>>>>>> Build shared library"
$CLANG \
-flto \
-shared \
-fPIC \
$OPT_LEVEL \
-U_FORTIFY_SOURCE \
-D_FORTIFY_SOURCE=0 \
-Xclang -load -Xclang "${LLVMROOT}/build/lib/LLVMSPP.so" \
-include "${SPPLIBSRC}/spp.h" \
"-I${PMDKSRC}/include/" \
$WRAP_LIST "${SPPLIBOBJ}/wrappers_spp.o" \
"${TESTSRC}/libfuncs.c" \
-ggdb -g \
-fno-builtin \
-o libfuncs.so
echo ">>>>>>> Build static library"
$CLANG \
-c \
-flto \
-fPIC \
$OPT_LEVEL \
-U_FORTIFY_SOURCE \
-D_FORTIFY_SOURCE=0 \
-Xclang -load -Xclang "${LLVMROOT}/build/lib/LLVMSPP.so" \
-include "${SPPLIBSRC}/spp.h" \
"-I${PMDKSRC}/include/" \
"${TESTSRC}/libfuncs.c" \
-ggdb -g \
-fno-builtin \
-o libfuncs.o
$AR \
rcs \
libfuncs.a \
libfuncs.o
echo ">>>>>>> Build dynamically linked driver"
$CLANG \
$OPT_LEVEL \
-U_FORTIFY_SOURCE \
-D_FORTIFY_SOURCE=0 \
-flto \
-fuse-ld=gold \
-Xclang -load -Xclang "${LLVMROOT}/build/lib/LLVMSPP.so" \
-include "${SPPLIBSRC}/spp.h" \
"-I./" "-L./" \
"-I${PMDKSRC}/include/" "-L${PMDKSRC}/nondebug/" \
$WRAP_LIST "${SPPLIBOBJ}/wrappers_spp.o" \
-Xlinker "${SPPLIBOBJ}/spp.o" \
-DTAG_BITS=26 -lfuncs -lpmem -lpmemobj \
"${TESTSRC}/driver.c" \
-ggdb -g \
-fno-builtin \
-o driver_shared #-v
echo ">>>>>>> Build statically linked driver"
$CLANG \
$OPT_LEVEL \
-U_FORTIFY_SOURCE \
-D_FORTIFY_SOURCE=0 \
-flto \
-Xclang -load -Xclang "${LLVMROOT}/build/lib/LLVMSPP.so" \
-include "${SPPLIBSRC}/spp.h" \
"-I./" \
"-I${PMDKSRC}/include/" "-L${PMDKSRC}/nondebug/" \
$WRAP_LIST "${SPPLIBOBJ}/wrappers_spp.o" \
-Xlinker "${SPPLIBOBJ}/spp.o" \
-DTAG_BITS=26 -lpmem -lpmemobj \
-rdynamic "${TESTSRC}/driver.c" \
-ggdb -g \
-fno-builtin \
-o driver_static \
./libfuncs.a
echo ">>>>>>> Build llvm IRs"
$CLANG $OPT_LEVEL -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fno-builtin -S -I${PMDKSRC}/include/ -emit-llvm libfuncs.c
opt $OPT_LEVEL -load "${LLVMROOT}/build/lib/LLVMSPP.so" -S libfuncs.ll -o libfuncs_transformed.ll
$CLANG $OPT_LEVEL -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fno-builtin -S -I${PMDKSRC}/include/ -emit-llvm driver.c
opt $OPT_LEVEL -load "${LLVMROOT}/build/lib/LLVMSPP.so" -S driver.ll -o driver_transformed.ll #produce transformed .ll pass sequence plays a role here
echo ">>>>>>> Run driver shared"
rm -rf /dev/shm/spp_test.pool_lib
LD_LIBRARY_PATH="${PMDKSRC}/nondebug:./" ./driver_shared
echo ">>>>>>> Run driver static"
rm -rf /dev/shm/spp_test.pool_lib
LD_LIBRARY_PATH="${PMDKSRC}/nondebug" ./driver_static