Skip to content

Commit 1965c6f

Browse files
committed
Merge branch 'master_github' into master-gitlab
2 parents b814cf1 + 42ba7f5 commit 1965c6f

162 files changed

Lines changed: 1616 additions & 1142 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ set(CMAKE_CXX_STANDARD 17)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616
set(CMAKE_CXX_EXTENSIONS OFF)
1717

18+
set_property(GLOBAL PROPERTY TARGET_MESSAGES OFF)
19+
1820
if (NOT CMAKE_BUILD_TYPE)
1921
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('Debug' or 'Release',
2022
default is 'Debug')" FORCE)
@@ -91,10 +93,22 @@ include_directories(
9193
# Threads
9294
find_package(Threads)
9395

96+
# Fix boost_thread dependency for MacOS
97+
if(APPLE)
98+
set(BOOST_THREAD thread-mt)
99+
else()
100+
set(BOOST_THREAD thread)
101+
endif()
102+
103+
# Boost
104+
find_package(Boost 1.65.1 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
105+
include_directories(${Boost_INCLUDE_DIRS})
106+
add_definitions(-DBOOST_LOG_DYN_LINK)
107+
94108
# JSON library
95109
option(JSON_BuildTests OFF)
96110
add_subdirectory(external/json EXCLUDE_FROM_ALL)
97-
include_directories(external/json/single_include/nlohmann)
111+
include_directories(external/json/single_include/)
98112

99113
# Googletest
100114
if (NOT PHASAR_IN_TREE)
@@ -111,11 +125,6 @@ endif()
111125
add_subdirectory(external/WALi-OpenNWA)
112126
include_directories(external/WALi-OpenNWA/Source/wali/include)
113127

114-
# Boost
115-
find_package(Boost COMPONENTS filesystem graph system program_options log thread REQUIRED)
116-
include_directories(${BOOST_INCLUDE_DIR})
117-
add_definitions(-DBOOST_LOG_DYN_LINK)
118-
119128
# SQL
120129
find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)
121130
find_library(SQLITE3_LIBRARY NAMES sqlite3)
@@ -203,13 +212,6 @@ llvm_map_components_to_libnames(llvm_libs
203212
# phasar-based binaries
204213
add_subdirectory(tools)
205214

206-
# Fix boost_thread dependency for MacOS
207-
if(APPLE)
208-
set(BOOST_THREAD boost_thread-mt)
209-
else()
210-
set(BOOST_THREAD boost_thread)
211-
endif()
212-
213215
# Workaround: Remove Plugins for MacOS for now
214216
if(APPLE)
215217
set(PHASAR_PLUGINS_LIB)
@@ -243,7 +245,7 @@ install(DIRECTORY include/
243245
)
244246

245247
# Install the header only json container
246-
install(DIRECTORY external/json/single_include/nlohmann/
248+
install(DIRECTORY external/json/single_include/
247249
DESTINATION include
248250
FILES_MATCHING PATTERN "*.hpp"
249251
)

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ If you are using PhASAR without the wish or expertise to contribute to its code
3333
Thanks for contributing to the PhASAR project.
3434

3535
`std::cout << "Thank you!\n";`
36+
37+
## Additional Notes for Student Assistants
38+
When implementing a new feature please name you feature branch according to the following naming scheme:
39+
40+
* `f-CamelCase`

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ COPY . /usr/src/phasar
1212

1313
RUN ./bootstrap_docker.sh
1414

15-
ENTRYPOINT [ "./build/phasar" ]
15+
ENTRYPOINT [ "./build/phasar-llvm/phasar-llvm" ]

bootstrap.sh

Lines changed: 82 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#!/bin/bash
22
set -e
33

4+
readonly PHASAR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5+
readonly PHASAR_INSTALL_DIR="/usr/local/phasar"
6+
readonly LLVM_INSTALL_DIR="/usr/local/llvm-9"
7+
48
NUM_THREADS=$(nproc)
59
LLVM_RELEASE=llvmorg-9.0.0
10+
DO_UNIT_TEST=false
11+
612

713
# Parsing command-line-parameters
814
# See "https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash" as a reference
@@ -18,6 +24,19 @@ case $key in
1824
shift # past argument
1925
shift # past value
2026
;;
27+
-u|--unittest)
28+
DO_UNIT_TEST=true
29+
shift # past argument
30+
;;
31+
-DBOOST_DIR)
32+
DESIRED_BOOST_DIR="$2"
33+
shift # past argument
34+
shift # past value
35+
;;
36+
-DBOOST_DIR=*)
37+
DESIRED_BOOST_DIR="${key#*=}"
38+
shift # past argument=value
39+
;;
2140
-DBOOST_VERSION)
2241
DESIRED_BOOST_VERSION="$2"
2342
shift # past argument
@@ -41,79 +60,87 @@ set -- "${POSITIONAL[@]}" # restore positional parameters
4160
echo "installing phasar dependencies..."
4261

4362
sudo apt-get update
44-
sudo apt-get install zlib1g-dev sqlite3 libsqlite3-dev libmysqlcppconn-dev bear python3 doxygen graphviz python python-dev python3-pip python-pip libxml2 libxml2-dev libncurses5-dev libncursesw5-dev swig build-essential g++ cmake libz3-dev libedit-dev python-sphinx libomp-dev libcurl4-openssl-dev -y
63+
sudo apt-get install zlib1g-dev sqlite3 libsqlite3-dev bear python3 doxygen graphviz python python-dev python3-pip python-pip libxml2 libxml2-dev libncurses5-dev libncursesw5-dev swig build-essential g++ cmake libz3-dev libedit-dev python-sphinx libomp-dev libcurl4-openssl-dev -y
4564
sudo pip install Pygments
4665
sudo pip install pyyaml
47-
# installing boost
48-
#wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz
49-
#tar xvf boost_1_66_0.tar.gz
50-
#cd boost_1_66_0/
51-
#./bootstrap.sh
52-
#sudo ./b2 install
53-
#cd ..
5466

67+
if [ ! -z ${DESIRED_BOOST_DIR} ]; then
68+
BOOST_PARAMS="-DBOOST_ROOT=${DESIRED_BOOST_DIR}"
69+
else
5570
# New way of installing boost:
56-
5771
# Check whether we have the required boost packages installed
58-
59-
BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')
60-
61-
if [ -z $BOOST_VERSION ] ;then
62-
if [ -z $DESIRED_BOOST_VERSION ] ;then
63-
sudo apt-get install libboost-all-dev -y
64-
else
65-
# DESIRED_BOOST_VERSION in form d.d, i.e. 1.65 (this is the latest version I found in the apt repo)
66-
sudo apt-get install "libboost${DESIRED_BOOST_VERSION}-all-dev" -y
67-
fi
68-
#verify installation
69-
BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')
70-
if [ -z $BOOST_VERSION ] ;then
71-
echo "Failed installing boost $DESIRED_BOOST_VERSION"
72-
exit 1
73-
else
74-
echo "Successfully installed boost v${BOOST_VERSION//_/.}"
75-
fi
76-
else
77-
echo "Already installed boost version ${BOOST_VERSION//_/.}"
78-
DESIRED_BOOST_VERSION=${BOOST_VERSION//_/.}
79-
# install missing packages if necessary
80-
boostlibnames=("libboost-system" "libboost-filesystem"
81-
"libboost-graph" "libboost-program-options"
82-
"libboost-log" "libboost-thread")
83-
additional_boost_libs=()
84-
85-
for boost_lib in ${boostlibnames[@]}; do
86-
dpkg -s "$boost_lib${DESIRED_BOOST_VERSION}" >/dev/null 2>&1 || additional_boost_libs+=("$boost_lib${DESIRED_BOOST_VERSION}")
87-
done
88-
if [ ${#additional_boost_libs[@]} -gt 0 ] ;then
89-
echo "Installing additional ${#additional_boost_libs[@]} boost packages: ${additional_boost_libs[@]}"
90-
sudo apt-get install ${additional_boost_libs[@]} -y
91-
fi
72+
BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')
73+
74+
if [ -z $BOOST_VERSION ] ;then
75+
if [ -z $DESIRED_BOOST_VERSION ] ;then
76+
sudo apt-get install libboost-all-dev -y
77+
else
78+
# DESIRED_BOOST_VERSION in form d.d, i.e. 1.65 (this is the latest version I found in the apt repo)
79+
sudo apt-get install "libboost${DESIRED_BOOST_VERSION}-all-dev" -y
80+
fi
81+
#verify installation
82+
BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')
83+
if [ -z $BOOST_VERSION ] ;then
84+
echo "Failed installing boost $DESIRED_BOOST_VERSION"
85+
exit 1
86+
else
87+
echo "Successfully installed boost v${BOOST_VERSION//_/.}"
88+
fi
89+
else
90+
echo "Already installed boost version ${BOOST_VERSION//_/.}"
91+
DESIRED_BOOST_VERSION=${BOOST_VERSION//_/.}
92+
# install missing packages if necessary
93+
boostlibnames=("libboost-system" "libboost-filesystem"
94+
"libboost-graph" "libboost-program-options"
95+
"libboost-log" "libboost-thread")
96+
additional_boost_libs=()
97+
98+
for boost_lib in ${boostlibnames[@]}; do
99+
dpkg -s "$boost_lib${DESIRED_BOOST_VERSION}" >/dev/null 2>&1 || additional_boost_libs+=("$boost_lib${DESIRED_BOOST_VERSION}")
100+
done
101+
if [ ${#additional_boost_libs[@]} -gt 0 ] ;then
102+
echo "Installing additional ${#additional_boost_libs[@]} boost packages: ${additional_boost_libs[@]}"
103+
sudo apt-get install ${additional_boost_libs[@]} -y
104+
fi
105+
fi
92106
fi
93107

94108

95109

96110
# installing LLVM
97-
./utils/install-llvm.sh $NUM_THREADS . $LLVM_RELEASE
98-
# installing wllvm
111+
tmp_dir=`mktemp -d "llvm-9_build.XXXXXXXX" --tmpdir`
112+
./utils/install-llvm.sh ${NUM_THREADS} ${tmp_dir} ${LLVM_INSTALL_DIR} ${LLVM_RELEASE}
113+
rm -rf ${tmp_dir}
99114
sudo pip3 install wllvm
100115

101116
echo "dependencies successfully installed"
102-
echo "build phasar..."
117+
echo "Building PhASAR..."
118+
${DO_UNIT_TESTS} && echo "with unit tests."
103119

104-
#git submodule init
105-
#git submodule update
120+
git submodule init
121+
git submodule update
106122

107-
export CC=/usr/local/bin/clang
108-
export CXX=/usr/local/bin/clang++
123+
export CC=${LLVM_INSTALL_DIR}/bin/clang
124+
export CXX=${LLVM_INSTALL_DIR}/bin/clang++
109125

110-
mkdir -p build
111-
cd build
112-
cmake -DCMAKE_BUILD_TYPE=Release ..
126+
mkdir -p ${PHASAR_DIR}/build
127+
cd ${PHASAR_DIR}/build
128+
cmake -DCMAKE_BUILD_TYPE=Release ${BOOST_PARAMS} -DPHASAR_BUILD_UNITTESTS=${DO_UNIT_TEST} ${PHASAR_DIR}
113129
make -j $NUM_THREADS
130+
131+
if ${DO_UNIT_TEST}; then
132+
echo "Running PhASAR unit tests..."
133+
pushd unittests
134+
for x in `find . -type f -executable -print`; do
135+
pushd ${x%/*} && ./${x##*/} && popd || { echo "Test ${x} failed, aborting."; exit 1; };
136+
done
137+
popd
138+
fi
139+
114140
echo "phasar successfully built"
115141
echo "install phasar..."
116-
sudo make install
142+
sudo cmake -DCMAKE_INSTALL_PREFIX=${PHASAR_INSTALL_DIR} -P cmake_install.cmake
143+
117144
sudo ldconfig
118145
cd ..
119-
echo "phasar successfully installed"
146+
echo "phasar successfully installed to ${PHASAR_INSTALL_DIR}"

cmake/phasar_macros.cmake

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,32 @@ function(generate_ll_file)
8787
# define compilation flags
8888
set(GEN_CXX_FLAGS -std=c++14 -fno-discard-value-names -emit-llvm -S)
8989
set(GEN_C_FLAGS -fno-discard-value-names -emit-llvm -S)
90-
set(GEN_CMD_COMMENT "compile ${GEN_LL_FILE} to LLVM IR")
90+
set(GEN_CMD_COMMENT "[LL]")
9191
if(GEN_LL_MEM2REG)
9292
list(APPEND GEN_CXX_FLAGS -Xclang -disable-O0-optnone)
9393
list(APPEND GEN_C_FLAGS -Xclang -disable-O0-optnone)
94-
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT} with mem2reg optimization")
94+
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT}[M2R]")
9595
endif()
9696
if(GEN_LL_DEBUG)
9797
list(APPEND GEN_CXX_FLAGS -g)
9898
list(APPEND GEN_C_FLAGS -g)
99-
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT} with/and debug information")
99+
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT}[DBG]")
100100
endif()
101+
set(GEN_CMD_COMMENT "${GEN_CMD_COMMENT} ${GEN_LL_FILE}")
101102

102103
# define .ll file generation command
103104
if(${test_code_file_ext} STREQUAL ".cpp")
104-
set(GEN_CMD ${CMAKE_CXX_COMPILER})
105+
set(GEN_CMD ${CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER})
105106
list(APPEND GEN_CMD ${GEN_CXX_FLAGS})
106107
else()
107-
set(GEN_CMD ${CMAKE_C_COMPILER})
108+
set(GEN_CMD ${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER})
108109
list(APPEND GEN_CMD ${GEN_C_FLAGS})
109110
endif()
110111
if(GEN_LL_MEM2REG)
111112
add_custom_command(
112113
OUTPUT ${test_code_ll_file}
113114
COMMAND ${GEN_CMD} ${test_code_file_path} -o ${test_code_ll_file}
114-
COMMAND opt -mem2reg -S ${test_code_ll_file} -o ${test_code_ll_file}
115+
COMMAND ${CMAKE_CXX_COMPILER_LAUNCHER} opt -mem2reg -S ${test_code_ll_file} -o ${test_code_ll_file}
115116
COMMENT ${GEN_CMD_COMMENT}
116117
DEPENDS ${GEN_LL_FILE}
117118
VERBATIM

include/phasar/Controller/AnalysisConfigurations.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ ANALYSIS_CONFIGURATIONS("IFDSUninitializedVariables", "ifds-uninit", IFDSUniniti
1515
ANALYSIS_CONFIGURATIONS("IFDSConstAnalysis", "ifds-const", IFDSConstAnalysis)
1616
ANALYSIS_CONFIGURATIONS("IFDSTaintAnalysis", "ifds-taint", IFDSTaintAnalysis)
1717
ANALYSIS_CONFIGURATIONS("IDETaintAnalysis", "ide-taint", IDETaintAnalysis)
18-
ANALYSIS_CONFIGURATIONS("IDETypeStateAnalysis", "ide-ts", IDETypeStateAnalysis)
18+
ANALYSIS_CONFIGURATIONS("IDECSTDIOTypeStateAnalysis", "ide-stdio-ts", IDECSTDIOTypeStateAnalysis)
19+
ANALYSIS_CONFIGURATIONS("IDEOpenSSLTypeStateAnalysis", "ide-openssl-ts", IDEOpenSSLTypeStateAnalysis)
1920
ANALYSIS_CONFIGURATIONS("IFDSTypeAnalysis", "ifds-ts", IFDSTypeAnalysis)
2021
ANALYSIS_CONFIGURATIONS("IFDSSolverTest", "ifds-solvertest", IFDSSolverTest)
2122
ANALYSIS_CONFIGURATIONS("IFDSLinearConstantAnalysis", "ifds-lca", IFDSLinearConstantAnalysis)

0 commit comments

Comments
 (0)