mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #2465 from fwalch/fix-jemalloc
Force je_ prefix for jemalloc functions, small CMake fixes.
This commit is contained in:
commit
b427dcdda2
@ -190,38 +190,25 @@ include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS})
|
||||
find_package(LuaJit REQUIRED)
|
||||
include_directories(SYSTEM ${LUAJIT_INCLUDE_DIRS})
|
||||
|
||||
option(LIBUNIBILIUM_USE_STATIC "Use static libunibilium" ON)
|
||||
find_package(LibUnibilium REQUIRED)
|
||||
include_directories(SYSTEM ${LIBUNIBILIUM_INCLUDE_DIRS})
|
||||
find_package(Unibilium REQUIRED)
|
||||
include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS})
|
||||
|
||||
option(LIBTERMKEY_USE_STATIC "Use static libtermkey" ON)
|
||||
find_package(LibTermkey REQUIRED)
|
||||
include_directories(SYSTEM ${LIBTERMKEY_INCLUDE_DIRS})
|
||||
|
||||
option(LIBVTERM_USE_STATIC "Use static libvterm" ON)
|
||||
find_package(LibVterm REQUIRED)
|
||||
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)
|
||||
option(JEMALLOC_USE_STATIC "Use static jemalloc" ON)
|
||||
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()
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
# JEMALLOC_INCLUDE_DIRS - The jemalloc include directories
|
||||
# JEMALLOC_LIBRARIES - The libraries needed to use jemalloc
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(NOT JEMALLOC_USE_BUNDLED)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
|
@ -4,7 +4,6 @@
|
||||
# LIBTERMKEY_INCLUDE_DIRS - The libtermkey include directories
|
||||
# LIBTERMKEY_LIBRARIES - The libraries needed to use libtermkey
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(NOT LIBTERMKEY_USE_BUNDLED)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
|
@ -1,48 +0,0 @@
|
||||
# - Try to find libunibilium
|
||||
# Once done this will define
|
||||
# LIBUNIBILIUM_FOUND - System has libunibilium
|
||||
# LIBUNIBILIUM_INCLUDE_DIRS - The libunibilium include directories
|
||||
# LIBUNIBILIUM_LIBRARIES - The libraries needed to use libunibilium
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(NOT LIBUNIBILIUM_USE_BUNDLED)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_LIBUNIBILIUM QUIET unibilium)
|
||||
endif()
|
||||
else()
|
||||
set(PC_LIBUNIBILIUM_INCLUDEDIR)
|
||||
set(PC_LIBUNIBILIUM_INCLUDE_DIRS)
|
||||
set(PC_LIBUNIBILIUM_LIBDIR)
|
||||
set(PC_LIBUNIBILIUM_LIBRARY_DIRS)
|
||||
set(LIMIT_SEARCH NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
set(LIBUNIBILIUM_DEFINITIONS ${PC_LIBUNIBILIUM_CFLAGS_OTHER})
|
||||
|
||||
find_path(LIBUNIBILIUM_INCLUDE_DIR unibilium.h
|
||||
PATHS ${PC_LIBUNIBILIUM_INCLUDEDIR} ${PC_LIBUNIBILIUM_INCLUDE_DIRS}
|
||||
${LIMIT_SEARCH})
|
||||
|
||||
# If we're asked to use static linkage, add libuv.a as a preferred library name.
|
||||
if(LIBUNIBILIUM_USE_STATIC)
|
||||
list(APPEND LIBUNIBILIUM_NAMES
|
||||
"${CMAKE_STATIC_LIBRARY_PREFIX}unibilium${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif()
|
||||
|
||||
list(APPEND LIBUNIBILIUM_NAMES unibilium)
|
||||
|
||||
find_library(LIBUNIBILIUM_LIBRARY NAMES ${LIBUNIBILIUM_NAMES}
|
||||
HINTS ${PC_LIBUNIBILIUM_LIBDIR} ${PC_LIBUNIBILIUM_LIBRARY_DIRS}
|
||||
${LIMIT_SEARCH})
|
||||
|
||||
set(LIBUNIBILIUM_LIBRARIES ${LIBUNIBILIUM_LIBRARY})
|
||||
set(LIBUNIBILIUM_INCLUDE_DIRS ${LIBUNIBILIUM_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LIBUNIBILIUM_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(LibUnibilium DEFAULT_MSG
|
||||
LIBUNIBILIUM_LIBRARY LIBUNIBILIUM_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBUNIBILIUM_INCLUDE_DIR LIBUNIBILIUM_LIBRARY)
|
@ -4,7 +4,6 @@
|
||||
# LIBVTERM_INCLUDE_DIRS - The libvterm include directories
|
||||
# LIBVTERM_LIBRARIES - The libraries needed to use libvterm
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(NOT LIBVTERM_USE_BUNDLED)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
|
@ -4,7 +4,6 @@
|
||||
# LUAJIT_INCLUDE_DIRS - The luajit include directories
|
||||
# LUAJIT_LIBRARIES - The libraries needed to use luajit
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(NOT LUAJIT_USE_BUNDLED)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
|
@ -4,7 +4,6 @@
|
||||
# MSGPACK_INCLUDE_DIRS - The msgpack include directories
|
||||
# MSGPACK_LIBRARIES - The libraries needed to use msgpack
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(NOT MSGPACK_USE_BUNDLED)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
|
47
cmake/FindUnibilium.cmake
Normal file
47
cmake/FindUnibilium.cmake
Normal file
@ -0,0 +1,47 @@
|
||||
# - Try to find unibilium
|
||||
# Once done this will define
|
||||
# UNIBILIUM_FOUND - System has unibilium
|
||||
# UNIBILIUM_INCLUDE_DIRS - The unibilium include directories
|
||||
# UNIBILIUM_LIBRARIES - The libraries needed to use unibilium
|
||||
|
||||
if(NOT UNIBILIUM_USE_BUNDLED)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_UNIBILIUM QUIET unibilium)
|
||||
endif()
|
||||
else()
|
||||
set(PC_UNIBILIUM_INCLUDEDIR)
|
||||
set(PC_UNIBILIUM_INCLUDE_DIRS)
|
||||
set(PC_UNIBILIUM_LIBDIR)
|
||||
set(PC_UNIBILIUM_LIBRARY_DIRS)
|
||||
set(LIMIT_SEARCH NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
set(UNIBILIUM_DEFINITIONS ${PC_UNIBILIUM_CFLAGS_OTHER})
|
||||
|
||||
find_path(UNIBILIUM_INCLUDE_DIR unibilium.h
|
||||
PATHS ${PC_UNIBILIUM_INCLUDEDIR} ${PC_UNIBILIUM_INCLUDE_DIRS}
|
||||
${LIMIT_SEARCH})
|
||||
|
||||
# If we're asked to use static linkage, add libunibilium.a as a preferred library name.
|
||||
if(UNIBILIUM_USE_STATIC)
|
||||
list(APPEND UNIBILIUM_NAMES
|
||||
"${CMAKE_STATIC_LIBRARY_PREFIX}unibilium${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif()
|
||||
|
||||
list(APPEND UNIBILIUM_NAMES unibilium)
|
||||
|
||||
find_library(UNIBILIUM_LIBRARY NAMES ${UNIBILIUM_NAMES}
|
||||
HINTS ${PC_UNIBILIUM_LIBDIR} ${PC_UNIBILIUM_LIBRARY_DIRS}
|
||||
${LIMIT_SEARCH})
|
||||
|
||||
set(UNIBILIUM_LIBRARIES ${UNIBILIUM_LIBRARY})
|
||||
set(UNIBILIUM_INCLUDE_DIRS ${UNIBILIUM_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set UNIBILIUM_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(unibilium DEFAULT_MSG
|
||||
UNIBILIUM_LIBRARY UNIBILIUM_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(UNIBILIUM_INCLUDE_DIR UNIBILIUM_LIBRARY)
|
@ -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
|
||||
|
@ -163,7 +163,7 @@ list(APPEND NVIM_LINK_LIBRARIES
|
||||
${LUAJIT_LIBRARIES}
|
||||
${LIBVTERM_LIBRARIES}
|
||||
${LIBTERMKEY_LIBRARIES}
|
||||
${LIBUNIBILIUM_LIBRARIES}
|
||||
${UNIBILIUM_LIBRARIES}
|
||||
m
|
||||
util
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
@ -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,18 +14,20 @@
|
||||
#include "nvim/misc1.h"
|
||||
#include "nvim/ui.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "memory.c.generated.h"
|
||||
#endif
|
||||
|
||||
#if defined(USE_JEMALLOC) && !defined(UNIT_TESTING)
|
||||
#include "jemalloc/jemalloc.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
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "memory.c.generated.h"
|
||||
#endif
|
||||
|
||||
/// Try to free memory. Used when trying to recover from out of memory errors.
|
||||
/// @see {xmalloc}
|
||||
static void try_to_free_memory(void)
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
9
third-party/CMakeLists.txt
vendored
9
third-party/CMakeLists.txt
vendored
@ -109,6 +109,13 @@ if(USE_BUNDLED_JEMALLOC)
|
||||
include(BuildJeMalloc)
|
||||
endif()
|
||||
|
||||
add_custom_target(clean-shared-libraries
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DREMOVE_FILE_GLOB=${DEPS_INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}*${CMAKE_SHARED_LIBRARY_SUFFIX}*
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RemoveFiles.cmake
|
||||
DEPENDS ${THIRD_PARTY_DEPS}
|
||||
)
|
||||
|
||||
add_custom_target(third-party ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E touch .third-party
|
||||
DEPENDS ${THIRD_PARTY_DEPS})
|
||||
DEPENDS clean-shared-libraries)
|
||||
|
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)
|
||||
|
||||
|
4
third-party/cmake/BuildMsgpack.cmake
vendored
4
third-party/cmake/BuildMsgpack.cmake
vendored
@ -17,8 +17,6 @@ ExternalProject_Add(msgpack
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC"
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build .
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND}
|
||||
-DREMOVE_FILE_GLOB=${DEPS_INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}msgpack*${CMAKE_SHARED_LIBRARY_SUFFIX}*
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/InstallMsgpack.cmake)
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install)
|
||||
list(APPEND THIRD_PARTY_DEPS msgpack)
|
||||
|
||||
|
12
third-party/cmake/InstallMsgpack.cmake
vendored
12
third-party/cmake/InstallMsgpack.cmake
vendored
@ -1,12 +0,0 @@
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build . --target install
|
||||
RESULT_VARIABLE res)
|
||||
|
||||
if(NOT res EQUAL 0)
|
||||
message(FATAL_ERROR "Installing msgpack failed.")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE FILES_TO_REMOVE ${REMOVE_FILE_GLOB})
|
||||
if(FILES_TO_REMOVE)
|
||||
file(REMOVE ${FILES_TO_REMOVE})
|
||||
endif()
|
5
third-party/cmake/RemoveFiles.cmake
vendored
Normal file
5
third-party/cmake/RemoveFiles.cmake
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
file(GLOB_RECURSE FILES_TO_REMOVE ${REMOVE_FILE_GLOB})
|
||||
|
||||
if(FILES_TO_REMOVE)
|
||||
file(REMOVE ${FILES_TO_REMOVE})
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user