mariadb/storage/rocksdb/CMakeLists.txt

279 lines
8 KiB
Text
Raw Normal View History

# TODO: Copyrights
MACRO(SKIP_ROCKSDB_PLUGIN msg)
MESSAGE_ONCE(SKIP_ROCKSDB_PLUGIN "Can't build rocksdb engine - ${msg}")
RETURN()
ENDMACRO()
IF (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/CMakeLists.txt")
SKIP_ROCKSDB_PLUGIN("Missing CMakeLists.txt in rocksdb directory. Try \"git submodule update\".")
ENDIF()
CHECK_LIBRARY_EXISTS(rt timer_delete "" HAVE_TIMER_DELETE)
IF (HAVE_TIMER_DELETE)
ADD_DEFINITIONS(-DHAVE_TIMER_DELETE)
ENDIF(HAVE_TIMER_DELETE)
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
IF(HAVE_SCHED_GETCPU)
ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1 -DROCKSDB_SCHED_GETCPU_PRESENT)
ENDIF()
IF(WITH_VALGRIND)
ADD_DEFINITIONS(-DROCKSDB_VALGRIND_RUN=1)
ENDIF()
# We've had our builders hang during the build process. This prevents MariaRocks
# to be built on 32 bit intel OS kernels.
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i[36]86")
SKIP_ROCKSDB_PLUGIN("Intel 32 bit not supported.")
ENDIF()
MDEV-12469: rocksdb having large numberic storage errors on ppc64 (BE) (from: http://buildbot.askmonty.org/buildbot/builders/p8-rhel6-bintar/builds/820/steps/test/logs/stdio) Errors like the following indicate a potential endian storage issue: rocksdb.rocksdb_range w1 [ fail ] Test ended at 2017-04-27 18:56:11 CURRENT_TEST: rocksdb.rocksdb_range --- /home/buildbot/maria-slave/p8-rhel6-bintar/build/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range.result 2017-04-27 17:41:27.740050347 -0400 +++ /home/buildbot/maria-slave/p8-rhel6-bintar/build/storage/rocksdb/mysql-test/rocksdb/r/rocksdb_range.reject 2017-04-27 18:56:11.230050346 -0400 @@ -25,15 +25,15 @@ select * from t2 force index (a) where a=0; pk a b 0 0 0 -1 0 1 -2 0 2 -3 0 3 -4 0 4 -5 0 5 -6 0 6 -7 0 7 -8 0 8 -9 0 9 +16777216 0 1 +33554432 0 2 +50331648 0 3 +67108864 0 4 +83886080 0 5 +100663296 0 6 +117440512 0 7 +134217728 0 8 +150994944 0 9 # The rest are for code coverage: explain select * from t2 force index (a) where a=2; @@ -41,23 +41,23 @@ 1 SIMPLE t2 ref a a 4 const # select * from t2 force index (a) where a=2; pk a b -20 2 20 -21 2 21 -22 2 22 -23 2 23 -24 2 24 -25 2 25 -26 2 26 -27 2 27 -28 2 28 -29 2 29 +335544320 2 20 +352321536 2 21 +369098752 2 22 +385875968 2 23 +402653184 2 24 +419430400 2 25 +436207616 2 26 +452984832 2 27 +469762048 2 28 +486539264 2 29 explain select * from t2 force index (a) where a=3 and pk=33; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 const a a 8 const,const # select * from t2 force index (a) where a=3 and pk=33; pk a b -33 3 33 +553648128 3 33 select * from t2 force index (a) where a=99 and pk=99; pk a b select * from t2 force index (a) where a=0 and pk=0; ... Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2017-04-28 04:25:52 +02:00
# Due to retrieved data being incorrect endian
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN)
SKIP_ROCKSDB_PLUGIN("Big Endian not supported.")
endif()
#
# Also, disable building on 32-bit Windows
#
IF (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
SKIP_ROCKSDB_PLUGIN("32-Bit Windows are temporarily disabled")
ENDIF()
# This plugin needs recent C++ compilers (it is using C++11 features)
# Skip build for the old compilers
SET(CXX11_FLAGS)
SET(OLD_COMPILER_MSG "requires c++11 -capable compiler (minimal supported versions are g++ 4.8, clang 3.3, VS2015)")
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
IF (GCC_VERSION VERSION_LESS 4.8)
SKIP_ROCKSDB_PLUGIN("${OLD_COMPILER_MSG}")
ENDIF()
SET(CXX11_FLAGS "-std=c++11")
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
IF ((CMAKE_CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3) OR
(CLANG_VERSION_STRING AND CLANG_VERSION_STRING VERSION_LESS 3.3))
SKIP_ROCKSDB_PLUGIN("${OLD_COMPILER_MSG}")
ENDIF()
SET(CXX11_FLAGS "-std=c++11 -stdlib=libstdc++")
ELSEIF(MSVC)
IF (MSVC_VERSION LESS 1900)
SKIP_ROCKSDB_PLUGIN("${OLD_COMPILER_MSG}")
ENDIF()
ELSE()
SKIP_ROCKSDB_PLUGIN("Compiler not supported")
ENDIF()
IF(CMAKE_VERSION GREATER 3.0)
SET(CMAKE_CXX_STANDARD 11)
ELSEIF(CXX11_FLAGS)
ADD_DEFINITIONS(${CXX11_FLAGS})
ENDIF()
SET(ROCKSDB_SE_SOURCES
rdb_mariadb_server_port.cc
rdb_mariadb_server_port.h
ha_rocksdb.cc
ha_rocksdb.h
rdb_i_s.cc
rdb_i_s.h
2017-09-19 15:15:08 +02:00
rdb_io_watchdog.h
rdb_io_watchdog.cc
rdb_mutex_wrapper.cc
rdb_mutex_wrapper.h
rdb_index_merge.cc
rdb_index_merge.h
properties_collector.cc
properties_collector.h
rdb_datadic.cc
rdb_datadic.h
rdb_cf_manager.cc
rdb_cf_manager.h
rdb_utils.cc rdb_utils.h
rdb_threads.cc
rdb_threads.h
rdb_psi.h
rdb_psi.cc
rdb_sst_info.cc
rdb_sst_info.h
rdb_converter.cc
rdb_converter.h
)
# MariaDB: the following is added in build_rocksdb.cmake, when appropriate:
# This is a strong requirement coming from RocksDB. No conditional checks here.
#ADD_DEFINITIONS(-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX
#)
MYSQL_ADD_PLUGIN(rocksdb ${ROCKSDB_SE_SOURCES} MODULE_ONLY STORAGE_ENGINE
MODULE_OUTPUT_NAME ha_rocksdb
COMPONENT rocksdb-engine)
2017-04-02 20:22:22 +02:00
IF(NOT TARGET rocksdb)
# Bail out if compilation with rocksdb engine is not requested
RETURN()
ENDIF()
CHECK_CXX_SOURCE_COMPILES("
#if defined(_MSC_VER) && !defined(__thread)
#define __thread __declspec(thread)
#endif
int main() {
static __thread int tls;
tls=0;
return tls;
}
" HAVE_THREAD_LOCAL)
if(HAVE_THREAD_LOCAL)
ADD_DEFINITIONS(-DROCKSDB_SUPPORT_THREAD_LOCAL)
else()
MESSAGE(SEND_ERROR "The compiler failed the check for ROCKSDB_SUPPORT_THREAD_LOCAL. "
"MyRocks requires that feature.")
endif()
INCLUDE(build_rocksdb.cmake)
ADD_CONVENIENCE_LIBRARY(rocksdb_aux_lib
ha_rocksdb_proto.h
logger.h
rdb_comparator.h
rdb_cf_options.cc
rdb_cf_options.h
event_listener.cc
event_listener.h
rdb_perf_context.cc
rdb_perf_context.h
rdb_buff.h
rdb_mariadb_port.h
nosql_access.cc nosql_access.h
)
ADD_DEPENDENCIES(rocksdb_aux_lib GenError)
# MARIAROCKS-TODO: how to properly depend on -lrt ?
TARGET_LINK_LIBRARIES(rocksdb_aux_lib rocksdblib ${ZLIB_LIBRARY})
if (UNIX AND NOT APPLE)
TARGET_LINK_LIBRARIES(rocksdb_aux_lib -lrt)
endif()
IF (WITH_JEMALLOC)
FIND_LIBRARY(JEMALLOC_LIBRARY
NAMES libjemalloc${PIC_EXT}.a jemalloc
HINTS ${WITH_JEMALLOC}/lib)
SET(rocksdb_static_libs ${rocksdb_static_libs}
${JEMALLOC_LIBRARY})
ADD_DEFINITIONS(-DROCKSDB_JEMALLOC)
ADD_DEFINITIONS(-DROCKSDB_MALLOC_USABLE_SIZE)
ENDIF()
IF (WITH_UNWIND)
FIND_LIBRARY(UNWIND_LIBRARY
NAMES libunwind${PIC_EXT}.a unwind
HINTS ${WITH_UNWIND}/lib)
SET(rocksdb_static_libs ${rocksdb_static_libs}
${UNWIND_LIBRARY})
ENDIF()
2017-04-02 20:22:22 +02:00
TARGET_LINK_LIBRARIES(rocksdb rocksdb_aux_lib)
FIND_LIBRARY(LZ4_LIBRARY
NAMES liblz4${PIC_EXT}.a lz4
HINTS ${WITH_LZ4}/lib)
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# MARIAROCKS_NOT_YET: Add -frtti flag when compiling RocksDB files.
# TODO: is this the right way to do this?
# - SQL layer and storage/rocksdb/*.cc are compiled with -fnortti
# - RocksDB files are compiled with "-fnortti ... -frtti"
# - This causes RocksDB headers to be compiled with different settings:
# = with RTTI when compiling RocksDB
# = without RTTI when compiling storage/rocksdb/*.cc
#
# (facebook/mysql-5.6 just compiles everything without -f*rtti, which means
# everything is compiled with -frtti)
#
# (also had to add -frtti above, because something that event_listener.cc
# includes requires it. So, now everything in MariaRocks is compiled with
# -frtti)
set_source_files_properties(event_listener.cc rdb_cf_options.cc rdb_sst_info.cc
PROPERTIES COMPILE_FLAGS -frtti)
ENDIF()
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
IF(HAVE_SCHED_GETCPU)
ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1)
ADD_DEFINITIONS(-DZSTD_STATIC_LINKING_ONLY)
ENDIF()
IF (WITH_TBB)
FIND_LIBRARY(TBB_LIBRARY
NAMES libtbb${PIC_EXT}.a tbb
HINTS ${WITH_TBB}/lib)
SET(rocksdb_static_libs ${rocksdb_static_libs}
${TBB_LIBRARY})
ADD_DEFINITIONS(-DTBB)
ENDIF()
#
# MariaDB: Dynamic plugin build is not suitable with unittest ATM
#
#IF(WITH_UNIT_TESTS AND WITH_EMBEDDED_SERVER)
# ADD_SUBDIRECTORY(unittest)
#ENDIF()
if (UNIX AND NOT APPLE)
SET(rocksdb_static_libs ${rocksdb_static_libs} "-lrt")
endif()
ADD_LIBRARY(rocksdb_tools STATIC
rocksdb/tools/ldb_tool.cc
rocksdb/tools/ldb_cmd.cc
rocksdb/tools/sst_dump_tool.cc
)
MYSQL_ADD_EXECUTABLE(sst_dump rocksdb/tools/sst_dump.cc COMPONENT rocksdb-engine)
TARGET_LINK_LIBRARIES(sst_dump rocksdblib)
MYSQL_ADD_EXECUTABLE(mysql_ldb tools/mysql_ldb.cc COMPONENT rocksdb-engine)
TARGET_LINK_LIBRARIES(mysql_ldb rocksdb_tools rocksdb_aux_lib)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/myrocks_hotbackup.py
${CMAKE_CURRENT_BINARY_DIR}/myrocks_hotbackup @ONLY)
INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/myrocks_hotbackup COMPONENT rocksdb-engine)
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mysql_ldb PROPERTIES COMPILE_FLAGS -frtti)
ENDIF()
IF(MSVC)
# RocksDB, the storage engine, overdoes "const" by adding
# additional const qualifiers to parameters of the overriden virtual functions
# This creates a lot of warnings, that we silence here.
ADD_DEFINITIONS(/wd4373)
# Some checks in C++ runtime that make debug build much slower
ADD_DEFINITIONS(-D_ITERATOR_DEBUG_LEVEL=0)
ENDIF()
IF(GIT_EXECUTABLE)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb
OUTPUT_VARIABLE OUT RESULT_VARIABLE RES)
IF(RES EQUAL 0)
STRING(REGEX REPLACE "\n$" "" ROCKSDB_GIT_HASH "${OUT}")
ENDIF()
ENDIF()
IF(ROCKSDB_GIT_HASH OR
(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/rdb_source_revision.h))
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/rdb_source_revision.h.in
${CMAKE_CURRENT_BINARY_DIR}/rdb_source_revision.h )
ENDIF()