Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP link jemalloc statically #495

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- run:
name: Installing dependencies (common)
command: |
sudo apt-get install -y libboost-dev
sudo apt-get install -y libboost-dev libjemalloc-dev
- when:
condition:
equal: [ "gcc", << parameters.compiler >> ]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ jobs:

- name: Setup common dependencies for Linux
run: |
sudo apt-get install -y libboost-dev libc6-dev-i386
sudo apt-get install -y libboost-dev libc6-dev-i386 libjemalloc-dev
sudo apt-get remove clang-tidy-11
if: runner.os == 'Linux'

Expand Down Expand Up @@ -268,7 +268,7 @@ jobs:

- name: Set up dependencies for macOS (common)
run: |
brew install boost
brew install boost jemalloc
if: runner.os == 'macOS'

- name: Set up dependencies for macOS (coverage)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/experimental-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up dependencies for macOS
run: |
brew update
brew install boost cppcheck iwyu
brew install boost cppcheck iwyu jemalloc

- name: Create build environment
run: mkdir ${{github.workspace}}/build
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/msvc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ jobs:
platform_version: 2019
toolset: msvc

- name: Install jemalloc
run: |
vcpkg install jemalloc

- name: Setup command line tools
uses: ilammy/msvc-dev-cmd@v1

- name: Configure CMake
run: cmake --preset "${{ matrix.preset }}"
run: |
$env:PKG_CONFIG_PATH += ";C:\vcpkg\packages\jemalloc_x86-windows\lib\pkgconfig"
cmake --preset "${{ matrix.preset }}"
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/old-compilers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ jobs:

- name: Setup common dependencies for Linux
run: |
sudo apt-get install -y libboost-dev libc6-dev-i386
sudo apt-get install -y libboost-dev libc6-dev-i386 libjemalloc-dev
if: runner.os == 'Linux'

- name: Setup dependencies for Linux LLVM 11 & 12
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Setup dependencies
run: |
sudo add-apt-repository -y 'ppa:mhier/libboost-latest'
sudo apt-get install -y boost1.74
sudo apt-get install -y boost1.74 libjemalloc-dev

- name: Produce Compilation Database
shell: bash
Expand Down
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,22 @@ find_package(Threads REQUIRED)

find_package(Boost REQUIRED)

# Enable statically-linked jemalloc for Apple Silicon once
# https://github.com/jemalloc/jemalloc/issues/2051 is fixed
if(NOT("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin"
AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64"))
set(USE_JEMALLOC ON)
else()
set(USE_JEMALLOC OFF)
endif()

if(USE_JEMALLOC)
find_package(PkgConfig REQUIRED)

pkg_check_modules(JEMALLOC jemalloc)
pkg_search_module(JEMALLOC REQUIRED jemalloc)
endif()

string(REPLACE ";" " " CXX_FLAGS_FOR_SUBDIR_STR "${SANITIZER_CXX_FLAGS}")
if(MSVC)
string(REPLACE ";" " " MSVC_WARNING_FLAGS_FOR_SUBDIR_STR_TMP "${MSVC_CXX_WARNING_FLAGS}")
Expand Down Expand Up @@ -395,6 +411,7 @@ set(is_clang_ge_13_not_windows "$<AND:${is_clang_not_windows},${cxx_ge_13}>")
set(is_clang_ge_14_not_windows "$<AND:${is_clang_not_windows},${cxx_ge_14}>")
set(is_gxx_ge_11 "$<AND:${is_gxx},${cxx_ge_11}>")
set(is_gxx_ge_12 "$<AND:${is_gxx},${cxx_ge_12}>")
set(has_jemalloc "$<BOOL:${USE_JEMALLOC}>")
set(has_avx2 "$<BOOL:${AVX2}>")
set(fatal_warnings_on "$<BOOL:${FATAL_WARNINGS}>")
set(coverage_on "$<BOOL:${COVERAGE}>")
Expand Down Expand Up @@ -496,6 +513,9 @@ function(COMMON_TARGET_PROPERTIES TARGET)
set_target_properties(${TARGET} PROPERTIES CXX_EXTENSIONS OFF)
target_compile_definitions(${TARGET} PRIVATE
"$<${is_standalone}:UNODB_DETAIL_STANDALONE>")
target_compile_definitions(${TARGET} PRIVATE
# FIXME(laurynas): UNODB_DETAIL_USE_SIZED_FREE
"$<${has_jemalloc}:UNODB_DETAIL_USE_JEMALLOC>")
target_compile_options(${TARGET} PRIVATE
"${CXX_FLAGS}" "${SANITIZER_CXX_FLAGS}"
"$<${is_msvc}:${MSVC_CXX_FLAGS}>"
Expand All @@ -520,6 +540,8 @@ function(COMMON_TARGET_PROPERTIES TARGET)
"$<$<AND:${is_release},${is_not_windows}>:$<IF:${coverage_on},-O0,-O3>>"
# Misc
"$<${coverage_on}:--coverage>")
target_link_libraries(${TARGET} PRIVATE
"$<${has_jemalloc}:${JEMALLOC_LDFLAGS}>")
# Change to target_link_options on 3.13 minimum CMake version
target_link_libraries(${TARGET} INTERFACE "$<${coverage_on}:--coverage>")
target_link_libraries(${TARGET} PRIVATE
Expand Down