mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
jemalloc: Force use of prefixed functions.
* Set JEMALLOC_NO_DEMANGLE to be able to use `je_*` functions, regardless of how jemalloc was compiled (--with-jemalloc-prefix) * Show jemalloc information in Neovim's version output. Resolve #2449.
This commit is contained in:
@@ -201,23 +201,14 @@ include_directories(SYSTEM ${LIBVTERM_INCLUDE_DIRS})
|
|||||||
|
|
||||||
option(SANITIZE "Enable Clang sanitizers for nvim binary" OFF)
|
option(SANITIZE "Enable Clang sanitizers for nvim binary" OFF)
|
||||||
if(SANITIZE AND NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
|
if(SANITIZE AND NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
message(WARNING "SANITIZE is only supported for Clang ... disabling")
|
message(WARNING "SANITIZE is only supported for Clang, disabling")
|
||||||
set(SANITIZE OFF)
|
set(SANITIZE OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SANITIZE)
|
if(NOT SANITIZE)
|
||||||
option(USE_JEMALLOC "Use jemalloc" OFF)
|
|
||||||
else()
|
|
||||||
option(USE_JEMALLOC "Use jemalloc" ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_JEMALLOC)
|
|
||||||
find_package(JeMalloc)
|
find_package(JeMalloc)
|
||||||
if(JEMALLOC_FOUND)
|
if(JEMALLOC_FOUND)
|
||||||
message(STATUS "Using jemalloc instead of libc allocator")
|
|
||||||
include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
|
include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
|
||||||
else()
|
|
||||||
set(USE_JEMALLOC OFF)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -46,6 +46,10 @@ if(Iconv_FOUND)
|
|||||||
set(HAVE_ICONV 1)
|
set(HAVE_ICONV 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(JEMALLOC_FOUND)
|
||||||
|
set(HAVE_JEMALLOC 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
check_function_exists(lstat HAVE_LSTAT)
|
check_function_exists(lstat HAVE_LSTAT)
|
||||||
if(NOT HAVE_LSTAT)
|
if(NOT HAVE_LSTAT)
|
||||||
# os_unix.c uses lstat.c
|
# os_unix.c uses lstat.c
|
||||||
|
@@ -66,6 +66,9 @@
|
|||||||
#define FEAT_BROWSE
|
#define FEAT_BROWSE
|
||||||
#define FEAT_CSCOPE
|
#define FEAT_CSCOPE
|
||||||
#define FEAT_MOUSE
|
#define FEAT_MOUSE
|
||||||
#cmakedefine USE_JEMALLOC
|
|
||||||
|
#ifndef UNIT_TESTING
|
||||||
|
#cmakedefine HAVE_JEMALLOC
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // AUTO_CONFIG_H
|
#endif // AUTO_CONFIG_H
|
||||||
|
@@ -171,8 +171,8 @@ list(APPEND NVIM_LINK_LIBRARIES
|
|||||||
|
|
||||||
set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES})
|
set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES})
|
||||||
|
|
||||||
if(USE_JEMALLOC)
|
# Don't use jemalloc in the unit test library.
|
||||||
# dont use jemalloc in the unit test library
|
if(JEMALLOC_FOUND)
|
||||||
list(APPEND NVIM_EXEC_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
|
list(APPEND NVIM_EXEC_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -14,16 +14,18 @@
|
|||||||
#include "nvim/misc1.h"
|
#include "nvim/misc1.h"
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef HAVE_JEMALLOC
|
||||||
# include "memory.c.generated.h"
|
// Force je_ prefix on jemalloc functions.
|
||||||
|
# define JEMALLOC_NO_DEMANGLE
|
||||||
|
# include <jemalloc/jemalloc.h>
|
||||||
|
# define malloc(size) je_malloc(size)
|
||||||
|
# define calloc(count, size) je_calloc(count, size)
|
||||||
|
# define realloc(ptr, size) je_realloc(ptr, size)
|
||||||
|
# define free(ptr) je_free(ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_JEMALLOC) && !defined(UNIT_TESTING)
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
#include "jemalloc/jemalloc.h"
|
# include "memory.c.generated.h"
|
||||||
#define malloc(size) je_malloc(size)
|
|
||||||
#define calloc(count, size) je_calloc(count, size)
|
|
||||||
#define realloc(ptr, size) je_realloc(ptr, size)
|
|
||||||
#define free(ptr) je_free(ptr)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Try to free memory. Used when trying to recover from out of memory errors.
|
/// Try to free memory. Used when trying to recover from out of memory errors.
|
||||||
|
@@ -47,21 +47,25 @@ char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS;
|
|||||||
static char *features[] = {
|
static char *features[] = {
|
||||||
#ifdef HAVE_ACL
|
#ifdef HAVE_ACL
|
||||||
"+acl",
|
"+acl",
|
||||||
#else // ifdef HAVE_ACL
|
#else
|
||||||
"-acl",
|
"-acl",
|
||||||
#endif // ifdef HAVE_ACL
|
#endif
|
||||||
|
|
||||||
#if (defined(HAVE_ICONV_H) && defined(USE_ICONV)) || defined(DYNAMIC_ICONV)
|
#if (defined(HAVE_ICONV_H) && defined(USE_ICONV)) || defined(DYNAMIC_ICONV)
|
||||||
# ifdef DYNAMIC_ICONV
|
# ifdef DYNAMIC_ICONV
|
||||||
"+iconv/dyn",
|
"+iconv/dyn",
|
||||||
# else // ifdef DYNAMIC_ICONV
|
# else
|
||||||
"+iconv",
|
"+iconv",
|
||||||
# endif // ifdef DYNAMIC_ICONV
|
# endif
|
||||||
#else // if (defined(HAVE_ICONV_H) && defined(USE_ICONV))
|
#else
|
||||||
// ||defined(DYNAMIC_ICONV)
|
|
||||||
"-iconv",
|
"-iconv",
|
||||||
#endif // if (defined(HAVE_ICONV_H) && defined(USE_ICONV))
|
#endif
|
||||||
// || defined(DYNAMIC_ICONV)
|
|
||||||
|
#ifdef HAVE_JEMALLOC
|
||||||
|
"+jemalloc",
|
||||||
|
#else
|
||||||
|
"-jemalloc",
|
||||||
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
4
third-party/cmake/BuildJeMalloc.cmake
vendored
4
third-party/cmake/BuildJeMalloc.cmake
vendored
@@ -11,8 +11,8 @@ ExternalProject_Add(jemalloc
|
|||||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
|
||||||
BUILD_IN_SOURCE 1
|
BUILD_IN_SOURCE 1
|
||||||
CONFIGURE_COMMAND sh ${DEPS_BUILD_DIR}/src/jemalloc/autogen.sh &&
|
CONFIGURE_COMMAND sh ${DEPS_BUILD_DIR}/src/jemalloc/autogen.sh &&
|
||||||
${DEPS_BUILD_DIR}/src/jemalloc/configure --with-jemalloc-prefix=je_
|
${DEPS_BUILD_DIR}/src/jemalloc/configure --enable-cc-silence
|
||||||
--enable-cc-silence CC=${DEPS_C_COMPILER} --prefix=${DEPS_INSTALL_DIR}
|
CC=${DEPS_C_COMPILER} --prefix=${DEPS_INSTALL_DIR}
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
INSTALL_COMMAND ${MAKE_PRG} install_include install_lib)
|
INSTALL_COMMAND ${MAKE_PRG} install_include install_lib)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user