Skip to content

Commit c3c300f

Browse files
committed
do_SRPM.sh: Rebase to newer upstream version
* Add support for LLVM 11 on F33+ * Link with LLVM dynamically
1 parent 1727410 commit c3c300f

File tree

4 files changed

+1459
-330
lines changed

4 files changed

+1459
-330
lines changed

do_SRPM.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
set -e
44

55
# upstream revision to checkout
6-
SYMBIOTIC_REV="svcomp19-506-g630bd29"
6+
SYMBIOTIC_REV="svcomp19-528-g0db3c4a"
77

88
rm -rf srpm
99
mkdir srpm
1010
cd srpm
1111

1212
# clone symbiotic git repo, including its submodules
13-
git clone --recurse-submodules https://github.com/staticafi/symbiotic.git
13+
git clone --depth 1 --recurse-submodules https://github.com/staticafi/symbiotic.git
1414

1515
pushd symbiotic > /dev/null
1616

@@ -58,29 +58,34 @@ tar -Jcf "symbiotic-$VER.tar.xz" "symbiotic-$VER"
5858
cat > symbiotic.spec << EOF
5959
Name: $PKG
6060
Version: $VER
61-
Release: 5%{?dist}
61+
Release: 1%{?dist}
6262
Summary: Tool for analysis of sequential computer programs written in C
63-
License: Free
63+
License: MIT
6464
URL: https://github.com/staticafi/%{name}
65+
6566
Source0: %{name}-%{version}.tar.xz
6667
Source1: symbiotic2cs.py
6768
Source2: csexec-symbiotic.sh
69+
6870
Patch0: build.patch
6971
Patch1: hotfix.patch
72+
Patch2: llvm-dynamic-link.patch
73+
%if 0%{?fedora} > 32
74+
Patch3: llvm-11.patch
75+
%endif
7076
71-
BuildRequires: gcc
72-
BuildRequires: cmake
73-
BuildRequires: jsoncpp-devel
74-
BuildRequires: llvm-devel
75-
BuildRequires: llvm-static
77+
BuildRequires: gcc-c++
7678
BuildRequires: clang
79+
BuildRequires: cmake
7780
BuildRequires: glibc-devel
7881
BuildRequires: glibc-devel(x86-32)
82+
BuildRequires: jsoncpp-devel
83+
BuildRequires: llvm-devel
7984
BuildRequires: ncurses-devel
8085
BuildRequires: python3
8186
BuildRequires: sqlite-devel
8287
BuildRequires: z3-devel
83-
BuildRequires: zlib-static
88+
BuildRequires: zlib-devel
8489
8590
Requires: clang
8691
Requires: llvm
@@ -117,6 +122,6 @@ ln -sf /opt/symbiotic/bin/symbiotic %{buildroot}%{_bindir}/symbiotic
117122
%{_bindir}/csexec-symbiotic
118123
EOF
119124

120-
cp ../{symbiotic2cs.py,csexec-symbiotic.sh,build.patch,hotfix.patch} .
125+
cp ../{symbiotic2cs.py,csexec-symbiotic.sh,{build,hotfix,llvm-{11,dynamic-link}}.patch} .
121126

122127
rpmbuild -bs symbiotic.spec --define "_sourcedir $PWD" --define "_srcrpmdir $PWD"

hotfix.patch

Lines changed: 1 addition & 319 deletions
Original file line numberDiff line numberDiff line change
@@ -11,198 +11,7 @@
1111
# copy the jsoncpp.cpp file into parent's src/ folder
1212
cp dist/jsoncpp.cpp ../src/
1313

14-
# lzaoral/fix-custom-llvm
15-
diff --git a/system-build.sh b/system-build.sh
16-
index cb4ecff..b83932a 100755
17-
--- a/system-build.sh
18-
+++ b/system-build.sh
19-
@@ -246,21 +246,22 @@ elif [ $LLVM_MAJOR_VERSION -ge 3 -a $LLVM_MINOR_VERSION -ge 9 ]; then
20-
LLVM_CMAKE_CONFIG_DIR=lib/cmake/llvm
21-
fi
22-
23-
+LLVM_BIN_DIR=$("$LLVM_CONFIG" --bindir)
24-
+
25-
mkdir -p $LLVM_PREFIX/bin
26-
for T in $LLVM_TOOLS; do
27-
- TOOL=$(which $T || true)
28-
-
29-
- # always avoid making copy of a ccache executable (symlink's target)
30-
- if [[ "$TOOL" =~ "ccache" ]]; then
31-
- TOOL="/usr/bin/$T"
32-
+ TOOL="$LLVM_BIN_DIR/$T"
33-
+ if [ ! -x "${TOOL}" ]; then
34-
+ exitmsg "Cannot find working $T binary".
35-
fi
36-
37-
- if [ -z "${TOOL}" -o ! -x "${TOOL}" ]; then
38-
- exitmsg "Cannot find working $T binary"
39-
+ TOOL_VERSION=$("$TOOL" --version)
40-
+ if [[ ! "$TOOL_VERSION" =~ "$LLVM_VERSION" ]]; then
41-
+ exitmsg "$T has wrong version. Expected: $LLVM_VERSION Found: $TOOL_VERSION"
42-
fi
43-
44-
# copy the binaries only with full-archive option
45-
- if [ "$FULL_ARCHIVE" = "no" ] || readlink -- "${TOOL}" > /dev/null; then
46-
+ if [ "$FULL_ARCHIVE" = "no" ] ; then
47-
ln -fs "${TOOL}" "${LLVM_PREFIX}/bin"
48-
else
49-
cp -rf "${TOOL}" "${LLVM_PREFIX}/bin"
50-
51-
diff --git a/system-build.sh b/system-build.sh
52-
index b83932a..dbe983f 100755
53-
--- a/system-build.sh
54-
+++ b/system-build.sh
55-
@@ -269,7 +269,11 @@ for T in $LLVM_TOOLS; do
56-
done
57-
58-
mkdir -p $LLVM_PREFIX/lib
59-
-ln -sf $(dirname $(which clang))/../lib/clang/ $LLVM_PREFIX/lib/
60-
+CLANG_LIBS=$("$LLVM_CONFIG" --libdir)/clang/
61-
+if [ ! -d "$CLANG_LIBS" ]; then
62-
+ exitmsg "Invalid path to clang libraries."
63-
+fi
64-
+ln -sf "$CLANG_LIBS" "$LLVM_PREFIX/lib/"
65-
66-
######################################################################
67-
# dg
68-
69-
diff --git a/scripts/precompile_bitcode_files.sh b/scripts/precompile_bitcode_files.sh
70-
index c662433..6dd9824 100755
71-
--- a/scripts/precompile_bitcode_files.sh
72-
+++ b/scripts/precompile_bitcode_files.sh
73-
@@ -14,7 +14,7 @@ ORIG_CPPFLAGS="$CPPFLAGS"
74-
for LLVM in $PREFIX/llvm-*; do
75-
CLANG=$LLVM/bin/clang
76-
LLVM_VERSION=${LLVM#*llvm-*}
77-
- INCLUDE_DIR="llvm-${LLVM_VERSION}/build/lib/clang/${LLVM_VERSION}/include/"
78-
+ INCLUDE_DIR="$LLVM/lib/clang/${LLVM_VERSION}/include/"
79-
CPPFLAGS="-I ${INCLUDE_DIR} $ORIG_CPPFLAGS"
80-
for F in `find $INSTR/instrumentations/ -name '*.c'`; do
81-
NAME=`basename $F`
82-
@@ -33,7 +33,7 @@ done
83-
for LLVM in $PREFIX/llvm-*; do
84-
CLANG=$LLVM/bin/clang
85-
LLVM_VERSION=${LLVM#*llvm-*}
86-
- INCLUDE_DIR="llvm-${LLVM_VERSION}/build/lib/clang/${LLVM_VERSION}/include/"
87-
+ INCLUDE_DIR="$LLVM/lib/clang/${LLVM_VERSION}/include/"
88-
CPPFLAGS="-I ${INCLUDE_DIR} -Iinclude/ $ORIG_CPPFLAGS"
89-
for F in `find $LIBS -name '*.c'`; do
90-
NAME=`basename $F`
91-
92-
diff --git a/scripts/build-utils.sh b/scripts/build-utils.sh
93-
index 3a43d55..8b6feed 100644
94-
--- a/scripts/build-utils.sh
95-
+++ b/scripts/build-utils.sh
96-
@@ -1,4 +1,4 @@
97-
-#!/bin/sh
98-
+#!/bin/bash
99-
100-
set -x
101-
102-
@@ -57,6 +57,20 @@ build()
103-
return 0
104-
}
105-
106-
+check_llvm_tool()
107-
+{
108-
+ TOOL_PATH="$1"
109-
+ TOOL_NAME="$(dirname "$1")"
110-
+ if [ ! -x "$TOOL_PATH" ]; then
111-
+ exitmsg "Cannot find working $TOOL_NAME binary".
112-
+ fi
113-
+
114-
+ TOOL_VERSION=$("$TOOL_PATH" --version)
115-
+ if [[ ! "$TOOL_VERSION" =~ "$LLVM_VERSION" ]]; then
116-
+ exitmsg "$TOOL_NAME has wrong version. Expected: $LLVM_VERSION Found: $TOOL_VERSION"
117-
+ fi
118-
+}
119-
+
120-
git_clone_or_pull()
121-
{
122-
123-
diff --git a/system-build.sh b/system-build.sh
124-
index dbe983f..8748120 100755
125-
--- a/system-build.sh
126-
+++ b/system-build.sh
127-
@@ -250,28 +250,21 @@ LLVM_BIN_DIR=$("$LLVM_CONFIG" --bindir)
128-
129-
mkdir -p $LLVM_PREFIX/bin
130-
for T in $LLVM_TOOLS; do
131-
- TOOL="$LLVM_BIN_DIR/$T"
132-
- if [ ! -x "${TOOL}" ]; then
133-
- exitmsg "Cannot find working $T binary".
134-
- fi
135-
-
136-
- TOOL_VERSION=$("$TOOL" --version)
137-
- if [[ ! "$TOOL_VERSION" =~ "$LLVM_VERSION" ]]; then
138-
- exitmsg "$T has wrong version. Expected: $LLVM_VERSION Found: $TOOL_VERSION"
139-
- fi
140-
+ check_llvm_tool "$LLVM_BIN_DIR/$T"
141-
142-
# copy the binaries only with full-archive option
143-
if [ "$FULL_ARCHIVE" = "no" ] ; then
144-
- ln -fs "${TOOL}" "${LLVM_PREFIX}/bin"
145-
- else
146-
- cp -rf "${TOOL}" "${LLVM_PREFIX}/bin"
147-
+ ln -fs "$LLVM_BIN_DIR/$T" "$LLVM_PREFIX/bin"
148-
+ continue
149-
fi
150-
+
151-
+ cp -L "$LLVM_BIN_DIR/$T" "$LLVM_PREFIX/bin"
152-
done
153-
154-
mkdir -p $LLVM_PREFIX/lib
155-
CLANG_LIBS=$("$LLVM_CONFIG" --libdir)/clang/
156-
if [ ! -d "$CLANG_LIBS" ]; then
157-
- exitmsg "Invalid path to clang libraries."
158-
+ exitmsg "Invalid path to clang libraries."
159-
fi
160-
ln -sf "$CLANG_LIBS" "$LLVM_PREFIX/lib/"
161-
162-
diff --git a/scripts/build-utils.sh b/scripts/build-utils.sh
163-
index 8b6feed..1cfdbd4 100644
164-
--- a/scripts/build-utils.sh
165-
+++ b/scripts/build-utils.sh
166-
@@ -60,7 +60,7 @@ build()
167-
check_llvm_tool()
168-
{
169-
TOOL_PATH="$1"
170-
- TOOL_NAME="$(dirname "$1")"
171-
+ TOOL_NAME="$(basename "$1")"
172-
if [ ! -x "$TOOL_PATH" ]; then
173-
exitmsg "Cannot find working $TOOL_NAME binary".
174-
fi
175-
diff --git a/system-build.sh b/system-build.sh
176-
index 8748120..9b5a515 100755
177-
--- a/system-build.sh
178-
+++ b/system-build.sh
179-
@@ -239,13 +239,6 @@ export LLVM_PREFIX="$PREFIX/llvm-$LLVM_VERSION"
180-
LLVM_MAJOR_VERSION="${LLVM_VERSION%%\.*}"
181-
LLVM_MINOR_VERSION=${LLVM_VERSION#*\.}
182-
LLVM_MINOR_VERSION="${LLVM_MINOR_VERSION%\.*}"
183-
-LLVM_CMAKE_CONFIG_DIR=share/llvm/cmake
184-
-if [ $LLVM_MAJOR_VERSION -gt 3 ]; then
185-
- LLVM_CMAKE_CONFIG_DIR=lib/cmake/llvm
186-
-elif [ $LLVM_MAJOR_VERSION -ge 3 -a $LLVM_MINOR_VERSION -ge 9 ]; then
187-
- LLVM_CMAKE_CONFIG_DIR=lib/cmake/llvm
188-
-fi
189-
-
190-
LLVM_BIN_DIR=$("$LLVM_CONFIG" --bindir)
191-
192-
mkdir -p $LLVM_PREFIX/bin
193-
@@ -350,7 +343,9 @@ if [ $FROM -le 6 -a "$BUILD_PREDATOR" = "yes" ]; then
194-
pushd predator-${LLVM_VERSION}
195-
196-
if [ ! -d CMakeFiles ]; then
197-
- CXX=clang++ ./switch-host-llvm.sh /usr/${LLVM_CMAKE_CONFIG_DIR}
198-
+ check_llvm_tool "$LLVM_BIN_DIR/clang++"
199-
+ CXX="$LLVM_BIN_DIR/clang++" ./switch-host-llvm.sh \
200-
+ "$("$LLVM_CONFIG" --cmakedir)"
201-
fi
202-
203-
build || exit 1
204-
205-
# build with default Fedora build flags
14+
# Build with default Fedora build flags
20615
diff --git a/scripts/build-utils.sh b/scripts/build-utils.sh
20716
index 3a43d55..60597d0 100644
20817
--- a/scripts/build-utils.sh
@@ -268,130 +77,3 @@ index c662433..e84e123 100755
26877
FILES="$FILES ${LLVM#install/}/lib32/$OUT"
26978
done
27079
done
271-
diff --git a/transforms/CMakeLists.txt b/transforms/CMakeLists.txt
272-
index 4f71902..2e267f7 100644
273-
--- a/transforms/CMakeLists.txt
274-
+++ b/transforms/CMakeLists.txt
275-
@@ -9,13 +9,6 @@ message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
276-
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
277-
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
278-
279-
-if (${LLVM_PACKAGE_VERSION} VERSION_LESS_EQUAL "3.7")
280-
- # needed for LLVM 3.7
281-
- set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR})
282-
- set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR})
283-
- include(HandleLLVMOptions)
284-
-endif()
285-
-
286-
include(AddLLVM)
287-
288-
# explicitly add -std=c++11 (c++14), some cmake versions
289-
@@ -57,11 +50,6 @@ include(GNUInstallDirs)
290-
message(STATUS "CMAKE_INSTALL_LIBDIR: \"${CMAKE_INSTALL_LIBDIR}\"")
291-
message(STATUS "CMAKE_INSTALL_INCLUDEDIR: \"${CMAKE_INSTALL_INCLUDEDIR}\"")
292-
293-
-# We need all the symbols with dynamic libs. With static libs, we get errors.
294-
-if (BUILD_SHARED_LIBS)
295-
- set(LLVM_LINK_COMPONENTS analysis core support)
296-
-endif()
297-
-
298-
add_library(LLVMsbt MODULE "BreakCritLoops.cpp"
299-
"BreakInfiniteLoops.cpp"
300-
"CheckModule.cpp"
301-
@@ -92,6 +80,7 @@ add_library(LLVMsbt MODULE "BreakCritLoops.cpp"
302-
303-
# remove lib prefix for compatibility with older releases
304-
set_target_properties(LLVMsbt PROPERTIES PREFIX "")
305-
+target_link_libraries(LLVMsbt LLVM)
306-
307-
install(TARGETS LLVMsbt
308-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
309-
diff --git a/transforms/InternalizeGlobals.cpp b/transforms/InternalizeGlobals.cpp
310-
index 3c6a3db..3d7c5a7 100644
311-
--- a/transforms/InternalizeGlobals.cpp
312-
+++ b/transforms/InternalizeGlobals.cpp
313-
@@ -64,9 +64,8 @@ bool InternalizeGlobals::initializeExternalGlobals(Module& M) {
314-
// GV is a pointer to some memory, we want the size of the memory
315-
Type *Ty = GV->getType()->getContainedType(0);
316-
if (!Ty->isSized()) {
317-
- GV->dump();
318-
- llvm::errs() << "ERROR: failed making global variable symbolic "
319-
- "(type is unsized)\n";
320-
+ llvm::errs() << GV << "\nERROR: failed making global variable symbolic "
321-
+ "(type is unsized)\n";
322-
continue;
323-
}
324-
325-
@@ -86,9 +85,8 @@ bool InternalizeGlobals::initializeExternalGlobals(Module& M) {
326-
// point to and set it to symbolic at the beggining of main
327-
if (Ty->isPointerTy()) {
328-
if (!Ty->getContainedType(0)->isSized()) {
329-
- GV->dump();
330-
- llvm::errs() << "ERROR: failed making global variable symbolic "
331-
- "(referenced type is unsized)\n";
332-
+ llvm::errs() << GV << "\nERROR: failed making global variable "
333-
+ "symbolic (referenced type is unsized)\n";
334-
continue;
335-
}
336-
337-
# Add --argv option
338-
diff --git a/lib/symbioticpy/symbiotic/options.py b/lib/symbioticpy/symbiotic/options.py
339-
index 4289a55..1d62f39 100644
340-
--- a/lib/symbioticpy/symbiotic/options.py
341-
+++ b/lib/symbioticpy/symbiotic/options.py
342-
@@ -52,6 +52,7 @@ class SymbioticOptions(object):
343-
self.witness_output = '{0}/witness.graphml'.format(os.getcwd())
344-
self.testsuite_output = '{0}/test-suite'.format(os.getcwd())
345-
self.source_is_bc = False
346-
+ self.argv = []
347-
self.optlevel = ["before-O3", "after-O3"]
348-
self.slicer_pta = 'fi'
349-
self.memsafety_config_file = None
350-
@@ -205,7 +206,7 @@ def parse_command_line():
351-
'instrumentation-timeout=', 'version', 'help',
352-
'no-verification', 'output=', 'witness=', 'bc',
353-
'optimize=', 'malloc-never-fails',
354-
- 'pta=', 'no-link=',
355-
+ 'pta=', 'no-link=', 'argv=',
356-
'cflags=', 'cppflags=', 'link=', 'executable-witness',
357-
'verifier=','target=', 'require-slicer',
358-
'no-link-undefined', 'repeat-slicing=',
359-
@@ -246,6 +247,8 @@ def parse_command_line():
360-
elif opt == '--version-short':
361-
print_shortest_vers()
362-
sys.exit(0)
363-
+ elif opt == '--argv':
364-
+ options.argv = arg.split(',')
365-
elif opt == '--version':
366-
print_versions()
367-
sys.exit(0)
368-
@@ -475,6 +478,7 @@ where OPTS can be following:
369-
--cflags=flags
370-
--cppflags=flags Append extra CFLAGS and CPPFLAGS to use while compiling,
371-
the environment CFLAGS and CPPFLAGS are used too
372-
+ --argv=args Arguments for the main function of the verified bitcode
373-
--slicer-params=STR Pass parameters directly to slicer
374-
--slicer-cmd=STR Command to run slicer, default: sbt-slicer
375-
--verifier-params=STR Pass parameters directly to the verifier
376-
diff --git a/lib/symbioticpy/symbiotic/targets/klee.py b/lib/symbioticpy/symbiotic/targets/klee.py
377-
index 3e52eed..51b6577 100644
378-
--- a/lib/symbioticpy/symbiotic/targets/klee.py
379-
+++ b/lib/symbioticpy/symbiotic/targets/klee.py
380-
@@ -125,7 +125,7 @@ class KleeToolFullInstrumentation(KleeBase):
381-
if self._options.exit_on_error:
382-
cmd.append('-exit-on-error-type=Assert')
383-
384-
- return cmd + options + tasks
385-
+ return cmd + options + tasks + self._options.argv
386-
387-
def _parse_klee_output_line(self, line):
388-
for (key, pattern) in self._patterns:
389-
@@ -335,7 +335,7 @@ class SymbioticTool(KleeBase):
390-
# but we may remove this switch during debugging)
391-
cmd.append('-output-source=false')
392-
393-
- return cmd + options + tasks
394-
+ return cmd + options + tasks + self._options.argv
395-
396-
def _parse_klee_output_line(self, line):
397-
opts = self._options

0 commit comments

Comments
 (0)