svf-lib 1.0.2640 → 1.0.2642
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
Binary file
|
package/llvm_install.sh
CHANGED
|
@@ -4,14 +4,125 @@ sysOS=`uname -s`
|
|
|
4
4
|
arch=`uname -m`
|
|
5
5
|
MajorLLVMVer=21
|
|
6
6
|
LLVMVer=${MajorLLVMVer}.1.0
|
|
7
|
+
Z3Ver=4.15.4
|
|
7
8
|
UbuntuLLVM_RTTI="https://github.com/bjjwwang/SVF-LLVM/releases/download/${LLVMVer}/llvm-${LLVMVer}-ubuntu22-rtti-x86-64.tar.gz"
|
|
8
9
|
UbuntuArmLLVM_RTTI="https://github.com/bjjwwang/SVF-LLVM/releases/download/${LLVMVer}/llvm-${LLVMVer}-ubuntu22-rtti-aarch64.tar.gz"
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
Z3PrebuiltBase="https://github.com/SVF-tools/SVF-npm/raw/prebuilt-libs"
|
|
12
|
+
UbuntuZ3Arm="${Z3PrebuiltBase}/z3-${Z3Ver}-arm64-ubuntu-22.04.zip"
|
|
13
|
+
UbuntuZ3="${Z3PrebuiltBase}/z3-${Z3Ver}-x86_64-ubuntu-22.04.zip"
|
|
14
|
+
MacOSZ3Arm="${Z3PrebuiltBase}/z3-${Z3Ver}-arm64-macos-14.zip"
|
|
12
15
|
Z3Home="z3.obj"
|
|
13
16
|
LLVMHome="llvm-${LLVMVer}.obj"
|
|
14
17
|
|
|
18
|
+
function download_file {
|
|
19
|
+
if [[ $# -ne 2 ]]; then
|
|
20
|
+
echo "$0: bad args to download_file!"
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
local url="$1"
|
|
25
|
+
local out="$2"
|
|
26
|
+
|
|
27
|
+
local download_failed=false
|
|
28
|
+
if command -v curl >/dev/null 2>&1; then
|
|
29
|
+
if ! curl -fL "$url" -o "$out"; then
|
|
30
|
+
download_failed=true
|
|
31
|
+
fi
|
|
32
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
33
|
+
if ! wget -c "$url" -O "$out"; then
|
|
34
|
+
download_failed=true
|
|
35
|
+
fi
|
|
36
|
+
else
|
|
37
|
+
echo "Cannot find curl or wget."
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
if $download_failed; then
|
|
42
|
+
echo "Failed to download $url"
|
|
43
|
+
rm -f "$out"
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function find_z3_root {
|
|
49
|
+
local search_dir="$1"
|
|
50
|
+
local candidate=""
|
|
51
|
+
|
|
52
|
+
while IFS= read -r -d '' candidate; do
|
|
53
|
+
if [[ -d "$candidate/include" && -d "$candidate/bin" ]]; then
|
|
54
|
+
echo "$candidate"
|
|
55
|
+
return 0
|
|
56
|
+
fi
|
|
57
|
+
done < <(find "$search_dir" -type d -print0)
|
|
58
|
+
|
|
59
|
+
return 1
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function unpack_z3_package {
|
|
63
|
+
if [[ $# -ne 2 ]]; then
|
|
64
|
+
echo "$0: bad args to unpack_z3_package!"
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
local archive="$1"
|
|
69
|
+
local target_dir="$2"
|
|
70
|
+
local unpack_dir="z3-unpack"
|
|
71
|
+
local nested_zip=""
|
|
72
|
+
local nested_dir=""
|
|
73
|
+
local z3_dir=""
|
|
74
|
+
|
|
75
|
+
rm -rf "$unpack_dir" "$target_dir"
|
|
76
|
+
mkdir "$unpack_dir"
|
|
77
|
+
unzip -q "$archive" -d "$unpack_dir"
|
|
78
|
+
|
|
79
|
+
while IFS= read -r -d '' nested_zip; do
|
|
80
|
+
nested_dir="$unpack_dir/nested-$(basename "$nested_zip" .zip)"
|
|
81
|
+
mkdir -p "$nested_dir"
|
|
82
|
+
unzip -q "$nested_zip" -d "$nested_dir"
|
|
83
|
+
done < <(find "$unpack_dir" -type f -name 'z3-*.zip' -print0)
|
|
84
|
+
|
|
85
|
+
if ! z3_dir=$(find_z3_root "$unpack_dir"); then
|
|
86
|
+
rm -rf "$unpack_dir"
|
|
87
|
+
echo "Z3 package did not contain the expected bin/ and include/ layout."
|
|
88
|
+
exit 1
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
mv "$z3_dir" "$target_dir"
|
|
92
|
+
rm -rf "$unpack_dir"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function fix_linux_z3_links {
|
|
96
|
+
if [[ "$sysOS" != "Linux" ]]; then
|
|
97
|
+
return
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
if [[ -f "$Z3_DIR/bin/libz3.so" ]]; then
|
|
101
|
+
ln -sf libz3.so "$Z3_DIR/bin/libz3.so.4"
|
|
102
|
+
fi
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function fix_macos_z3_load_paths {
|
|
106
|
+
if [[ "$sysOS" != "Darwin" ]]; then
|
|
107
|
+
return
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
local z3_dylib="$Z3_DIR/bin/libz3.dylib"
|
|
111
|
+
local z3_rpath="@loader_path/../../../${Z3Home}/bin"
|
|
112
|
+
local binary=""
|
|
113
|
+
|
|
114
|
+
if [[ -f "$z3_dylib" ]]; then
|
|
115
|
+
install_name_tool -id "@rpath/libz3.dylib" "$z3_dylib"
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
while IFS= read -r -d '' binary; do
|
|
119
|
+
install_name_tool -change "/opt/homebrew/opt/z3/lib/libz3.4.15.dylib" "@rpath/libz3.dylib" "$binary" 2>/dev/null || true
|
|
120
|
+
install_name_tool -change "/opt/homebrew/opt/z3/lib/libz3.dylib" "@rpath/libz3.dylib" "$binary" 2>/dev/null || true
|
|
121
|
+
install_name_tool -change "libz3.dylib" "@rpath/libz3.dylib" "$binary" 2>/dev/null || true
|
|
122
|
+
install_name_tool -add_rpath "$z3_rpath" "$binary" 2>/dev/null || true
|
|
123
|
+
done < <(find "$SVFHOME/SVF-osx/bin" "$SVFHOME/SVF-osx/lib" \( -type f -perm -111 -o -name '*.dylib' \) -print0)
|
|
124
|
+
}
|
|
125
|
+
|
|
15
126
|
if [[ $sysOS == "Darwin" ]]
|
|
16
127
|
then
|
|
17
128
|
# Create soft links for SvfLLVM
|
|
@@ -112,16 +223,18 @@ if [[ $sysOS == "Darwin" ]]
|
|
|
112
223
|
then
|
|
113
224
|
if [ ! -d "$install_path/$Z3Home" ]
|
|
114
225
|
then
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
226
|
+
if [[ $arch == "arm64" ]]
|
|
227
|
+
then
|
|
228
|
+
urlZ3=$MacOSZ3Arm
|
|
229
|
+
else
|
|
230
|
+
echo "No prebuilt z3 binary is available for MacOS ${arch}."
|
|
231
|
+
exit 1
|
|
232
|
+
fi
|
|
233
|
+
echo 'Downloading z3 binary for MacOS arm64'
|
|
234
|
+
download_file "$urlZ3" z3.zip
|
|
235
|
+
echo 'Unzipping z3 binary for MacOS'
|
|
236
|
+
unpack_z3_package z3.zip "$install_path/$Z3Home"
|
|
237
|
+
rm z3.zip
|
|
125
238
|
fi
|
|
126
239
|
elif [[ $sysOS == "Linux" ]]
|
|
127
240
|
then
|
|
@@ -135,17 +248,18 @@ then
|
|
|
135
248
|
fi
|
|
136
249
|
if [ ! -d "$install_path/$Z3Home" ]
|
|
137
250
|
then
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
rm z3.zip
|
|
251
|
+
echo 'Downloading z3 binary for Ubuntu'
|
|
252
|
+
download_file "$urlZ3" z3.zip
|
|
253
|
+
echo 'Unzipping z3 binary for Ubuntu'
|
|
254
|
+
unpack_z3_package z3.zip "$install_path/$Z3Home"
|
|
255
|
+
rm z3.zip
|
|
144
256
|
fi
|
|
145
257
|
else
|
|
146
258
|
echo 'not support z3 builds in OS other than Ubuntu and Mac'
|
|
147
259
|
fi
|
|
148
260
|
export Z3_DIR="$install_path/$Z3Home"
|
|
261
|
+
fix_linux_z3_links
|
|
262
|
+
fix_macos_z3_load_paths
|
|
149
263
|
echo "Z3_DIR=$Z3_DIR"
|
|
150
264
|
export SVF_DIR="$install_path/SVF"
|
|
151
265
|
echo "SVF_DIR=$SVF_DIR"
|