Skip to content

rocksdb: add folly support, add version 10.2.1 #27606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions recipes/rocksdb/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"10.2.1":
url: "https://github.com/facebook/rocksdb/archive/refs/tags/v10.2.1.tar.gz"
sha256: "D1DDFD3551E649F7E2D180D5A6A006D90CFDE56DCFE1E548C58D95B7F1C87049"
"10.0.1":
url: "https://github.com/facebook/rocksdb/archive/refs/tags/v10.0.1.tar.gz"
sha256: "3fdc9ca996971c4c039959866382c4a3a6c8ade4abf888f3b2ff77153e07bf28"
Expand All @@ -21,6 +24,16 @@ sources:
url: "https://github.com/facebook/rocksdb/archive/refs/tags/v6.29.5.tar.gz"
sha256: "ddbf84791f0980c0bbce3902feb93a2c7006f6f53bfd798926143e31d4d756f0"
patches:
"10.2.1":
- patch_file: "patches/10.x.x-0001-fix-folly.patch"
patch_description: "Fix folly check"
patch_type: "conan"
- patch_file: "patches/10.x.x-0001-fix-msvc-coroutines.patch"
patch_description: "Fix coroutines on msvc"
patch_type: "portability"
- patch_file: "patches/9.x.x-0001-exclude-thirdparty.patch"
patch_description: "Do not include thirdparty.inc"
patch_type: "portability"
"10.0.1":
- patch_file: "patches/9.x.x-0001-exclude-thirdparty.patch"
patch_description: "Do not include thirdparty.inc"
Expand Down
40 changes: 33 additions & 7 deletions recipes/rocksdb/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RocksDBConan(ConanFile):
"with_jemalloc": [True, False],
"enable_sse": [False, "sse42", "avx2"],
"use_rtti": [True, False],
"use_coroutines": [True, False],
"use_folly": [True, False],
}
default_options = {
"shared": False,
Expand All @@ -49,11 +51,13 @@ class RocksDBConan(ConanFile):
"with_jemalloc": False,
"enable_sse": False,
"use_rtti": False,
"use_coroutines": False,
"use_folly": False,
}

@property
def _min_cppstd(self):
return "11" if Version(self.version) < "8.8.1" else "17"
return "11" if Version(self.version) < "8.8.1" else "20" if self.options.use_coroutines else "17"

def export_sources(self):
export_conandata_patches(self)
Expand All @@ -69,6 +73,8 @@ def config_options(self):
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
if Version(self.version) >= "8.0.0":
self.options.rm_safe("lite") # RocksDB Lite was removed in 8.0.0

def layout(self):
cmake_layout(self, src_folder="src")
Expand All @@ -77,17 +83,19 @@ def requirements(self):
if self.options.with_gflags:
self.requires("gflags/2.2.2")
if self.options.with_snappy:
self.requires("snappy/1.1.10")
self.requires("snappy/[>=1.1.10 <2]")
if self.options.with_lz4:
self.requires("lz4/1.9.4")
self.requires("lz4/[>=1.10.0 <2]")
if self.options.with_zlib:
self.requires("zlib/[>=1.2.11 <2]")
if self.options.with_zstd:
self.requires("zstd/1.5.5")
self.requires("zstd/[>=1.5.5 <2]")
if self.options.get_safe("with_tbb"):
self.requires("onetbb/2021.10.0")
if self.options.with_jemalloc:
self.requires("jemalloc/5.3.0")
if self.options.use_coroutines or self.options.use_folly:
self.requires("folly/[>=2024.08.12.00]")

def validate(self):
check_min_cppstd(self, self._min_cppstd)
Expand All @@ -97,6 +105,13 @@ def validate(self):

if is_msvc(self) and Version(self.settings.compiler.version) < "191":
raise ConanInvalidConfiguration("Rocksdb requires MSVC version >= 191")

folly_options = [bool(self.options.use_coroutines), bool(self.options.use_folly)]
if sum(folly_options) > 1:
raise ConanInvalidConfiguration("Rocksdb requires at most one of use_coroutines or use_folly")

if self.options.shared and (self.options.use_coroutines or self.options.use_folly):
raise ConanInvalidConfiguration("Rocksdb does not support a shared build with folly or coroutines")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
Expand All @@ -108,18 +123,27 @@ def generate(self):
tc.variables["WITH_TOOLS"] = False
tc.variables["WITH_CORE_TOOLS"] = False
tc.variables["WITH_BENCHMARK_TOOLS"] = False
tc.variables["WITH_FOLLY_DISTRIBUTED_MUTEX"] = False
tc.variables["WITH_TRACE_TOOLS"] = False
if Version(self.version) >= "7.7.0":
tc.variables["USE_COROUTINES"] = self.options.use_coroutines
tc.variables["USE_FOLLY_LITE"] = False # Folly Lite would download dependencies through a python script; I'm assuming we do not want that on CC
if Version(self.version) < "7.2.0":
tc.variables["WITH_FOLLY_DISTRIBUTED_MUTEX"] = False # This option was removed in 7.2.0; no reason to apply it
else:
tc.variables["USE_FOLLY"] = self.options.use_folly
if is_msvc(self):
tc.variables["WITH_MD_LIBRARY"] = not is_msvc_static_runtime(self)
tc.variables["ROCKSDB_INSTALL_ON_WINDOWS"] = self.settings.os == "Windows"
tc.variables["ROCKSDB_LITE"] = self.options.lite
if Version(self.version) < "8.0.0":
tc.variables["ROCKSDB_LITE"] = self.options.lite
tc.variables["WITH_GFLAGS"] = self.options.with_gflags
tc.variables["WITH_SNAPPY"] = self.options.with_snappy
tc.variables["WITH_LZ4"] = self.options.with_lz4
tc.variables["WITH_ZLIB"] = self.options.with_zlib
tc.variables["WITH_ZSTD"] = self.options.with_zstd
tc.variables["WITH_TBB"] = self.options.get_safe("with_tbb", False)
tc.variables["WITH_JEMALLOC"] = self.options.with_jemalloc

tc.variables["ROCKSDB_BUILD_SHARED"] = self.options.shared
tc.variables["ROCKSDB_LIBRARY_EXPORTS"] = self.settings.os == "Windows" and self.options.shared
tc.variables["ROCKSDB_DLL" ] = self.settings.os == "Windows" and self.options.shared
Expand Down Expand Up @@ -188,7 +212,7 @@ def package_info(self):
self.cpp_info.components["librocksdb"].defines = ["ROCKSDB_DLL"]
elif self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["librocksdb"].system_libs = ["pthread", "m"]
if self.options.lite:
if Version(self.version) < "8.0.0" and self.options.lite:
self.cpp_info.components["librocksdb"].defines.append("ROCKSDB_LITE")

self.cpp_info.components["librocksdb"].set_property("cmake_target_name", f"RocksDB::{cmake_target}")
Expand All @@ -206,3 +230,5 @@ def package_info(self):
self.cpp_info.components["librocksdb"].requires.append("onetbb::onetbb")
if self.options.with_jemalloc:
self.cpp_info.components["librocksdb"].requires.append("jemalloc::jemalloc")
if self.options.use_coroutines or self.options.use_folly:
self.cpp_info.components["librocksdb"].requires.append("folly::folly")
11 changes: 11 additions & 0 deletions recipes/rocksdb/all/patches/10.x.x-0001-fix-folly.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -607,7 +607,7 @@
find_package(folly)
# If cmake could not find the folly-config.cmake file, fall back
# to looking in third-party/folly for folly and its dependencies
- if(NOT FOLLY_LIBRARIES)
+ if(NOT folly_LIBRARIES)
exec_program(python3 ${PROJECT_SOURCE_DIR}/third-party/folly ARGS
build/fbcode_builder/getdeps.py show-inst-dir OUTPUT_VARIABLE
FOLLY_INST_PATH)
23 changes: 23 additions & 0 deletions recipes/rocksdb/all/patches/10.x.x-0001-fix-msvc-coroutines.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -586,11 +586,15 @@
message(FATAL_ERROR "Please specify exactly one of USE_COROUTINES,"
" USE_FOLLY, and USE_FOLLY_LITE")
endif()
- set(CMAKE_CXX_STANDARD 20)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines -Wno-maybe-uninitialized")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-memory-model")
+ if( NOT DEFINED CMAKE_CXX_STANDARD )
+ set(CMAKE_CXX_STANDARD 20)
+ endif()
+ if (NOT MSVC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines -Wno-maybe-uninitialized")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-memory-model")
+ endif()
add_compile_definitions(USE_COROUTINES)
set(USE_FOLLY 1)
endif()
2 changes: 2 additions & 0 deletions recipes/rocksdb/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"10.2.1":
folder: all
"10.0.1":
folder: all
"9.10.0":
Expand Down