diff --git a/CMakeLists.txt b/CMakeLists.txt index e4dff04..9a8daa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ option(SNMALLOC_NO_REALLOCARR "Build without reallocarr exported" ON) option(SNMALLOC_LINK_ICF "Link with Identical Code Folding" ON) option(SNMALLOC_IPO "Link with IPO/LTO support" OFF) option(SNMALLOC_BENCHMARK_INDIVIDUAL_MITIGATIONS "Build tests and ld_preload for individual mitigations" OFF) +option(SNMALLOC_ENABLE_DYNAMIC_LOADING "Build such that snmalloc can be dynamically loaded. This is not required for LD_PRELOAD, and will harm performance if enabled." OFF) # Options that apply only if we're not building the header-only library cmake_dependent_option(SNMALLOC_RUST_SUPPORT "Build static library for rust" OFF "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF) cmake_dependent_option(SNMALLOC_STATIC_LIBRARY "Build static libraries" ON "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF) @@ -396,7 +397,8 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY) target_compile_options(${name} PRIVATE -mprfchw) endif() # Static TLS model is unsupported on Haiku. - if (NOT CMAKE_SYSTEM_NAME STREQUAL "Haiku") + if ((NOT CMAKE_SYSTEM_NAME STREQUAL "Haiku") AND (NOT SNMALLOC_ENABLE_DYNAMIC_LOADING)) + message(STATUS "snmalloc: Using static TLS model") target_compile_options(${name} PRIVATE -ftls-model=initial-exec) target_compile_options(${name} PRIVATE $<$:-g>) endif()