2018-08-06 09:55:02 +00:00
|
|
|
function(build_rocksdb)
|
|
|
|
set(rocksdb_CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DWITH_GFLAGS=OFF)
|
2017-09-19 03:56:15 +00:00
|
|
|
|
2020-02-05 15:01:04 +00:00
|
|
|
# cmake doesn't properly handle arguments containing ";", such as
|
|
|
|
# CMAKE_PREFIX_PATH, for which reason we'll have to use some other separator.
|
|
|
|
string(REPLACE ";" "!" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}")
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP})
|
|
|
|
if(CMAKE_TOOLCHAIN_FILE)
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS
|
2020-07-27 13:57:59 +00:00
|
|
|
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
|
2020-02-05 15:01:04 +00:00
|
|
|
endif()
|
|
|
|
|
cmake: populate liburing include and library paths down to rocksdb external project
There are two problems:
1) The librocksdb does not use the built liburing if present.
2) You cannot turn off rocksdb's use of liburing with WITH_LIBURING=OFF.
This is to fix errors like:
FAILED: bin/ceph_test_keyvaluedb_iterators
: && /opt/rh/gcc-toolset-11/root/usr/bin/g++ -Og -g -rdynamic -pie src/test/ObjectMap/CMakeFiles/ceph_test_keyvaluedb_iterators.dir/test_keyvaluedb_iterators.cc.o src/test/ObjectMap/CMakeFiles/ceph_test_keyvaluedb_iterators.dir/KeyValueDBMemory.cc.o -o bin/ceph_test_keyvaluedb_iterators -Wl,-rpath,/home/pdonnell/scratch/build/lib lib/libos.a lib/libgmock_maind.a lib/libgmockd. a lib/libgtestd.a -lpthread -ldl lib/libglobal.a -ldl /usr/lib64/librt.so -lresolv -ldl lib/libblk.a /lib64/libaio.so src/liburing/src/liburing.a lib/libkv.a lib/libheap_profiler.a /lib64/libtcmalloc.so src/rocksdb/librocksdb.a /lib64/libsnappy.so /usr/lib64/liblz4.so /usr/lib64/libz.so /usr/lib64/libfuse.so lib/libceph-common.so.2 src/opentelemetry-cpp/sdk/src/trace/libopentelemetry_trace.a src/opentelemetry-cpp/sdk/src/resource/libopentelemetry_resources.a src/opentelemetry-cpp/sdk/src/common/libopentelemetry_common.a src/opentelemetry-cpp/exporters/jaeger/libopentelemetry_exporter_jaeger_trace.a src/opentelemetry-cpp/ext/src/http/client/curl/libopentelemetry_http_client_curl.a /usr/lib64/libcurl.so /usr/lib64/libthrift.so lib/libjson_spirit.a lib/libcommon_utf8.a lib/liberasure_code.a lib/libextblkdev.a -lcap boost/lib/libboost_thread.a boost/lib/libboost_chrono.a boost/lib/libboost_atomic.a boost/lib/libboost_system.a boost/lib/libboost_random.a boost/lib/libboost_program_options.a boost/lib/libboost_date_time.a boost/lib/libboost_iostreams.a boost/lib/libboost_regex.a lib/libfmtd.a /usr/lib64/libblkid.so -lpthread /usr/lib64/libcrypto.so /usr/lib64/libudev.so /usr/lib64/libz.so -ldl -lresolv -Wl,--as-needed -latomic && :
/opt/rh/gcc-toolset-11/root/usr/bin/ld: src/rocksdb/librocksdb.a(fs_posix.cc.o): in function `io_uring_wait_cqe_nr':
/home/pdonnell/scratch/build/src/liburing/src/include/liburing.h:494: undefined reference to `__io_uring_get_cqe'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: src/rocksdb/librocksdb.a(fs_posix.cc.o): in function `rocksdb::(anonymous namespace)::PosixFileSystem::AbortIO(std::vector<void*, std::allocator<void*> >&)':
/home/pdonnell/ceph/src/rocksdb/env/fs_posix.cc:1125: undefined reference to `io_uring_get_sqe'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: /home/pdonnell/ceph/src/rocksdb/env/fs_posix.cc:1134: undefined reference to `io_uring_submit'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: src/rocksdb/librocksdb.a(fs_posix.cc.o): in function `rocksdb::CreateIOUring()':
/home/pdonnell/ceph/src/rocksdb/env/io_posix.h:272: undefined reference to `io_uring_queue_init'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: src/rocksdb/librocksdb.a(io_posix.cc.o): in function `io_uring_wait_cqe_nr':
/home/pdonnell/scratch/build/src/liburing/src/include/liburing.h:494: undefined reference to `__io_uring_get_cqe'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: src/rocksdb/librocksdb.a(io_posix.cc.o): in function `rocksdb::PosixRandomAccessFile::MultiRead(rocksdb::FSReadRequest*, unsigned long, rocksdb::IOOptions const&, rocksdb::IODebugContext*)':
/home/pdonnell/ceph/src/rocksdb/env/io_posix.cc:674: undefined reference to `io_uring_get_sqe'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: /home/pdonnell/ceph/src/rocksdb/env/io_posix.cc:684: undefined reference to `io_uring_submit_and_wait'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: src/rocksdb/librocksdb.a(io_posix.cc.o): in function `rocksdb::PosixRandomAccessFile::ReadAsync(rocksdb::FSReadRequest&, rocksdb::IOOptions const&, std::function<void (rocksdb::FSReadRequest const&, void*)>, void*, void**, std::function<void (void*)>*, rocksdb::IODebugContext*)':
/home/pdonnell/ceph/src/rocksdb/env/io_posix.cc:901: undefined reference to `io_uring_get_sqe'
/opt/rh/gcc-toolset-11/root/usr/bin/ld: /home/pdonnell/ceph/src/rocksdb/env/io_posix.cc:910: undefined reference to `io_uring_submit'
collect2: error: ld returned 1 exit status
Fixes: https://tracker.ceph.com/issues/63218
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
2023-10-16 14:07:04 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DWITH_LIBURING=${WITH_LIBURING})
|
|
|
|
if(WITH_LIBURING)
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -During_INCLUDE_DIR=${URING_INCLUDE_DIR})
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -During_LIBRARIES=${URING_LIBRARY_DIR})
|
|
|
|
list(APPEND rocksdb_INTERFACE_LINK_LIBRARIES uring::uring)
|
|
|
|
endif()
|
|
|
|
|
2017-09-19 03:56:15 +00:00
|
|
|
if(ALLOCATOR STREQUAL "jemalloc")
|
2018-08-06 09:55:02 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DWITH_JEMALLOC=ON)
|
|
|
|
list(APPEND rocksdb_INTERFACE_LINK_LIBRARIES JeMalloc::JeMalloc)
|
2017-09-19 03:56:15 +00:00
|
|
|
endif()
|
|
|
|
|
2019-06-12 10:54:26 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
|
2024-03-02 10:02:05 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
|
2017-09-19 03:56:15 +00:00
|
|
|
|
2018-08-06 09:55:02 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DWITH_SNAPPY=${SNAPPY_FOUND})
|
|
|
|
if(SNAPPY_FOUND)
|
|
|
|
list(APPEND rocksdb_INTERFACE_LINK_LIBRARIES snappy::snappy)
|
|
|
|
endif()
|
2018-07-23 11:55:05 +00:00
|
|
|
# libsnappy is a C++ library, we need to force rocksdb to link against
|
|
|
|
# libsnappy statically.
|
|
|
|
if(SNAPPY_FOUND AND WITH_STATIC_LIBSTDCXX)
|
2018-08-06 09:55:02 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DWITH_SNAPPY_STATIC_LIB=ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DWITH_LZ4=${LZ4_FOUND})
|
|
|
|
if(LZ4_FOUND)
|
|
|
|
list(APPEND rocksdb_INTERFACE_LINK_LIBRARIES LZ4::LZ4)
|
2020-02-05 15:01:04 +00:00
|
|
|
# When cross compiling, cmake may fail to locate lz4.
|
2020-07-27 13:57:59 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -Dlz4_INCLUDE_DIRS=${LZ4_INCLUDE_DIR})
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -Dlz4_LIBRARIES=${LZ4_LIBRARY})
|
2018-08-06 09:55:02 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DWITH_ZLIB=${ZLIB_FOUND})
|
|
|
|
if(ZLIB_FOUND)
|
|
|
|
list(APPEND rocksdb_INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
|
2018-07-23 11:55:05 +00:00
|
|
|
endif()
|
2018-08-06 09:55:02 +00:00
|
|
|
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DPORTABLE=ON)
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_AR=${CMAKE_AR})
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DFAIL_ON_WARNINGS=OFF)
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DUSE_RTTI=1)
|
2018-06-18 06:15:27 +00:00
|
|
|
CHECK_C_COMPILER_FLAG("-Wno-stringop-truncation" HAS_WARNING_STRINGOP_TRUNCATION)
|
|
|
|
if(HAS_WARNING_STRINGOP_TRUNCATION)
|
2019-06-12 08:50:14 +00:00
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_C_FLAGS=-Wno-stringop-truncation)
|
|
|
|
endif()
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
check_cxx_compiler_flag("-Wno-deprecated-copy" HAS_WARNING_DEPRECATED_COPY)
|
2023-12-15 11:03:57 +00:00
|
|
|
set(rocksdb_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
2019-06-12 08:50:14 +00:00
|
|
|
if(HAS_WARNING_DEPRECATED_COPY)
|
2023-12-15 11:01:46 +00:00
|
|
|
string(APPEND rocksdb_CXX_FLAGS " -Wno-deprecated-copy")
|
2019-06-12 08:50:14 +00:00
|
|
|
endif()
|
|
|
|
check_cxx_compiler_flag("-Wno-pessimizing-move" HAS_WARNING_PESSIMIZING_MOVE)
|
|
|
|
if(HAS_WARNING_PESSIMIZING_MOVE)
|
2023-12-15 11:01:46 +00:00
|
|
|
string(APPEND rocksdb_CXX_FLAGS " -Wno-pessimizing-move")
|
2019-06-12 08:50:14 +00:00
|
|
|
endif()
|
|
|
|
if(rocksdb_CXX_FLAGS)
|
|
|
|
list(APPEND rocksdb_CMAKE_ARGS -DCMAKE_CXX_FLAGS='${rocksdb_CXX_FLAGS}')
|
2018-06-18 06:15:27 +00:00
|
|
|
endif()
|
2017-09-19 03:56:15 +00:00
|
|
|
# we use an external project and copy the sources to bin directory to ensure
|
|
|
|
# that object files are built outside of the source tree.
|
|
|
|
include(ExternalProject)
|
2018-08-06 09:55:02 +00:00
|
|
|
set(rocksdb_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rocksdb")
|
|
|
|
set(rocksdb_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocksdb")
|
2019-05-27 11:53:42 +00:00
|
|
|
set(rocksdb_LIBRARY "${rocksdb_BINARY_DIR}/librocksdb.a")
|
2019-11-22 14:17:16 +00:00
|
|
|
if(CMAKE_MAKE_PROGRAM MATCHES "make")
|
|
|
|
# try to inherit command line arguments passed by parent "make" job
|
|
|
|
set(make_cmd $(MAKE) rocksdb)
|
|
|
|
else()
|
|
|
|
set(make_cmd ${CMAKE_COMMAND} --build <BINARY_DIR> --target rocksdb)
|
|
|
|
endif()
|
|
|
|
|
2017-09-19 03:56:15 +00:00
|
|
|
ExternalProject_Add(rocksdb_ext
|
2018-08-06 09:55:02 +00:00
|
|
|
SOURCE_DIR "${rocksdb_SOURCE_DIR}"
|
|
|
|
CMAKE_ARGS ${rocksdb_CMAKE_ARGS}
|
|
|
|
BINARY_DIR "${rocksdb_BINARY_DIR}"
|
2019-11-22 14:17:16 +00:00
|
|
|
BUILD_COMMAND "${make_cmd}"
|
2019-05-27 11:53:42 +00:00
|
|
|
BUILD_BYPRODUCTS "${rocksdb_LIBRARY}"
|
2021-03-04 07:16:37 +00:00
|
|
|
INSTALL_COMMAND ""
|
2020-02-05 15:01:04 +00:00
|
|
|
LIST_SEPARATOR !)
|
2017-09-19 03:56:15 +00:00
|
|
|
|
2023-11-23 05:12:29 +00:00
|
|
|
# make sure all the link libraries are built first
|
|
|
|
add_dependencies(rocksdb_ext ${rocksdb_INTERFACE_LINK_LIBRARIES})
|
|
|
|
|
2018-08-06 09:55:02 +00:00
|
|
|
add_library(RocksDB::RocksDB STATIC IMPORTED)
|
|
|
|
add_dependencies(RocksDB::RocksDB rocksdb_ext)
|
|
|
|
set(rocksdb_INCLUDE_DIR "${rocksdb_SOURCE_DIR}/include")
|
2017-09-19 05:07:59 +00:00
|
|
|
foreach(ver "MAJOR" "MINOR" "PATCH")
|
2018-08-06 09:55:02 +00:00
|
|
|
file(STRINGS "${rocksdb_INCLUDE_DIR}/rocksdb/version.h" ROCKSDB_VER_${ver}_LINE
|
2017-09-19 05:07:59 +00:00
|
|
|
REGEX "^#define[ \t]+ROCKSDB_${ver}[ \t]+[0-9]+$")
|
|
|
|
string(REGEX REPLACE "^#define[ \t]+ROCKSDB_${ver}[ \t]+([0-9]+)$"
|
|
|
|
"\\1" ROCKSDB_VERSION_${ver} "${ROCKSDB_VER_${ver}_LINE}")
|
|
|
|
unset(ROCKDB_VER_${ver}_LINE)
|
|
|
|
endforeach()
|
2018-08-06 09:55:02 +00:00
|
|
|
set(rocksdb_VERSION_STRING
|
2017-09-19 05:07:59 +00:00
|
|
|
"${ROCKSDB_VERSION_MAJOR}.${ROCKSDB_VERSION_MINOR}.${ROCKSDB_VERSION_PATCH}")
|
2018-08-06 09:55:02 +00:00
|
|
|
set_target_properties(RocksDB::RocksDB PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${rocksdb_INCLUDE_DIR}"
|
|
|
|
INTERFACE_LINK_LIBRARIES "${rocksdb_INTERFACE_LINK_LIBRARIES}"
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
|
|
|
IMPORTED_LOCATION "${rocksdb_LIBRARY}"
|
|
|
|
VERSION "${rocksdb_VERSION_STRING}")
|
|
|
|
endfunction()
|