From 35eef3309976a9e2ca65f4d828a00a9914d53d3d Mon Sep 17 00:00:00 2001 From: Matthew A Johnson Date: Wed, 13 Sep 2023 11:17:10 +0100 Subject: [PATCH] Adding an option to disable TLS (#632) Signed-off-by: Matthew A Johnson --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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()