Adding an option to disable TLS (#632)

Signed-off-by: Matthew A Johnson <matjoh@microsoft.com>
This commit is contained in:
Matthew A Johnson 2023-09-13 11:17:10 +01:00 коммит произвёл GitHub
Родитель 7b597335ae
Коммит 35eef33099
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -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 $<$<BOOL:${SNMALLOC_CI_BUILD}>:-g>)
endif()