mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +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)
|
||||
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)
|
||||
endif()
|
||||
|
||||
if(SANITIZE)
|
||||
option(USE_JEMALLOC "Use jemalloc" OFF)
|
||||
else()
|
||||
option(USE_JEMALLOC "Use jemalloc" ON)
|
||||
endif()
|
||||
|
||||
if(USE_JEMALLOC)
|
||||
if(NOT SANITIZE)
|
||||
find_package(JeMalloc)
|
||||
if(JEMALLOC_FOUND)
|
||||
message(STATUS "Using jemalloc instead of libc allocator")
|
||||
include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
|
||||
else()
|
||||
set(USE_JEMALLOC OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -46,6 +46,10 @@ if(Iconv_FOUND)
|
||||
set(HAVE_ICONV 1)
|
||||
endif()
|
||||
|
||||
if(JEMALLOC_FOUND)
|
||||
set(HAVE_JEMALLOC 1)
|
||||
endif()
|
||||
|
||||
check_function_exists(lstat HAVE_LSTAT)
|
||||
if(NOT HAVE_LSTAT)
|
||||
# os_unix.c uses lstat.c
|
||||
|
@ -66,6 +66,9 @@
|
||||
#define FEAT_BROWSE
|
||||
#define FEAT_CSCOPE
|
||||
#define FEAT_MOUSE
|
||||
#cmakedefine USE_JEMALLOC
|
||||
|
||||
#ifndef UNIT_TESTING
|
||||
#cmakedefine HAVE_JEMALLOC
|
||||
#endif
|
||||
|
||||
#endif // AUTO_CONFIG_H
|
||||
|
@ -171,8 +171,8 @@ list(APPEND NVIM_LINK_LIBRARIES
|
||||
|
||||
set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES})
|
||||
|
||||
if(USE_JEMALLOC)
|
||||
# dont use jemalloc in the unit test library
|
||||
# Don't use jemalloc in the unit test library.
|
||||
if(JEMALLOC_FOUND)
|
||||
list(APPEND NVIM_EXEC_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
@ -14,16 +14,18 @@
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/ui.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "memory.c.generated.h"
|
||||
#ifdef HAVE_JEMALLOC
|
||||
// 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
|
||||
|
||||
#if defined(USE_JEMALLOC) && !defined(UNIT_TESTING)
|
||||
#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)
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "memory.c.generated.h"
|
||||
#endif
|
||||
|
||||
/// 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[] = {
|
||||
#ifdef HAVE_ACL
|
||||
"+acl",
|
||||
#else // ifdef HAVE_ACL
|
||||
#else
|
||||
"-acl",
|
||||
#endif // ifdef HAVE_ACL
|
||||
#endif
|
||||
|
||||
#if (defined(HAVE_ICONV_H) && defined(USE_ICONV)) || defined(DYNAMIC_ICONV)
|
||||
# ifdef DYNAMIC_ICONV
|
||||
"+iconv/dyn",
|
||||
# else // ifdef DYNAMIC_ICONV
|
||||
# else
|
||||
"+iconv",
|
||||
# endif // ifdef DYNAMIC_ICONV
|
||||
#else // if (defined(HAVE_ICONV_H) && defined(USE_ICONV))
|
||||
// ||defined(DYNAMIC_ICONV)
|
||||
# endif
|
||||
#else
|
||||
"-iconv",
|
||||
#endif // if (defined(HAVE_ICONV_H) && defined(USE_ICONV))
|
||||
// || defined(DYNAMIC_ICONV)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_JEMALLOC
|
||||
"+jemalloc",
|
||||
#else
|
||||
"-jemalloc",
|
||||
#endif
|
||||
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
|
||||
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}
|
||||
${DEPS_BUILD_DIR}/src/jemalloc/configure --enable-cc-silence
|
||||
CC=${DEPS_C_COMPILER} --prefix=${DEPS_INSTALL_DIR}
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ${MAKE_PRG} install_include install_lib)
|
||||
|
||||
|
Reference in New Issue
Block a user