2016-10-06 19:24:09 +02:00
|
|
|
# TODO: Copyrights
|
2017-03-25 19:18:06 +01:00
|
|
|
|
|
|
|
MACRO(SKIP_ROCKSDB_PLUGIN msg)
|
|
|
|
MESSAGE_ONCE(SKIP_ROCKSDB_PLUGIN "Can't build rocksdb engine - ${msg}")
|
2017-08-09 21:39:18 +02:00
|
|
|
ADD_FEATURE_INFO(ROCKSDB "OFF" "Storage Engine")
|
2017-03-25 19:18:06 +01:00
|
|
|
RETURN()
|
|
|
|
ENDMACRO()
|
|
|
|
|
2019-04-07 00:52:05 +02:00
|
|
|
IF (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/CMakeLists.txt")
|
|
|
|
SKIP_ROCKSDB_PLUGIN("Missing CMakeLists.txt in rocksdb directory. Try \"git submodule update\".")
|
2016-10-06 19:24:09 +02:00
|
|
|
ENDIF()
|
|
|
|
|
2017-11-13 22:25:30 +01:00
|
|
|
CHECK_LIBRARY_EXISTS(rt timer_delete "" HAVE_TIMER_DELETE)
|
|
|
|
IF (HAVE_TIMER_DELETE)
|
|
|
|
ADD_DEFINITIONS(-DHAVE_TIMER_DELETE)
|
|
|
|
ENDIF(HAVE_TIMER_DELETE)
|
|
|
|
|
2016-12-31 21:30:09 +01:00
|
|
|
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
|
|
|
|
IF(HAVE_SCHED_GETCPU)
|
2017-07-28 19:52:07 +02:00
|
|
|
ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1 -DROCKSDB_SCHED_GETCPU_PRESENT)
|
2016-12-31 21:30:09 +01:00
|
|
|
ENDIF()
|
|
|
|
|
2018-05-22 18:36:51 +02:00
|
|
|
IF(WITH_VALGRIND)
|
|
|
|
ADD_DEFINITIONS(-DROCKSDB_VALGRIND_RUN=1)
|
|
|
|
ENDIF()
|
2016-10-06 19:24:09 +02:00
|
|
|
|
2017-03-14 00:01:11 +01:00
|
|
|
# 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()
|
2017-02-01 22:27:13 +01:00
|
|
|
|
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()
|
|
|
|
|
2017-04-04 16:46:56 +02:00
|
|
|
#
|
|
|
|
# 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()
|
|
|
|
|
2021-08-25 08:53:39 +02:00
|
|
|
#
|
|
|
|
# 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()
|
|
|
|
|
2017-02-01 22:27:13 +01:00
|
|
|
# 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")
|
2020-09-03 17:26:55 +02:00
|
|
|
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")
|
2020-09-03 17:26:55 +02:00
|
|
|
ENDIF()
|
2017-02-01 22:27:13 +01:00
|
|
|
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()
|
2017-02-07 21:10:38 +01:00
|
|
|
SET(CXX11_FLAGS "-std=c++11 -stdlib=libstdc++")
|
2017-02-01 22:27:13 +01:00
|
|
|
ELSEIF(MSVC)
|
|
|
|
IF (MSVC_VERSION LESS 1900)
|
|
|
|
SKIP_ROCKSDB_PLUGIN("${OLD_COMPILER_MSG}")
|
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
|
|
|
SKIP_ROCKSDB_PLUGIN("Compiler not supported")
|
|
|
|
ENDIF()
|
2016-10-07 10:25:10 +02:00
|
|
|
|
2017-04-07 00:29:33 +02:00
|
|
|
IF(CMAKE_VERSION GREATER 3.0)
|
|
|
|
SET(CMAKE_CXX_STANDARD 11)
|
|
|
|
ELSEIF(CXX11_FLAGS)
|
2017-02-01 22:27:13 +01:00
|
|
|
ADD_DEFINITIONS(${CXX11_FLAGS})
|
2016-12-31 21:30:09 +01:00
|
|
|
ENDIF()
|
|
|
|
|
2017-02-01 22:27:13 +01:00
|
|
|
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
|
2017-02-01 22:27:13 +01:00
|
|
|
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
|
2017-03-11 21:00:08 +01:00
|
|
|
rdb_psi.h
|
|
|
|
rdb_psi.cc
|
2018-04-17 10:10:11 +02:00
|
|
|
rdb_sst_info.cc
|
|
|
|
rdb_sst_info.h
|
2019-06-16 14:29:04 +02:00
|
|
|
rdb_converter.cc
|
|
|
|
rdb_converter.h
|
2016-10-06 19:24:09 +02:00
|
|
|
)
|
|
|
|
|
2017-09-19 13:28:30 +02:00
|
|
|
# MariaDB: the following is added in build_rocksdb.cmake, when appropriate:
|
2017-07-28 19:52:07 +02:00
|
|
|
# This is a strong requirement coming from RocksDB. No conditional checks here.
|
2017-09-19 13:28:30 +02:00
|
|
|
#ADD_DEFINITIONS(-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX
|
|
|
|
#)
|
2020-07-02 01:39:13 +02:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
|
|
|
|
SET(ATOMIC_EXTRA_LIBS -latomic)
|
|
|
|
else()
|
|
|
|
SET(ATOMIC_EXTRA_LIBS)
|
|
|
|
endif()
|
2017-09-19 13:28:30 +02:00
|
|
|
|
2018-05-18 22:58:24 +02:00
|
|
|
MYSQL_ADD_PLUGIN(rocksdb ${ROCKSDB_SE_SOURCES} MODULE_ONLY STORAGE_ENGINE
|
2017-03-17 16:08:34 +01:00
|
|
|
MODULE_OUTPUT_NAME ha_rocksdb
|
2020-07-02 01:39:13 +02:00
|
|
|
LINK_LIBRARIES ${ATOMIC_EXTRA_LIBS}
|
2017-03-17 16:08:34 +01:00
|
|
|
COMPONENT rocksdb-engine)
|
2016-10-06 19:24:09 +02:00
|
|
|
|
2017-04-02 20:22:22 +02:00
|
|
|
IF(NOT TARGET rocksdb)
|
2017-02-01 22:27:13 +01:00
|
|
|
# Bail out if compilation with rocksdb engine is not requested
|
|
|
|
RETURN()
|
|
|
|
ENDIF()
|
|
|
|
|
2017-09-18 13:06:01 +02:00
|
|
|
|
2017-03-11 05:17:42 +01:00
|
|
|
|
2017-07-28 19:52:07 +02:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
#if defined(_MSC_VER) && !defined(__thread)
|
|
|
|
#define __thread __declspec(thread)
|
|
|
|
#endif
|
|
|
|
int main() {
|
|
|
|
static __thread int tls;
|
2019-05-16 16:27:28 +02:00
|
|
|
tls=0;
|
|
|
|
return tls;
|
2017-07-28 19:52:07 +02:00
|
|
|
}
|
|
|
|
" HAVE_THREAD_LOCAL)
|
|
|
|
if(HAVE_THREAD_LOCAL)
|
|
|
|
ADD_DEFINITIONS(-DROCKSDB_SUPPORT_THREAD_LOCAL)
|
2019-05-16 16:27:28 +02:00
|
|
|
else()
|
|
|
|
MESSAGE(SEND_ERROR "The compiler failed the check for ROCKSDB_SUPPORT_THREAD_LOCAL. "
|
|
|
|
"MyRocks requires that feature.")
|
2017-07-28 19:52:07 +02:00
|
|
|
endif()
|
|
|
|
|
2017-02-01 22:27:13 +01:00
|
|
|
INCLUDE(build_rocksdb.cmake)
|
|
|
|
|
|
|
|
ADD_CONVENIENCE_LIBRARY(rocksdb_aux_lib
|
2016-12-04 21:55:54 +01:00
|
|
|
ha_rocksdb_proto.h
|
2016-10-06 19:24:09 +02:00
|
|
|
logger.h
|
|
|
|
rdb_comparator.h
|
2017-02-01 22:27:13 +01:00
|
|
|
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
|
2017-03-11 21:00:08 +01:00
|
|
|
rdb_mariadb_port.h
|
2019-06-15 20:29:46 +02:00
|
|
|
nosql_access.cc nosql_access.h
|
2016-10-06 19:24:09 +02:00
|
|
|
)
|
2017-02-01 22:27:13 +01:00
|
|
|
|
|
|
|
ADD_DEPENDENCIES(rocksdb_aux_lib GenError)
|
|
|
|
|
2017-07-29 12:06:09 +02:00
|
|
|
# MARIAROCKS-TODO: how to properly depend on -lrt ?
|
2017-02-01 22:27:13 +01:00
|
|
|
TARGET_LINK_LIBRARIES(rocksdb_aux_lib rocksdblib ${ZLIB_LIBRARY})
|
2017-09-05 19:30:59 +02:00
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
TARGET_LINK_LIBRARIES(rocksdb_aux_lib -lrt)
|
|
|
|
endif()
|
2020-07-02 01:39:13 +02:00
|
|
|
TARGET_LINK_LIBRARIES(rocksdb_aux_lib ${ATOMIC_EXTRA_LIBS})
|
2017-07-29 12:06:09 +02:00
|
|
|
|
2019-06-16 20:44:02 +02:00
|
|
|
# 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()
|
2019-06-15 20:29:46 +02:00
|
|
|
|
2016-10-06 19:24:09 +02:00
|
|
|
|
2017-04-02 20:22:22 +02:00
|
|
|
TARGET_LINK_LIBRARIES(rocksdb rocksdb_aux_lib)
|
2018-08-28 10:23:44 +02:00
|
|
|
FIND_LIBRARY(LZ4_LIBRARY
|
|
|
|
NAMES liblz4${PIC_EXT}.a lz4
|
|
|
|
HINTS ${WITH_LZ4}/lib)
|
2017-02-01 22:27:13 +01:00
|
|
|
|
2017-02-07 21:10:38 +01:00
|
|
|
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
|
2017-02-01 22:27:13 +01:00
|
|
|
# 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)
|
2017-10-11 18:21:09 +02:00
|
|
|
set_source_files_properties(event_listener.cc rdb_cf_options.cc rdb_sst_info.cc
|
2017-02-01 22:27:13 +01:00
|
|
|
PROPERTIES COMPILE_FLAGS -frtti)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
|
|
|
|
IF(HAVE_SCHED_GETCPU)
|
|
|
|
ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU=1)
|
2019-06-16 20:44:02 +02:00
|
|
|
# MariaDB: don't do this:
|
|
|
|
# ADD_DEFINITIONS(-DZSTD_STATIC_LINKING_ONLY)
|
2017-02-01 22:27:13 +01:00
|
|
|
ENDIF()
|
2016-10-06 19:24:09 +02:00
|
|
|
|
2018-01-27 11:18:20 +01:00
|
|
|
IF (WITH_TBB)
|
2018-08-28 10:23:44 +02:00
|
|
|
FIND_LIBRARY(TBB_LIBRARY
|
|
|
|
NAMES libtbb${PIC_EXT}.a tbb
|
|
|
|
HINTS ${WITH_TBB}/lib)
|
2017-09-15 12:04:49 +02:00
|
|
|
SET(rocksdb_static_libs ${rocksdb_static_libs}
|
2018-08-28 10:23:44 +02:00
|
|
|
${TBB_LIBRARY})
|
2017-09-15 12:04:49 +02:00
|
|
|
ADD_DEFINITIONS(-DTBB)
|
|
|
|
ENDIF()
|
|
|
|
|
2017-04-03 09:29:40 +02:00
|
|
|
#
|
|
|
|
# MariaDB: Dynamic plugin build is not suitable with unittest ATM
|
|
|
|
#
|
|
|
|
#IF(WITH_UNIT_TESTS AND WITH_EMBEDDED_SERVER)
|
|
|
|
# ADD_SUBDIRECTORY(unittest)
|
|
|
|
#ENDIF()
|
2016-12-31 23:50:17 +01:00
|
|
|
|
2017-09-05 19:30:59 +02:00
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
SET(rocksdb_static_libs ${rocksdb_static_libs} "-lrt")
|
|
|
|
endif()
|
2017-07-28 19:52:07 +02:00
|
|
|
|
2016-10-06 19:24:09 +02:00
|
|
|
|
2017-02-01 22:27:13 +01:00
|
|
|
ADD_LIBRARY(rocksdb_tools STATIC
|
|
|
|
rocksdb/tools/ldb_tool.cc
|
|
|
|
rocksdb/tools/ldb_cmd.cc
|
|
|
|
rocksdb/tools/sst_dump_tool.cc
|
2016-12-04 21:55:54 +01:00
|
|
|
)
|
|
|
|
|
2017-03-26 16:30:26 +02:00
|
|
|
MYSQL_ADD_EXECUTABLE(sst_dump rocksdb/tools/sst_dump.cc COMPONENT rocksdb-engine)
|
2017-02-01 22:27:13 +01:00
|
|
|
TARGET_LINK_LIBRARIES(sst_dump rocksdblib)
|
|
|
|
|
2017-03-26 16:30:26 +02:00
|
|
|
MYSQL_ADD_EXECUTABLE(mysql_ldb tools/mysql_ldb.cc COMPONENT rocksdb-engine)
|
2017-02-01 22:27:13 +01:00
|
|
|
TARGET_LINK_LIBRARIES(mysql_ldb rocksdb_tools rocksdb_aux_lib)
|
|
|
|
|
2019-01-02 19:33:52 +01:00
|
|
|
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)
|
2018-02-07 13:32:58 +01:00
|
|
|
|
2017-02-07 21:10:38 +01:00
|
|
|
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2019-12-17 16:06:15 +01:00
|
|
|
SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mysql_ldb PROPERTIES COMPILE_FLAGS "-frtti -Wno-error")
|
2017-02-01 22:27:13 +01:00
|
|
|
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)
|
2016-10-06 19:24:09 +02:00
|
|
|
ENDIF()
|
2017-12-31 15:18:39 +01:00
|
|
|
|
|
|
|
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()
|