@ -139,9 +139,14 @@ endif
GIT_COMMAND ?= git
GIT_COMMAND ?= git
i f e q ( $( USE_COROUTINES ) , 1 )
i f e q ( $( USE_COROUTINES ) , 1 )
USE_FOLLY = 1
USE_FOLLY = 1
OPT += -DUSE_COROUTINES
# glog/logging.h requires HAVE_CXX11_ATOMIC
OPT += -DUSE_COROUTINES -DHAVE_CXX11_ATOMIC
ROCKSDB_CXX_STANDARD = c++2a
ROCKSDB_CXX_STANDARD = c++2a
USE_RTTI = 1
USE_RTTI = 1
i f n e q ( $( USE_CLANG ) , 1 )
ROCKSDB_CXX_STANDARD = c++20
PLATFORM_CXXFLAGS += -fcoroutines
e n d i f
e n d i f
e n d i f
# if we're compiling for release, compile without debug code (-DNDEBUG)
# if we're compiling for release, compile without debug code (-DNDEBUG)
@ -235,6 +240,7 @@ dummy := $(shell (export ROCKSDB_ROOT="$(CURDIR)"; \
export USE_CLANG = " $( USE_CLANG) " ; \
export USE_CLANG = " $( USE_CLANG) " ; \
export LIB_MODE = " $( LIB_MODE) " ; \
export LIB_MODE = " $( LIB_MODE) " ; \
export ROCKSDB_CXX_STANDARD = " $( ROCKSDB_CXX_STANDARD) " ; \
export ROCKSDB_CXX_STANDARD = " $( ROCKSDB_CXX_STANDARD) " ; \
export USE_FOLLY = " $( USE_FOLLY) " ; \
" $( CURDIR) /build_tools/build_detect_platform " " $( CURDIR) /make_config.mk " ) )
" $( CURDIR) /build_tools/build_detect_platform " " $( CURDIR) /make_config.mk " ) )
# this file is generated by the previous line to set build flags and sources
# this file is generated by the previous line to set build flags and sources
i n c l u d e m a k e _ c o n f i g . m k
i n c l u d e m a k e _ c o n f i g . m k
@ -415,6 +421,10 @@ ifndef DISABLE_JEMALLOC
PLATFORM_CXXFLAGS += -DUSE_JEMALLOC
PLATFORM_CXXFLAGS += -DUSE_JEMALLOC
PLATFORM_CCFLAGS += -DUSE_JEMALLOC
PLATFORM_CCFLAGS += -DUSE_JEMALLOC
endif
endif
ifeq ( $( USE_FOLLY_LITE) ,1)
PLATFORM_CXXFLAGS += -DUSE_JEMALLOC
PLATFORM_CCFLAGS += -DUSE_JEMALLOC
endif
endif
endif
ifdef WITH_JEMALLOC_FLAG
ifdef WITH_JEMALLOC_FLAG
PLATFORM_LDFLAGS += -ljemalloc
PLATFORM_LDFLAGS += -ljemalloc
@ -448,10 +458,57 @@ endif
# This provides a Makefile simulation of a Meta-internal folly integration.
# This provides a Makefile simulation of a Meta-internal folly integration.
# It is not validated for general use.
# It is not validated for general use.
#
# USE_FOLLY links the build targets with libfolly.a. The latter could be
# built using 'make build_folly', or built externally and specified in
# the CXXFLAGS and EXTRA_LDFLAGS env variables. The build_detect_platform
# script tries to detect if an external folly dependency has been specified.
# If not, it exports FOLLY_PATH to the path of the installed Folly and
# dependency libraries.
#
# USE_FOLLY_LITE cherry picks source files from Folly to include in the
# RocksDB library. Its faster and has fewer dependencies on 3rd party
# libraries, but with limited functionality. For example, coroutine
# functionality is not available.
i f e q ( $( USE_FOLLY ) , 1 )
i f e q ( $( USE_FOLLY ) , 1 )
ifeq ( ,$( FOLLY_DIR) )
i f e q ( $( USE_FOLLY_LITE ) , 1 )
FOLLY_DIR = ./third-party/folly
$( error Please specify only one of USE_FOLLY and USE_FOLLY_LITE )
e n d i f
i f n e q ( $( strip $ ( FOLLY_PATH ) ) , )
BOOST_PATH = $( shell ( ls -d $( FOLLY_PATH) /../boost*) )
DBL_CONV_PATH = $( shell ( ls -d $( FOLLY_PATH) /../double-conversion*) )
GFLAGS_PATH = $( shell ( ls -d $( FOLLY_PATH) /../gflags*) )
GLOG_PATH = $( shell ( ls -d $( FOLLY_PATH) /../glog*) )
LIBEVENT_PATH = $( shell ( ls -d $( FOLLY_PATH) /../libevent*) )
XZ_PATH = $( shell ( ls -d $( FOLLY_PATH) /../xz*) )
LIBSODIUM_PATH = $( shell ( ls -d $( FOLLY_PATH) /../libsodium*) )
FMT_PATH = $( shell ( ls -d $( FOLLY_PATH) /../fmt*) )
# For some reason, glog and fmt libraries are under either lib or lib64
GLOG_LIB_PATH = $( shell ( ls -d $( GLOG_PATH) /lib*) )
FMT_LIB_PATH = $( shell ( ls -d $( FMT_PATH) /lib*) )
# AIX: pre-defined system headers are surrounded by an extern "C" block
ifeq ( $( PLATFORM) , OS_AIX)
PLATFORM_CCFLAGS += -I$( BOOST_PATH) /include -I$( DBL_CONV_PATH) /include -I$( GLOG_PATH) /include -I$( LIBEVENT_PATH) /include -I$( XZ_PATH) /include -I$( LIBSODIUM_PATH) /include -I$( FOLLY_PATH) /include -I$( FMT_PATH) /include
PLATFORM_CXXFLAGS += -I$( BOOST_PATH) /include -I$( DBL_CONV_PATH) /include -I$( GLOG_PATH) /include -I$( LIBEVENT_PATH) /include -I$( XZ_PATH) /include -I$( LIBSODIUM_PATH) /include -I$( FOLLY_PATH) /include -I$( FMT_PATH) /include
else
PLATFORM_CCFLAGS += -isystem $( BOOST_PATH) /include -isystem $( DBL_CONV_PATH) /include -isystem $( GLOG_PATH) /include -isystem $( LIBEVENT_PATH) /include -isystem $( XZ_PATH) /include -isystem $( LIBSODIUM_PATH) /include -isystem $( FOLLY_PATH) /include -isystem $( FMT_PATH) /include
PLATFORM_CXXFLAGS += -isystem $( BOOST_PATH) /include -isystem $( DBL_CONV_PATH) /include -isystem $( GLOG_PATH) /include -isystem $( LIBEVENT_PATH) /include -isystem $( XZ_PATH) /include -isystem $( LIBSODIUM_PATH) /include -isystem $( FOLLY_PATH) /include -isystem $( FMT_PATH) /include
endif
endif
# Add -ldl at the end as gcc resolves a symbol in a library by searching only in libraries specified later
# in the command line
PLATFORM_LDFLAGS += $( BOOST_PATH) /lib/libboost_context.a $( BOOST_PATH) /lib/libboost_filesystem.a $( BOOST_PATH) /lib/libboost_atomic.a $( BOOST_PATH) /lib/libboost_program_options.a $( BOOST_PATH) /lib/libboost_regex.a $( BOOST_PATH) /lib/libboost_system.a $( BOOST_PATH) /lib/libboost_thread.a $( DBL_CONV_PATH) /lib/libdouble-conversion.a $( FOLLY_PATH) /lib/libfolly.a $( FMT_LIB_PATH) /libfmt.a $( GLOG_LIB_PATH) /libglog.so $( GFLAGS_PATH) /lib/libgflags.so.2.2 -ldl
PLATFORM_LDFLAGS += -Wl,-rpath= $( GFLAGS_PATH) /lib -Wl,-rpath= $( GLOG_LIB_PATH) -Wl,-rpath= $( LIBEVENT_PATH) /lib -Wl,-rpath= $( LIBSODIUM_PATH) /lib -Wl,-rpath= $( LIBEVENT_PATH) /lib
e n d i f
PLATFORM_CCFLAGS += -DUSE_FOLLY -DFOLLY_NO_CONFIG
PLATFORM_CXXFLAGS += -DUSE_FOLLY -DFOLLY_NO_CONFIG
e n d i f
i f e q ( $( USE_FOLLY_LITE ) , 1 )
# Path to the Folly source code and include files
FOLLY_DIR = ./third-party/folly
# AIX: pre-defined system headers are surrounded by an extern "C" block
# AIX: pre-defined system headers are surrounded by an extern "C" block
ifeq ( $( PLATFORM) , OS_AIX)
ifeq ( $( PLATFORM) , OS_AIX)
PLATFORM_CCFLAGS += -I$( FOLLY_DIR)
PLATFORM_CCFLAGS += -I$( FOLLY_DIR)
@ -550,7 +607,7 @@ LIB_OBJECTS += $(patsubst %.c, $(OBJ_DIR)/%.o, $(LIB_SOURCES_C))
LIB_OBJECTS += $( patsubst %.S, $( OBJ_DIR) /%.o, $( LIB_SOURCES_ASM) )
LIB_OBJECTS += $( patsubst %.S, $( OBJ_DIR) /%.o, $( LIB_SOURCES_ASM) )
e n d i f
e n d i f
i f e q ( $( USE_FOLLY ) , 1 )
i f e q ( $( USE_FOLLY_LITE ) , 1 )
LIB_OBJECTS += $( patsubst %.cpp, $( OBJ_DIR) /%.o, $( FOLLY_SOURCES) )
LIB_OBJECTS += $( patsubst %.cpp, $( OBJ_DIR) /%.o, $( FOLLY_SOURCES) )
e n d i f
e n d i f
@ -2371,13 +2428,26 @@ checkout_folly:
@# need to worry about folly breaking our integration. Update periodically
@# need to worry about folly breaking our integration. Update periodically
cd third-party/folly && git reset --hard beacd86d63cd71c904632262e6c36f60874d78ba
cd third-party/folly && git reset --hard beacd86d63cd71c904632262e6c36f60874d78ba
@# A hack to remove boost dependency.
@# A hack to remove boost dependency.
@# NOTE: this hack is not needed if using FBCODE compiler config
@# NOTE: this hack is only needed if building using USE_FOLLY_LITE
perl -pi -e 's/^(#include <boost)/\/\/$$1/' third-party/folly/folly/functional/Invoke.h
perl -pi -e 's/^(#include <boost)/\/\/$$1/' third-party/folly/folly/functional/Invoke.h
@# NOTE: this hack is required for clang in some cases
@# NOTE: this hack is required for clang in some cases
perl -pi -e 's/int rv = syscall/int rv = (int)syscall/' third-party/folly/folly/detail/Futex.cpp
perl -pi -e 's/int rv = syscall/int rv = (int)syscall/' third-party/folly/folly/detail/Futex.cpp
@# NOTE: this hack is required for gcc in some cases
@# NOTE: this hack is required for gcc in some cases
perl -pi -e 's/(__has_include.<experimental.memory_resource>.)/__cpp_rtti && $$1/' third-party/folly/folly/memory/MemoryResource.h
perl -pi -e 's/(__has_include.<experimental.memory_resource>.)/__cpp_rtti && $$1/' third-party/folly/folly/memory/MemoryResource.h
build_folly :
FOLLY_INST_PATH = ` cd third-party/folly; $( PYTHON) build/fbcode_builder/getdeps.py show-inst-dir` ; \
if [ " $$ FOLLY_INST_PATH " ] ; then \
rm -rf $$ { FOLLY_INST_PATH} /../../*; \
else \
echo "Please run checkout_folly first" ; \
false; \
fi
# Restore the original version of Invoke.h with boost dependency
cd third-party/folly && ${ GIT_COMMAND } checkout folly/functional/Invoke.h
cd third-party/folly && MAYBE_AVX2 = ` echo $( CXXFLAGS) | grep -o -- -DHAVE_AVX2 | sed 's/-DHAVE_AVX2/-mavx2/g' || true ` && \
CXXFLAGS = " $$ MAYBE_AVX2 -DHAVE_CXX11_ATOMIC " $( PYTHON) build/fbcode_builder/getdeps.py build --no-tests
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Build size testing
# Build size testing
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
@ -2462,7 +2532,7 @@ endif
i f n e q ( $( SKIP_DEPENDS ) , 1 )
i f n e q ( $( SKIP_DEPENDS ) , 1 )
DEPFILES = $( patsubst %.cc, $( OBJ_DIR) /%.cc.d, $( ALL_SOURCES) )
DEPFILES = $( patsubst %.cc, $( OBJ_DIR) /%.cc.d, $( ALL_SOURCES) )
D E P F I L E S + = $( patsubst %.c , $ ( OBJ_DIR ) /%.c .d , $ ( LIB_SOURCES_C ) $ ( TEST_MAIN_SOURCES_C ) )
D E P F I L E S + = $( patsubst %.c , $ ( OBJ_DIR ) /%.c .d , $ ( LIB_SOURCES_C ) $ ( TEST_MAIN_SOURCES_C ) )
i f e q ( $( USE_FOLLY ) , 1 )
i f e q ( $( USE_FOLLY_LITE ) , 1 )
DEPFILES += $( patsubst %.cpp, $( OBJ_DIR) /%.cpp.d, $( FOLLY_SOURCES) )
DEPFILES += $( patsubst %.cpp, $( OBJ_DIR) /%.cpp.d, $( FOLLY_SOURCES) )
e n d i f
e n d i f
e n d i f
e n d i f