aboutsummaryrefslogtreecommitdiff
path: root/third-party
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-04-12 11:40:08 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-04-13 08:22:59 -0300
commit8a1a9b9558d6f3e28cc97254c1bacfbc823d05e2 (patch)
tree89ef647267ef31794eeb2f297886e6bde97dcf10 /third-party
parent34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b (diff)
downloadrneovim-8a1a9b9558d6f3e28cc97254c1bacfbc823d05e2.tar.gz
rneovim-8a1a9b9558d6f3e28cc97254c1bacfbc823d05e2.tar.bz2
rneovim-8a1a9b9558d6f3e28cc97254c1bacfbc823d05e2.zip
deps: Add jemalloc as an optional dependency
Jemalloc will be used if the cmake option `USE_JEMALLOC` is enabled(which is the default). To avoid trouble with clang's ASAN, it is disabled by default if the `SANITIZE` option is enabled. Since jemalloc has thread cache for small objects, it fills the gap created by removing klib memory pools. The `xstrdup` funciton(memory.c) had to be reimplemented on top of `xmalloc` to make it work with a custom allocator.
Diffstat (limited to 'third-party')
-rw-r--r--third-party/CMakeLists.txt7
-rw-r--r--third-party/cmake/BuildJeMalloc.cmake19
2 files changed, 26 insertions, 0 deletions
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index 60a53ace8f..fde367bc72 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -13,6 +13,7 @@ set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads")
option(USE_BUNDLED "Use bundled dependencies." ON)
+option(USE_BUNDLED_JEMALLOC "Use the bundled jemalloc." ${USE_BUNDLED})
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
option(USE_BUNDLED_LIBVTERM "Use the bundled libvterm." ${USE_BUNDLED})
@@ -73,6 +74,8 @@ set(LIBTERMKEY_SHA256 21846369081e6c9a0b615f4b3889c4cb809321c5ccc6e6c1640eb138f1
set(LIBVTERM_URL https://github.com/neovim/libvterm/archive/1b745d29d45623aa8d22a7b9288c7b0e331c7088.tar.gz)
set(LIBVTERM_SHA256 3fc75908256c0d158d6c2a32d39f34e86bfd26364f5404b7d9c03bb70cdc3611)
+set(JEMALLOC_URL https://github.com/jemalloc/jemalloc/archive/3.6.0.tar.gz)
+set(JEMALLOC_SHA256 68175f729423305dc8573cb093025a8db525e1956583c7c5924416a9abaaacb6)
if(USE_BUNDLED_UNIBILIUM)
include(BuildUnibilium)
@@ -102,6 +105,10 @@ if(USE_BUNDLED_LUAROCKS)
include(BuildLuarocks)
endif()
+if(USE_BUNDLED_JEMALLOC)
+ include(BuildJeMalloc)
+endif()
+
add_custom_target(third-party ALL
COMMAND ${CMAKE_COMMAND} -E touch .third-party
DEPENDS ${THIRD_PARTY_DEPS})
diff --git a/third-party/cmake/BuildJeMalloc.cmake b/third-party/cmake/BuildJeMalloc.cmake
new file mode 100644
index 0000000000..ceb7de41e9
--- /dev/null
+++ b/third-party/cmake/BuildJeMalloc.cmake
@@ -0,0 +1,19 @@
+ExternalProject_Add(jemalloc
+ PREFIX ${DEPS_BUILD_DIR}
+ URL ${JEMALLOC_URL}
+ DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/jemalloc
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND}
+ -DPREFIX=${DEPS_BUILD_DIR}
+ -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/jemalloc
+ -DURL=${JEMALLOC_URL}
+ -DEXPECTED_SHA256=${JEMALLOC_SHA256}
+ -DTARGET=jemalloc
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND sh ${DEPS_BUILD_DIR}/src/jemalloc/autogen.sh &&
+ ${DEPS_BUILD_DIR}/src/jemalloc/configure --with-jemalloc-prefix=je_
+ --enable-cc-silence CC=${DEPS_C_COMPILER} --prefix=${DEPS_INSTALL_DIR}
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ${MAKE_PRG} install_include install_lib)
+
+list(APPEND THIRD_PARTY_DEPS jemalloc)