summaryrefslogtreecommitdiffstats
path: root/cmake/modules/BuildRocksDB.cmake
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2017-10-26 12:26:24 +0200
committerKefu Chai <kchai@redhat.com>2017-10-27 05:13:15 +0200
commit16f0a67d83e0254fc1db6b985cb028de14d8e80d (patch)
tree001293ea1c7ad4f1d959690c0c29cc6ce8359b25 /cmake/modules/BuildRocksDB.cmake
parentMerge pull request #18524 from liewegas/wip-backfill-rops (diff)
downloadceph-16f0a67d83e0254fc1db6b985cb028de14d8e80d.tar.xz
ceph-16f0a67d83e0254fc1db6b985cb028de14d8e80d.zip
cmake: check for aligned_alloc()
in case developer is using patched tcmalloc. Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'cmake/modules/BuildRocksDB.cmake')
-rw-r--r--cmake/modules/BuildRocksDB.cmake39
1 files changed, 34 insertions, 5 deletions
diff --git a/cmake/modules/BuildRocksDB.cmake b/cmake/modules/BuildRocksDB.cmake
index 108db6b6da8..da6e18d04e0 100644
--- a/cmake/modules/BuildRocksDB.cmake
+++ b/cmake/modules/BuildRocksDB.cmake
@@ -1,3 +1,5 @@
+include(CheckCXXSourceCompiles)
+
function(do_build_rocksdb)
set(ROCKSDB_CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
@@ -38,6 +40,37 @@ function(do_build_rocksdb)
ALWAYS 1)
endfunction()
+function(check_aligned_alloc)
+ set(SAVE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "-std=c++11 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -nostdlib")
+ if(LINUX)
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE")
+ endif()
+ set(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ set(CMAKE_REQUIRED_LIBRARIES ${GPERFTOOLS_TCMALLOC_LIBRARY})
+ CHECK_CXX_SOURCE_COMPILES("
+#include <stdlib.h>
+
+int main()
+{
+#if defined(_ISOC11_SOURCE)
+ void* buf = aligned_alloc(64, 42);
+ free(buf);
+#endif
+}
+" HAVE_ALIGNED_ALLOC)
+ set(CMAKE_REQUIRED_FLAGS ${SAVE_CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
+
+ if(NOT HAVE_ALIGNED_ALLOC)
+ message(SEND_ERROR
+ "Incompatible tcmalloc v${TCMALLOC_VERSION_STRING} and rocksdb "
+ "v${ROCKSDB_VERSION_STRING}, please install gperf-tools 2.5 (not 2.5.93) "
+ "or >= 2.6.2, or switch to another allocator using "
+ "'cmake -DALLOCATOR=libc'.")
+ endif()
+endfunction()
+
macro(build_rocksdb)
do_build_rocksdb()
add_library(rocksdb STATIC IMPORTED)
@@ -60,11 +93,7 @@ macro(build_rocksdb)
if(ROCKSDB_VERSION_STRING VERSION_GREATER 5.7 AND
TCMALLOC_VERSION_STRING VERSION_GREATER 2.5 AND
TCMALLOC_VERSION_STRING VERSION_LESS 2.6.2)
- message(SEND_ERROR
- "Incompatible tcmalloc v${TCMALLOC_VERSION_STRING} and rocksdb "
- "v${ROCKSDB_VERSION_STRING}, please install gperf-tools 2.5 (not 2.5.93) "
- "or >= 2.6.2, or switch to another allocator using "
- "'cmake -DALLOCATOR=libc'.")
+ check_aligned_alloc()
endif()
endif()
endmacro()