Skip to content

Commit fc0147f

Browse files
authored
Make the sqlite3-dependency optional (#711)
1 parent 331c4b7 commit fc0147f

21 files changed

Lines changed: 74 additions & 76 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,12 @@ else()
293293
endif()
294294

295295
# SQL
296-
find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)
297-
find_library(SQLITE3_LIBRARY NAMES sqlite3)
296+
find_package(SQLite3)
297+
if(SQLite3_FOUND)
298+
set(PHASAR_HAS_SQLITE ON)
299+
else()
300+
set(PHASAR_HAS_SQLITE OFF)
301+
endif()
298302

299303
option(USE_LLVM_FAT_LIB "Link against libLLVM.so instead of the individual LLVM libraries if possible (default is OFF; always on if BUILD_SHARED_LIBS is ON)" OFF)
300304

bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters
108108

109109
echo "installing phasar dependencies..."
110110
if [ -x "$(command -v pacman)" ]; then
111-
yes | sudo pacman -Syu --needed which zlib sqlite3 python3 doxygen gcc python-pip ninja cmake
111+
yes | sudo pacman -Syu --needed which zlib python3 doxygen gcc ninja cmake
112112
else
113113
./utils/InstallAptDependencies.sh
114114
fi

config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
#cmakedefine DYNAMIC_LOG
1010
#cmakedefine BUILD_PHASAR_CLANG
1111

12+
#cmakedefine PHASAR_HAS_SQLITE
13+
1214
#endif /* PHASAR_CONFIG_CONFIG_H */

include/phasar/DB.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
#ifndef PHASAR_DB_H
1111
#define PHASAR_DB_H
1212

13-
#include "phasar/DB/Hexastore.h"
13+
#include "phasar/Config/phasar-config.h"
1414
#include "phasar/DB/ProjectIRDBBase.h"
15+
16+
#ifdef PHASAR_HAS_SQLITE
17+
#include "phasar/DB/Hexastore.h"
1518
#include "phasar/DB/Queries.h"
19+
#endif
1620

1721
#endif // PHASAR_DB_H

include/phasar/DB/Hexastore.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
#ifndef PHASAR_DB_HEXASTORE_H_
1111
#define PHASAR_DB_HEXASTORE_H_
1212

13-
#include "phasar/DB/Queries.h"
13+
#include "phasar/Config/phasar-config.h"
14+
#ifndef PHASAR_HAS_SQLITE
15+
#error \
16+
"Hexastore requires SQLite3. Please install libsqlite3-dev and reconfigure PhASAR."
17+
#endif
1418

1519
#include "llvm/Support/raw_ostream.h"
1620

17-
#include "boost/format.hpp"
18-
#include "sqlite3.h"
19-
2021
#include <array>
2122
#include <string>
2223
#include <vector>
2324

25+
struct sqlite3;
26+
2427
namespace psr {
2528
/**
2629
* @brief Holds the results of a query to the Hexastore.
@@ -51,6 +54,7 @@ struct HSResult {
5154
LHS.Object == RHS.Object;
5255
}
5356
};
57+
5458
/**
5559
* A Hexastore is an efficient approach to store large graphs.
5660
* This approach is based on the paper "Database-Backed Program Analysis

include/phasar/DataFlow/Mono/Solver/InterMonoSolver.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <unordered_map>
2525
#include <unordered_set>
2626
#include <utility>
27-
#include <vector>
2827

2928
namespace psr {
3029

@@ -368,18 +367,8 @@ template <typename AnalysisDomainTy, unsigned K> class InterMonoSolver {
368367
}
369368
// Compute the data-flow facts using the respective kind of flows
370369
if (ICF->isCallSite(Src)) {
371-
// Handle call flow(s)
372-
if (!isIntraEdge(Edge)) {
373-
// real call
374-
for (auto &[Ctx, Facts] : Analysis[Src]) {
375-
processCall(Edge); // TODO: decompose into processCall and
376-
// processCallToRet
377-
}
378-
} else {
379-
// call-to-return
380-
processCall(
381-
Edge); // TODO: decompose into processCall and processCallToRet
382-
}
370+
// Handle call flow(s) and call-to-return flow
371+
processCall(Edge);
383372
} else if (ICF->isExitInst(Src)) {
384373
// Handle return flow
385374
processExit(Edge);

lib/AnalysisStrategy/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ file(GLOB_RECURSE ANALYSIS_STRATEGY_SRC *.h *.cpp)
22

33
add_phasar_library(phasar_analysis_strategy
44
${ANALYSIS_STRATEGY_SRC}
5-
LINKS phasar_db phasar_controlflow
65
LLVM_LINK_COMPONENTS Support
76
)

lib/CMakeLists.txt

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,35 @@ if(PHASAR_BUILD_DYNLIB)
1818
set(PHASAR_DYNLIB_KIND SHARED)
1919
endif()
2020

21+
set(PHASAR_LINK_LIBS
22+
phasar_utils
23+
phasar_passes
24+
phasar_config
25+
phasar_pointer
26+
phasar_controlflow
27+
28+
phasar_llvm_utils
29+
phasar_llvm_db
30+
phasar_llvm_pointer
31+
phasar_llvm_typehierarchy
32+
phasar_llvm_controlflow
33+
34+
phasar_taintconfig
35+
phasar_mono
36+
phasar_llvm
37+
phasar_llvm_ifdside
38+
phasar_analysis_strategy
39+
phasar_controller
40+
)
41+
if(SQLite3_FOUND)
42+
list(APPEND PHASAR_LINK_LIBS phasar_db)
43+
endif()
44+
2145
add_phasar_library(phasar ${PHASAR_DYNLIB_KIND}
2246
FILES
2347
LibPhasar.cpp
2448
LINKS
25-
phasar_utils
26-
phasar_passes
27-
phasar_config
28-
phasar_db
29-
phasar_pointer
30-
phasar_controlflow
31-
32-
phasar_llvm_utils
33-
phasar_llvm_db
34-
phasar_llvm_pointer
35-
phasar_llvm_typehierarchy
36-
phasar_llvm_controlflow
37-
38-
phasar_taintconfig
39-
phasar_mono
40-
phasar_llvm
41-
phasar_llvm_ifdside
42-
phasar_analysis_strategy
43-
phasar_controller
49+
${PHASAR_LINK_LIBS}
4450
LINK_PRIVATE
4551
${Boost_LIBRARIES}
4652
LLVM_LINK_COMPONENTS

lib/Controller/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ add_phasar_library(phasar_controller
1515
phasar_utils
1616
phasar_analysis_strategy
1717
phasar_taintconfig
18+
phasar_passes
1819

1920
LLVM_LINK_COMPONENTS
2021
Core

lib/DB/CMakeLists.txt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
file(GLOB_RECURSE DB_SRC *.h *.cpp)
1+
if(SQLite3_FOUND)
2+
file(GLOB_RECURSE DB_SRC *.h *.cpp)
23

3-
add_phasar_library(phasar_db
4-
${DB_SRC}
5-
LINKS phasar_passes phasar_utils
6-
LLVM_LINK_COMPONENTS Support
7-
LINK_PRIVATE ${SQLITE3_LIBRARY}
8-
)
9-
10-
target_include_directories(phasar_db
11-
PRIVATE ${SQLITE3_INCLUDE_DIR}
12-
)
4+
add_phasar_library(phasar_db
5+
${DB_SRC}
6+
LINKS phasar_passes phasar_utils
7+
LLVM_LINK_COMPONENTS Support
8+
LINK_PRIVATE SQLite::SQLite3
9+
)
10+
endif()

0 commit comments

Comments
 (0)