-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmemkv_spp.patch
80 lines (76 loc) · 3.78 KB
/
pmemkv_spp.patch
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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2f5c7a..af9c83b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,10 @@ option(ENGINE_TREE3 "enable experimental tree3 engine" OFF)
option(ENGINE_RADIX "enable experimental radix engine" OFF)
option(ENGINE_ROBINHOOD "enable experimental robinhood engine (requires CXX_STANDARD to be set to value >= 14)" OFF)
+## SPP specific paths
+set(LLVMROOT "/llvm/" CACHE STRING "path to LLVM root directory")
+set(SPPLIBOBJ "/SPP/runtime/obj" CACHE STRING "path to SPP runtime object files")
+
# ----------------------------------------------------------------- #
## Set required and useful variables
# ----------------------------------------------------------------- #
@@ -233,7 +237,41 @@ add_common_flag(-Wsign-conversion)
add_common_flag(-ggdb DEBUG)
add_common_flag(-DDEBUG DEBUG)
-add_common_flag("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" RELEASE)
+#add_common_flag("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")
+
+# ----------------------------------------------------------------- #
+## Setup SPP flags
+# ----------------------------------------------------------------- #
+
+message(STATUS "LLVM root directory is ${LLVMROOT}")
+if(NOT(EXISTS "/llvm/lib/LLVMSPP.so"))
+ message(FATAL_ERROR "Couldn't locate SPP Pass in LLVM installation")
+endif()
+
+message(STATUS "SPP runtime library object directory is ${SPPLIBOBJ}")
+if(NOT((EXISTS "${SPPLIBOBJ}/wrappers_spp.o") AND (EXISTS "${SPPLIBOBJ}/wrappers_spp.o")))
+ message(FATAL_ERROR "Couldn't locate SPP runtime lib object files")
+endif()
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -flto -Xclang -load -Xclang /llvm/lib/LLVMSPP.so")
+
+set(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")
+
+set(BUILD_EXEC_FLAGS "${WRAP_LIST} ${SPPLIBOBJ}/wrappers_spp.o -Xlinker ${SPPLIBOBJ}/spp.o")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${BUILD_EXEC_FLAGS}")
# ----------------------------------------------------------------- #
## Setup environment, find packages,
@@ -278,7 +316,7 @@ string(REPLACE ";" ", " DEB_PACKAGE_REQUIRES "${DEB_DEPENDS}")
# ----------------------------------------------------------------- #
## Link libraries, setup targets
# ----------------------------------------------------------------- #
-add_library(pmemkv SHARED ${SOURCE_FILES})
+add_library(pmemkv STATIC ${SOURCE_FILES})
set_target_properties(pmemkv PROPERTIES SOVERSION 1)
target_link_libraries(pmemkv PRIVATE
-Wl,--version-script=${PMEMKV_ROOT_DIR}/src/libpmemkv.map)
diff --git a/src/engines/cmap.cc b/src/engines/cmap.cc
index 01b10d1..0946f6a 100644
--- a/src/engines/cmap.cc
+++ b/src/engines/cmap.cc
@@ -14,7 +14,7 @@ namespace kv
cmap::cmap(std::unique_ptr<internal::config> cfg) : pmemobj_engine_base(cfg, "pmemkv")
{
static_assert(
- sizeof(internal::cmap::string_t) == 40,
+ sizeof(internal::cmap::string_t) == 40 || sizeof(internal::cmap::string_t) == 48,
"Wrong size of cmap value and key. This probably means that std::string has size > 32");
LOG("Started ok");