Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
titan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
titan
Commits
02953c32
Commit
02953c32
authored
May 03, 2019
by
Yi Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy compile flags from rocksdb/CMakeLists.txt
Signed-off-by:
Yi Wu
<
yiwu@pingcap.com
>
parent
7b4f357e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
274 additions
and
40 deletions
+274
-40
CMakeLists.txt
CMakeLists.txt
+1
-40
rocksdb_flags.cmake
cmake/rocksdb_flags.cmake
+273
-0
No files found.
CMakeLists.txt
View file @
02953c32
...
...
@@ -7,51 +7,13 @@ if (NOT DEFINED ROCKSDB_DIR)
message
(
FATAL_ERROR
"ROCKSDB_DIR is not defined."
)
endif
()
set
(
ROCKSDB_FLAGS
-DROCKSDB_LIB_IO_POSIX
-DROCKSDB_PLATFORM_POSIX
-DROCKSDB_SUPPORT_THREAD_LOCAL
)
add_definitions
(
${
ROCKSDB_FLAGS
}
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-g"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O3 -DNDEBUG"
)
include
(
cmake/rocksdb_flags.cmake
)
include_directories
(
${
ROCKSDB_DIR
}
)
include_directories
(
${
ROCKSDB_DIR
}
/include
)
include_directories
(
${
PROJECT_SOURCE_DIR
}
/include
)
include_directories
(
${
PROJECT_SOURCE_DIR
}
/src
)
option
(
WITH_ASAN
"build with ASAN"
OFF
)
if
(
WITH_ASAN
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-fsanitize=address"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=address"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fsanitize=address"
)
if
(
WITH_JEMALLOC
)
message
(
FATAL
"ASAN does not work well with JeMalloc"
)
endif
()
endif
()
option
(
WITH_TSAN
"build with TSAN"
OFF
)
if
(
WITH_TSAN
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-fsanitize=thread -pie"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=thread -fPIC"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fsanitize=thread -fPIC"
)
if
(
WITH_JEMALLOC
)
message
(
FATAL
"TSAN does not work well with JeMalloc"
)
endif
()
endif
()
option
(
WITH_UBSAN
"build with UBSAN"
OFF
)
if
(
WITH_UBSAN
)
add_definitions
(
-DROCKSDB_UBSAN_RUN
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-fsanitize=undefined"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=undefined"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fsanitize=undefined"
)
if
(
WITH_JEMALLOC
)
message
(
FATAL
"UBSAN does not work well with JeMalloc"
)
endif
()
endif
()
set
(
SOURCES
src/blob_file_builder.cc
src/blob_file_cache.cc
...
...
@@ -86,7 +48,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release")
endif
()
if
(
WITH_TITAN_TESTS OR WITH_TITAN_TOOLS
)
message
(
"with tests or tools"
)
add_subdirectory
(
${
ROCKSDB_DIR
}
rocksdb EXCLUDE_FROM_ALL
)
endif
()
...
...
cmake/rocksdb_flags.cmake
0 → 100644
View file @
02953c32
# Generate compile and link flags
# Extracted from rocksdb/CMakeLists.txt
if
(
MSVC
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/Zi /nologo /EHsc /GS /Gd /GR /GF /fp:precise /Zc:wchar_t /Zc:forScope /errorReport:queue"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/FC /d2Zi+ /W4 /wd4127 /wd4800 /wd4996 /wd4351 /wd4100 /wd4204 /wd4324"
)
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-W -Wextra -Wall"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-strict-aliasing"
)
if
(
MINGW
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-format"
)
endif
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
if
(
NOT CMAKE_BUILD_TYPE STREQUAL
"Debug"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fno-omit-frame-pointer"
)
include
(
CheckCXXCompilerFlag
)
CHECK_CXX_COMPILER_FLAG
(
"-momit-leaf-frame-pointer"
HAVE_OMIT_LEAF_FRAME_POINTER
)
if
(
HAVE_OMIT_LEAF_FRAME_POINTER
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-momit-leaf-frame-pointer"
)
endif
()
endif
()
endif
()
include
(
CheckCCompilerFlag
)
if
(
CMAKE_SYSTEM_PROCESSOR MATCHES
"ppc64le"
)
CHECK_C_COMPILER_FLAG
(
"-maltivec"
HAS_ALTIVEC
)
if
(
HAS_ALTIVEC
)
message
(
STATUS
" HAS_ALTIVEC yes"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-maltivec"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-maltivec"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-mcpu=power8"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-mcpu=power8"
)
endif
(
HAS_ALTIVEC
)
endif
(
CMAKE_SYSTEM_PROCESSOR MATCHES
"ppc64le"
)
option
(
PORTABLE
"build a portable binary"
OFF
)
option
(
FORCE_SSE42
"force building with SSE4.2, even when PORTABLE=ON"
OFF
)
if
(
PORTABLE
)
# MSVC does not need a separate compiler flag to enable SSE4.2; if nmmintrin.h
# is available, it is available by default.
if
(
FORCE_SSE42 AND NOT MSVC
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-msse4.2 -mpclmul"
)
endif
()
else
()
if
(
MSVC
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/arch:AVX2"
)
else
()
if
(
NOT HAVE_POWER8
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native"
)
endif
()
endif
()
endif
()
include
(
CheckCXXSourceCompiles
)
if
(
NOT MSVC
)
set
(
CMAKE_REQUIRED_FLAGS
"-msse4.2 -mpclmul"
)
endif
()
CHECK_CXX_SOURCE_COMPILES
(
"
#include <cstdint>
#include <nmmintrin.h>
#include <wmmintrin.h>
int main() {
volatile uint32_t x = _mm_crc32_u32(0, 0);
const auto a = _mm_set_epi64x(0, 0);
const auto b = _mm_set_epi64x(0, 0);
const auto c = _mm_clmulepi64_si128(a, b, 0x00);
auto d = _mm_cvtsi128_si64(c);
}
"
HAVE_SSE42
)
unset
(
CMAKE_REQUIRED_FLAGS
)
if
(
HAVE_SSE42
)
add_definitions
(
-DHAVE_SSE42
)
add_definitions
(
-DHAVE_PCLMUL
)
elseif
(
FORCE_SSE42
)
message
(
FATAL_ERROR
"FORCE_SSE42=ON but unable to compile with SSE4.2 enabled"
)
endif
()
CHECK_CXX_SOURCE_COMPILES
(
"
#if defined(_MSC_VER) && !defined(__thread)
#define __thread __declspec(thread)
#endif
int main() {
static __thread int tls;
}
"
HAVE_THREAD_LOCAL
)
if
(
HAVE_THREAD_LOCAL
)
add_definitions
(
-DROCKSDB_SUPPORT_THREAD_LOCAL
)
endif
()
option
(
FAIL_ON_WARNINGS
"Treat compile warnings as errors"
ON
)
if
(
FAIL_ON_WARNINGS
)
if
(
MSVC
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/WX"
)
else
()
# assume GCC
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Werror"
)
endif
()
endif
()
option
(
WITH_ASAN
"build with ASAN"
OFF
)
if
(
WITH_ASAN
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-fsanitize=address"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=address"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fsanitize=address"
)
if
(
WITH_JEMALLOC
)
message
(
FATAL
"ASAN does not work well with JeMalloc"
)
endif
()
endif
()
option
(
WITH_TSAN
"build with TSAN"
OFF
)
if
(
WITH_TSAN
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-fsanitize=thread -pie"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=thread -fPIC"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fsanitize=thread -fPIC"
)
if
(
WITH_JEMALLOC
)
message
(
FATAL
"TSAN does not work well with JeMalloc"
)
endif
()
endif
()
option
(
WITH_UBSAN
"build with UBSAN"
OFF
)
if
(
WITH_UBSAN
)
add_definitions
(
-DROCKSDB_UBSAN_RUN
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-fsanitize=undefined"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=undefined"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fsanitize=undefined"
)
if
(
WITH_JEMALLOC
)
message
(
FATAL
"UBSAN does not work well with JeMalloc"
)
endif
()
endif
()
# Stall notifications eat some performance from inserts
option
(
DISABLE_STALL_NOTIF
"Build with stall notifications"
OFF
)
if
(
DISABLE_STALL_NOTIF
)
add_definitions
(
-DROCKSDB_DISABLE_STALL_NOTIFICATION
)
endif
()
if
(
DEFINED USE_RTTI
)
if
(
USE_RTTI
)
message
(
STATUS
"Enabling RTTI"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DROCKSDB_USE_RTTI"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
-DROCKSDB_USE_RTTI"
)
else
()
if
(
MSVC
)
message
(
STATUS
"Disabling RTTI in Release builds. Always on in Debug."
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DROCKSDB_USE_RTTI"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
/GR-"
)
else
()
message
(
STATUS
"Disabling RTTI in Release builds"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-fno-rtti"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
-fno-rtti"
)
endif
()
endif
()
else
()
message
(
STATUS
"Enabling RTTI in Debug builds only (default)"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DROCKSDB_USE_RTTI"
)
if
(
MSVC
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
/GR-"
)
else
()
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
-fno-rtti"
)
endif
()
endif
()
# Used to run CI build and tests so we can run faster
option
(
OPTDBG
"Build optimized debug build with MSVC"
OFF
)
option
(
WITH_RUNTIME_DEBUG
"build with debug version of runtime library"
ON
)
if
(
MSVC
)
if
(
OPTDBG
)
message
(
STATUS
"Debug optimization is enabled"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"/Oxt"
)
else
()
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
/Od /RTC1 /Gm"
)
endif
()
if
(
WITH_RUNTIME_DEBUG
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
/
${
RUNTIME_LIBRARY
}
d"
)
else
()
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
/
${
RUNTIME_LIBRARY
}
"
)
endif
()
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
/Oxt /Zp8 /Gm- /Gy /
${
RUNTIME_LIBRARY
}
"
)
set
(
CMAKE_SHARED_LINKER_FLAGS
"
${
CMAKE_SHARED_LINKER_FLAGS
}
/DEBUG"
)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
/DEBUG"
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fno-builtin-memcmp"
)
endif
()
option
(
ROCKSDB_LITE
"Build RocksDBLite version"
OFF
)
if
(
ROCKSDB_LITE
)
add_definitions
(
-DROCKSDB_LITE
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fno-exceptions -Os"
)
endif
()
if
(
CMAKE_SYSTEM_NAME MATCHES
"Cygwin"
)
add_definitions
(
-fno-builtin-memcmp -DCYGWIN
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"Darwin"
)
add_definitions
(
-DOS_MACOSX
)
if
(
CMAKE_SYSTEM_PROCESSOR MATCHES arm
)
add_definitions
(
-DIOS_CROSS_COMPILE -DROCKSDB_LITE
)
# no debug info for IOS, that will make our library big
add_definitions
(
-DNDEBUG
)
endif
()
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"Linux"
)
add_definitions
(
-DOS_LINUX
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"SunOS"
)
add_definitions
(
-DOS_SOLARIS
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"FreeBSD"
)
add_definitions
(
-DOS_FREEBSD
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"NetBSD"
)
add_definitions
(
-DOS_NETBSD
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"OpenBSD"
)
add_definitions
(
-DOS_OPENBSD
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"DragonFly"
)
add_definitions
(
-DOS_DRAGONFLYBSD
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"Android"
)
add_definitions
(
-DOS_ANDROID
)
elseif
(
CMAKE_SYSTEM_NAME MATCHES
"Windows"
)
add_definitions
(
-DWIN32 -DOS_WIN -D_MBCS -DWIN64 -DNOMINMAX
)
if
(
MINGW
)
add_definitions
(
-D_WIN32_WINNT=_WIN32_WINNT_VISTA
)
endif
()
endif
()
if
(
NOT WIN32
)
add_definitions
(
-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX
)
endif
()
option
(
WITH_FALLOCATE
"build with fallocate"
ON
)
if
(
WITH_FALLOCATE
)
CHECK_CXX_SOURCE_COMPILES
(
"
#include <fcntl.h>
#include <linux/falloc.h>
int main() {
int fd = open(
\"
/dev/null
\"
, 0);
fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, 0, 1024);
}
"
HAVE_FALLOCATE
)
if
(
HAVE_FALLOCATE
)
add_definitions
(
-DROCKSDB_FALLOCATE_PRESENT
)
endif
()
endif
()
CHECK_CXX_SOURCE_COMPILES
(
"
#include <fcntl.h>
int main() {
int fd = open(
\"
/dev/null
\"
, 0);
sync_file_range(fd, 0, 1024, SYNC_FILE_RANGE_WRITE);
}
"
HAVE_SYNC_FILE_RANGE_WRITE
)
if
(
HAVE_SYNC_FILE_RANGE_WRITE
)
add_definitions
(
-DROCKSDB_RANGESYNC_PRESENT
)
endif
()
CHECK_CXX_SOURCE_COMPILES
(
"
#include <pthread.h>
int main() {
(void) PTHREAD_MUTEX_ADAPTIVE_NP;
}
"
HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
)
if
(
HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
)
add_definitions
(
-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX
)
endif
()
include
(
CheckCXXSymbolExists
)
check_cxx_symbol_exists
(
malloc_usable_size malloc.h HAVE_MALLOC_USABLE_SIZE
)
if
(
HAVE_MALLOC_USABLE_SIZE
)
add_definitions
(
-DROCKSDB_MALLOC_USABLE_SIZE
)
endif
()
check_cxx_symbol_exists
(
sched_getcpu sched.h HAVE_SCHED_GETCPU
)
if
(
HAVE_SCHED_GETCPU
)
add_definitions
(
-DROCKSDB_SCHED_GETCPU_PRESENT
)
endif
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment