From 2ca0994cf74f6c6553cba6055ae879ba54f3bfca Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Thu, 17 Mar 2016 11:25:20 -0700 Subject: [PATCH] Latest versions of Jemalloc library do not require je_init()/je_unint() calls. #ifdef in the source code and make this a default build option. --- port/win/port_win.cc | 4 ++++ thirdparty.inc | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/port/win/port_win.cc b/port/win/port_win.cc index 66b0f90e9..dd87c3577 100644 --- a/port/win/port_win.cc +++ b/port/win/port_win.cc @@ -233,6 +233,8 @@ int GetMaxOpenFiles() { return -1; } #include "jemalloc/jemalloc.h" +#ifndef JEMALLOC_NON_INIT + namespace rocksdb { namespace port { @@ -278,6 +280,8 @@ JEMALLOC_SECTION(".CRT$XCT") JEMALLOC_ATTR(used) static const void( } // extern "C" +#endif // JEMALLOC_NON_INIT + // Global operators to be replaced by a linker void* operator new(size_t size) { diff --git a/thirdparty.inc b/thirdparty.inc index 46da30c52..e10bdaa4e 100644 --- a/thirdparty.inc +++ b/thirdparty.inc @@ -8,6 +8,7 @@ set(USE_SNAPPY_DEFAULT 0) # SNAPPY is disabled by default, enable with -D set(USE_LZ4_DEFAULT 0) # LZ4 is disabled by default, enable with -DLZ4=1 cmake command line agrument set(USE_ZLIB_DEFAULT 0) # ZLIB is disabled by default, enable with -DZLIB=1 cmake command line agrument set(USE_JEMALLOC_DEFAULT 0) # JEMALLOC is disabled by default, enable with -DJEMALLOC=1 cmake command line agrument +set(USE_JENONINIT_DEFAULT 1) # Default is enabled do not call je_init/je_uninit as the newer versions do not have it disable with -DJENONINIT=0 # # This example assumes all the libraries locate in directories under THIRDPARTY_HOME environment variable @@ -208,7 +209,7 @@ endif () if (${USE_JEMALLOC} EQUAL 1) message(STATUS "JEMALLOC library is enabled") - set(JEMALLOC_CXX_FLAGS -DJEMALLOC) + set(JEMALLOC_CXX_FLAGS "-DJEMALLOC -DJEMALLOC_EXPORT= ") if(DEFINED ENV{JEMALLOC_INCLUDE}) set(JEMALLOC_INCLUDE $ENV{JEMALLOC_INCLUDE}) @@ -228,6 +229,18 @@ if (${USE_JEMALLOC} EQUAL 1) include_directories(${JEMALLOC_INCLUDE}) set (THIRDPARTY_LIBS ${THIRDPARTY_LIBS} ${JEMALLOC_LIBS}) set (ARTIFACT_SUFFIX "_je") + + set(USE_JENONINIT USE_JENONINIT_DEFAULT) + + if(JENONINIT) + set(USE_JENONINIT ${JENONINIT}) + endif() + + if(${USE_JENONINIT} EQUAL 1) + add_definitions(-DJEMALLOC_NON_INIT) + message(STATUS "JEMALLOC NONINIT version") + endif() + else () set (ARTIFACT_SUFFIX "") message(STATUS "JEMALLOC library is disabled")