arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-466: Add ExternalProject for jemalloc
Date Tue, 10 Jan 2017 18:23:33 GMT
Repository: arrow
Updated Branches:
  refs/heads/master f44b6a3b9 -> 8d917c1f9


ARROW-466: Add ExternalProject for jemalloc

Author: Uwe L. Korn <uwelk@xhochy.com>

Closes #276 from xhochy/ARROW-466 and squashes the following commits:

9379c45 [Uwe L. Korn] Revert "Enable jemalloc on Windows"
6fd8da8 [Uwe L. Korn] Enable jemalloc on Windows
0e1082f [Uwe L. Korn] ARROW-466: Add ExternalProject for jemalloc


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/8d917c1f
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/8d917c1f
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/8d917c1f

Branch: refs/heads/master
Commit: 8d917c1f925c76e9009f6d1b9792551293a572fe
Parents: f44b6a3
Author: Uwe L. Korn <uwelk@xhochy.com>
Authored: Tue Jan 10 13:23:26 2017 -0500
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Tue Jan 10 13:23:26 2017 -0500

----------------------------------------------------------------------
 cpp/CMakeLists.txt                    | 37 ++++++++++++++++++++++++++++--
 cpp/cmake_modules/Findjemalloc.cmake  |  5 ++++
 cpp/src/arrow/jemalloc/CMakeLists.txt | 12 +++++++---
 3 files changed, 49 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/8d917c1f/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 87b7841..8a2cfc5 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -30,6 +30,7 @@ set(GFLAGS_VERSION "2.1.2")
 set(GTEST_VERSION "1.7.0")
 set(GBENCHMARK_VERSION "1.1.0")
 set(FLATBUFFERS_VERSION "1.3.0")
+set(JEMALLOC_VERSION "4.4.0")
 
 find_package(ClangTools)
 if ("$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "1" OR CLANG_TIDY_FOUND)
@@ -76,7 +77,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
 
   option(ARROW_JEMALLOC
     "Build the Arrow jemalloc-based allocator"
-    OFF)
+    ON)
 
   option(ARROW_BOOST_USE_SHARED
     "Rely on boost shared libraries where relevant"
@@ -594,11 +595,43 @@ message(STATUS "RapidJSON include dir: ${RAPIDJSON_INCLUDE_DIR}")
 include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR})
 
 if (ARROW_JEMALLOC)
-  find_package(jemalloc REQUIRED)
+  find_package(jemalloc)
+
+  if(NOT JEMALLOC_FOUND)
+    set(JEMALLOC_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/jemalloc_ep-prefix/src/jemalloc_ep")
+    set(JEMALLOC_HOME "${JEMALLOC_PREFIX}")
+    set(JEMALLOC_INCLUDE_DIR "${JEMALLOC_PREFIX}/include")
+    set(JEMALLOC_SHARED_LIB "${JEMALLOC_PREFIX}/lib/libjemalloc${CMAKE_SHARED_LIBRARY_SUFFIX}")
+    set(JEMALLOC_STATIC_LIB "${JEMALLOC_PREFIX}/lib/libjemalloc_pic${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    set(JEMALLOC_VENDORED 1)
+    if (CMAKE_VERSION VERSION_GREATER "3.2")
+      # BUILD_BYPRODUCTS is a 3.2+ feature
+      ExternalProject_Add(jemalloc_ep
+        URL https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2
+        CONFIGURE_COMMAND ./configure "--prefix=${JEMALLOC_PREFIX}" "--with-jemalloc-prefix="
+        BUILD_IN_SOURCE 1
+        BUILD_COMMAND ${MAKE}
+        BUILD_BYPRODUCTS "${JEMALLOC_STATIC_LIB}")
+    else()
+      ExternalProject_Add(jemalloc_ep
+        URL https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2
+        CONFIGURE_COMMAND ./configure "--prefix=${JEMALLOC_PREFIX}" "--with-jemalloc-prefix="
+        BUILD_IN_SOURCE 1
+        BUILD_COMMAND ${MAKE})
+    endif()
+  else()
+    set(JEMALLOC_VENDORED 0)
+  endif()
 
   include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIR})
   ADD_THIRDPARTY_LIB(jemalloc
+      STATIC_LIB ${JEMALLOC_STATIC_LIB}
       SHARED_LIB ${JEMALLOC_SHARED_LIB})
+
+  if (JEMALLOC_VENDORED)
+    add_dependencies(jemalloc_shared jemalloc_ep)
+    add_dependencies(jemalloc_static jemalloc_ep)
+  endif()
 endif()
 
 ## Google PerfTools

http://git-wip-us.apache.org/repos/asf/arrow/blob/8d917c1f/cpp/cmake_modules/Findjemalloc.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/Findjemalloc.cmake b/cpp/cmake_modules/Findjemalloc.cmake
index e7fbb94..e511d4d 100644
--- a/cpp/cmake_modules/Findjemalloc.cmake
+++ b/cpp/cmake_modules/Findjemalloc.cmake
@@ -47,11 +47,16 @@ if ( _jemalloc_roots )
     find_library( JEMALLOC_SHARED_LIB NAMES ${LIBJEMALLOC_NAMES}
         PATHS ${_jemalloc_roots} NO_DEFAULT_PATH
         PATH_SUFFIXES "lib" )
+    find_library( JEMALLOC_STATIC_LIB NAMES jemalloc_pic
+        PATHS ${_jemalloc_roots} NO_DEFAULT_PATH
+        PATH_SUFFIXES "lib" )
 else ()
     find_path( JEMALLOC_INCLUDE_DIR NAMES jemalloc/jemalloc.h )
     message(STATUS ${JEMALLOC_INCLUDE_DIR})
     find_library( JEMALLOC_SHARED_LIB NAMES ${LIBJEMALLOC_NAMES})
     message(STATUS ${JEMALLOC_SHARED_LIB})
+    find_library( JEMALLOC_STATIC_LIB NAMES jemalloc_pic)
+    message(STATUS ${JEMALLOC_STATIC_LIB})
 endif ()
 
 if (JEMALLOC_INCLUDE_DIR AND JEMALLOC_SHARED_LIB)

http://git-wip-us.apache.org/repos/asf/arrow/blob/8d917c1f/cpp/src/arrow/jemalloc/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/jemalloc/CMakeLists.txt b/cpp/src/arrow/jemalloc/CMakeLists.txt
index c6663eb..c0f90eb 100644
--- a/cpp/src/arrow/jemalloc/CMakeLists.txt
+++ b/cpp/src/arrow/jemalloc/CMakeLists.txt
@@ -23,18 +23,24 @@ include_directories(SYSTEM "{JEMALLOC_INCLUDE_DIR}")
 # arrow_jemalloc library
 set(ARROW_JEMALLOC_STATIC_LINK_LIBS
   arrow_static
-  jemalloc
+  jemalloc_static
 )
+
+if (NOT APPLE)
+  set(ARROW_JEMALLOC_STATIC_LINK_LIBS ${ARROW_JEMALLOC_STATIC_LINK_LIBS} pthread)
+endif()
+
 set(ARROW_JEMALLOC_SHARED_LINK_LIBS
   arrow_shared
-  jemalloc
+  jemalloc_shared
 )
 
 if (ARROW_BUILD_STATIC)
   set(ARROW_JEMALLOC_TEST_LINK_LIBS
+    ${ARROW_JEMALLOC_STATIC_LINK_LIBS}
     arrow_jemalloc_static)
 else()
-  set(ARROW_jemalloc_TEST_LINK_LIBS
+  set(ARROW_JEMALLOC_TEST_LINK_LIBS
     arrow_jemalloc_shared)
 endif()
 


Mime
View raw message