parent
022c15d437
commit
5a19eddd45
9 changed files with 124 additions and 47 deletions
|
|
@ -5,6 +5,9 @@
|
|||
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
|
||||
add_subdirectory(external)
|
||||
if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
|
||||
add_subdirectory(linux_jemalloc_helper)
|
||||
endif()
|
||||
if (DESKTOP_APP_USE_ALLOCATION_TRACER)
|
||||
add_subdirectory(linux_allocation_tracer)
|
||||
endif()
|
||||
|
|
|
|||
6
external/CMakeLists.txt
vendored
6
external/CMakeLists.txt
vendored
|
|
@ -38,6 +38,9 @@ if (add_hunspell_library)
|
|||
add_checked_subdirectory(hunspell)
|
||||
endif()
|
||||
add_checked_subdirectory(iconv)
|
||||
if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
|
||||
add_checked_subdirectory(jemalloc)
|
||||
endif()
|
||||
add_checked_subdirectory(jpeg)
|
||||
add_checked_subdirectory(kcoreaddons)
|
||||
add_checked_subdirectory(kimageformats)
|
||||
|
|
@ -54,9 +57,6 @@ add_checked_subdirectory(qr_code_generator)
|
|||
add_checked_subdirectory(ranges)
|
||||
add_checked_subdirectory(rlottie)
|
||||
add_checked_subdirectory(rnnoise)
|
||||
if (LINUX AND NOT DESKTOP_APP_DISABLE_SCUDO)
|
||||
add_checked_subdirectory(scudo)
|
||||
endif()
|
||||
add_checked_subdirectory(ton)
|
||||
add_checked_subdirectory(variant)
|
||||
add_checked_subdirectory(vpx)
|
||||
|
|
|
|||
65
external/jemalloc/CMakeLists.txt
vendored
Normal file
65
external/jemalloc/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# This file is part of Desktop App Toolkit,
|
||||
# a set of libraries for developing nice desktop applications.
|
||||
#
|
||||
# For license and copyright information please follow this link:
|
||||
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
|
||||
add_library(external_jemalloc INTERFACE IMPORTED GLOBAL)
|
||||
add_library(desktop-app::external_jemalloc ALIAS external_jemalloc)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (DESKTOP_APP_USE_PACKAGED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(JEMALLOC jemalloc)
|
||||
|
||||
if (JEMALLOC_FOUND)
|
||||
target_include_directories(external_jemalloc SYSTEM
|
||||
INTERFACE
|
||||
${JEMALLOC_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(external_jemalloc
|
||||
INTERFACE
|
||||
-Wl,--push-state,--no-as-needed,${JEMALLOC_LINK_LIBRARIES},--pop-state
|
||||
)
|
||||
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(N)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(jemalloc
|
||||
URL ${third_party_loc}/jemalloc
|
||||
CONFIGURE_COMMAND env
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
"$<IF:$<OR:$<NOT:$<BOOL:${DESKTOP_APP_USE_PACKAGED}>>,$<BOOL:${DESKTOP_APP_SPECIAL_TARGET}>>,EXTRA_CFLAGS=-fno-omit-frame-pointer -fstack-protector-all -fstack-clash-protection -fcf-protection -DNDEBUG -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS,=>"
|
||||
"$<IF:$<OR:$<NOT:$<BOOL:${DESKTOP_APP_USE_PACKAGED}>>,$<BOOL:${DESKTOP_APP_SPECIAL_TARGET}>>,EXTRA_CXXFLAGS=-fno-omit-frame-pointer -fstack-protector-all -fstack-clash-protection -fcf-protection -DNDEBUG -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS,=>"
|
||||
./autogen.sh --disable-shared
|
||||
BUILD_COMMAND make $<$<NOT:$<EQUAL:${N},0>>:-j${N}>
|
||||
BUILD_IN_SOURCE 1
|
||||
STEP_TARGETS build
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
BUILD_BYPRODUCTS <SOURCE_DIR>/lib/libjemalloc_pic.a
|
||||
)
|
||||
|
||||
ExternalProject_Get_property(jemalloc SOURCE_DIR)
|
||||
file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
|
||||
|
||||
target_include_directories(external_jemalloc SYSTEM
|
||||
INTERFACE
|
||||
${SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries(external_jemalloc
|
||||
INTERFACE
|
||||
-Wl,--push-state,--whole-archive,${SOURCE_DIR}/lib/libjemalloc_pic.a,--pop-state
|
||||
)
|
||||
|
||||
add_dependencies(external_jemalloc jemalloc-build)
|
||||
35
external/scudo/CMakeLists.txt
vendored
35
external/scudo/CMakeLists.txt
vendored
|
|
@ -1,35 +0,0 @@
|
|||
# This file is part of Desktop App Toolkit,
|
||||
# a set of libraries for developing nice desktop applications.
|
||||
#
|
||||
# For license and copyright information please follow this link:
|
||||
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
|
||||
add_library(external_scudo STATIC)
|
||||
add_library(desktop-app::external_scudo ALIAS external_scudo)
|
||||
init_target(external_scudo "(external)")
|
||||
|
||||
set(scudo_loc ${third_party_loc}/scudo)
|
||||
|
||||
# https://llvm.org/docs/ScudoHardenedAllocator.html#library
|
||||
file(GLOB scudo_srcs ${scudo_loc}/*.cpp)
|
||||
target_sources(external_scudo
|
||||
PRIVATE
|
||||
${scudo_srcs}
|
||||
)
|
||||
|
||||
target_include_directories(external_scudo SYSTEM
|
||||
PRIVATE
|
||||
${scudo_loc}/include
|
||||
)
|
||||
|
||||
add_library(external_scudo_options INTERFACE)
|
||||
target_compile_options(external_scudo_options
|
||||
INTERFACE
|
||||
-fno-lto
|
||||
-Wno-unused-result
|
||||
)
|
||||
|
||||
target_link_libraries(external_scudo
|
||||
PRIVATE
|
||||
external_scudo_options
|
||||
)
|
||||
|
|
@ -27,14 +27,6 @@ function(init_target target_name) # init_target(my_target [cxx_std_..] folder_na
|
|||
set_property(TARGET ${target_name} APPEND_STRING PROPERTY STATIC_LIBRARY_OPTIONS "$<IF:$<CONFIG:Debug>,,/LTCG>")
|
||||
endif()
|
||||
|
||||
if (LINUX AND NOT DESKTOP_APP_DISABLE_SCUDO AND NOT target_name STREQUAL external_scudo)
|
||||
add_dependencies(${target_name} desktop-app::external_scudo)
|
||||
target_link_options(${target_name}
|
||||
PRIVATE
|
||||
-Wl,--push-state,--whole-archive,$<TARGET_FILE:desktop-app::external_scudo>,--pop-state
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${target_name} PRIVATE desktop-app::common_options)
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES
|
||||
|
|
|
|||
19
linux_jemalloc_helper/CMakeLists.txt
Normal file
19
linux_jemalloc_helper/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# This file is part of Desktop App Toolkit,
|
||||
# a set of libraries for developing nice desktop applications.
|
||||
#
|
||||
# For license and copyright information please follow this link:
|
||||
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
|
||||
add_library(linux_jemalloc_helper OBJECT)
|
||||
init_target(linux_jemalloc_helper "(external)")
|
||||
add_library(desktop-app::linux_jemalloc_helper ALIAS linux_jemalloc_helper)
|
||||
|
||||
nice_target_sources(linux_jemalloc_helper ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE
|
||||
linux_jemalloc_helper.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(linux_jemalloc_helper
|
||||
PRIVATE
|
||||
desktop-app::external_jemalloc
|
||||
)
|
||||
25
linux_jemalloc_helper/linux_jemalloc_helper.cpp
Normal file
25
linux_jemalloc_helper/linux_jemalloc_helper.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// This file is part of Desktop App Toolkit,
|
||||
// a set of libraries for developing nice desktop applications.
|
||||
//
|
||||
// For license and copyright information please follow this link:
|
||||
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
//
|
||||
#ifdef __FreeBSD__
|
||||
#include <malloc_np.h>
|
||||
#else // __FreeBSD__
|
||||
#include <jemalloc/jemalloc.h>
|
||||
#endif // !__FreeBSD__
|
||||
|
||||
namespace {
|
||||
|
||||
class JemallocInitializer {
|
||||
public:
|
||||
JemallocInitializer() {
|
||||
auto backgroundThread = true;
|
||||
mallctl("background_thread", nullptr, nullptr, &backgroundThread, sizeof(bool));
|
||||
}
|
||||
};
|
||||
|
||||
static const JemallocInitializer initializer;
|
||||
|
||||
} // namespace
|
||||
|
|
@ -99,6 +99,14 @@ if (NOT DESKTOP_APP_USE_PACKAGED OR DESKTOP_APP_SPECIAL_TARGET)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (NOT DESKTOP_APP_DISABLE_JEMALLOC)
|
||||
target_link_libraries(common_options
|
||||
INTERFACE
|
||||
$<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
|
||||
$<LINK_ONLY:desktop-app::external_jemalloc>
|
||||
)
|
||||
endif()
|
||||
|
||||
if (DESKTOP_APP_USE_ALLOCATION_TRACER)
|
||||
target_link_options(common_options
|
||||
INTERFACE
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ option(DESKTOP_APP_ASAN "Enable address sanitizer" OFF)
|
|||
cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell." OFF LINUX OFF)
|
||||
cmake_dependent_option(DESKTOP_APP_USE_CLD3 "Disable system text language recognition and use bundled cld3 only." OFF APPLE ON)
|
||||
cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF)
|
||||
cmake_dependent_option(DESKTOP_APP_DISABLE_SCUDO "Disable scudo, use system malloc." OFF "LINUX; NOT DESKTOP_APP_ASAN" ON)
|
||||
cmake_dependent_option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc." OFF "LINUX; NOT DESKTOP_APP_ASAN" ON)
|
||||
|
||||
if (APPLE AND NOT DEFINED DESKTOP_APP_MAC_ARCH)
|
||||
if (DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue