mariadb/storage/rocksdb/CMakeLists.txt

312 lines
9.4 KiB
Text
Raw Permalink Normal View History

# TODO: Copyrights
IF(PLUGIN_ROCKSDB STREQUAL "NO")
ADD_FEATURE_INFO(ROCKSDB "OFF" "Storage Engine")
RETURN()
ENDIF()
SET(CPACK_RPM_rocksdb-engine_PACKAGE_SUMMARY "RocksDB storage engine for MariaDB server" PARENT_SCOPE)
SET(CPACK_RPM_rocksdb-engine_PACKAGE_DESCRIPTION "The RocksDB storage engine is a high performance storage engine, aimed
at maximising storage efficiency while maintaining InnoDB-like performance." PARENT_SCOPE)
MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-range-loop-construct)
2024-08-01 09:01:46 +02:00
MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-invalid-offsetof)
MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-effc++ DEBUG RELWITHDEBINFO)
MACRO(SKIP_ROCKSDB_PLUGIN msg)
MESSAGE_ONCE(SKIP_ROCKSDB_PLUGIN "Can't build rocksdb engine - ${msg}")
ADD_FEATURE_INFO(ROCKSDB "OFF" "Storage Engine")
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()
ADD_DEFINITIONS(-Duint64_t=u_int64_t)
ADD_DEFINITIONS(-Duint32_t=u_int32_t)
ADD_DEFINITIONS(-Duint16_t=u_int16_t)
ADD_DEFINITIONS(-Duint8_t=u_int8_t)
# 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()
IF(MSVC_ARM64)
SKIP_ROCKSDB_PLUGIN("Windows ARM64 not supported")
ENDIF()
#
# Also, disable on ARM64 when not Linux
# Requires submodule update to v6.16.3
# containing commit https://github.com/facebook/rocksdb/commit/ee4bd4780b321ddb5f92a0f4eb956f2a2ebd60dc
#
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64|aarch64)" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
SKIP_ROCKSDB_PLUGIN("ARM64 disabled on all except Linux")
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")
IF (GCC_VERSION VERSION_LESS 5.0)
2020-09-04 11:12:27 +02:00
SET(CXX11_FLAGS "-std=c++11 -Wno-missing-field-initializers")
ENDIF()
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++")
IF(MSVC)
# clang-cl does not work yet
SKIP_ROCKSDB_PLUGIN("Clang-cl is not supported")
ENDIF()
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
#)
if (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
SET(ATOMIC_EXTRA_LIBS -latomic)
else()
SET(ATOMIC_EXTRA_LIBS)
endif()
# don't use compression providers, there are standalone executables below
GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
LIST(REMOVE_ITEM dirs ${CMAKE_SOURCE_DIR}/include/providers)
SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}")
MYSQL_ADD_PLUGIN(rocksdb ${ROCKSDB_SE_SOURCES} MODULE_ONLY STORAGE_ENGINE
LINK_LIBRARIES ${ATOMIC_EXTRA_LIBS}
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()
INSTALL_MANPAGES(rocksdb-engine mariadb-ldb.1 myrocks_hotbackup.1)
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_LIBRARIES})
2022-10-23 05:08:06 +02:00
if (UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
TARGET_LINK_LIBRARIES(rocksdb_aux_lib -lrt)
endif()
TARGET_LINK_LIBRARIES(rocksdb_aux_lib ${ATOMIC_EXTRA_LIBS})
# 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()
# MariaDB: Q: why does the upstream add libunwind for a particular
# storage engine?
#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)
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
IF(HAVE_SCHED_GETCPU)
ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1)
# MariaDB: don't do this:
# 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()
2022-10-23 05:08:06 +02:00
if (UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
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(mariadb-ldb tools/mysql_ldb.cc COMPONENT rocksdb-engine)
TARGET_LINK_LIBRARIES(mariadb-ldb rocksdb_tools rocksdb_aux_lib dbug)
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(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)
# Temporarily disable "conversion from size_t .." warnings
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
ENDIF()
2019-12-27 17:20:28 +01:00
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mariadb-ldb PROPERTIES COMPILE_FLAGS "-Wno-error")
ENDIF()
IF(GIT_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/.git)
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()