diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2022-11-14 16:00:52 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-11-14 16:00:52 +0200 |
commit | eb0f1450ad9f23dac03050d9c8375980240aee21 (patch) | |
tree | 2ccb523dc0277999d3629bad18e0c2e819d33b64 /CMakeLists.txt | |
parent | Translations: Update the Romanian translation. (diff) | |
download | xz-eb0f1450ad9f23dac03050d9c8375980240aee21.tar.xz |
liblzma: Use __attribute__((__constructor__)) if available.
This uses it for CRC table initializations when using --disable-small.
It avoids mythread_once() overhead. It also means that then
--disable-small --disable-threads is thread-safe if this attribute
is supported.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e3af3bf6..11f3a055 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ cmake_minimum_required(VERSION 3.13...3.16 FATAL_ERROR) +include(CMakePushCheckState) include(CheckSymbolExists) include(CheckStructHasMember) include(cmake/tuklib_integer.cmake) @@ -387,6 +388,20 @@ if(NOT TUKLIB_CPUCORES_FOUND OR NOT TUKLIB_PHYSMEM_FOUND) "To build anyway, edit this CMakeLists.txt to ignore this error.") endif() +# Check for __attribute__((__constructor__)) support. +# This needs -Werror because some compilers just warn +# about this being unsupported. +cmake_push_check_state() +set(CMAKE_REQUIRED_FLAGS "-Werror") +check_c_source_compiles(" + __attribute__((__constructor__)) + static void my_constructor_func(void) { return; } + int main(void) { return 0; } + " + HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR) +cmake_pop_check_state() +tuklib_add_definition_if(liblzma HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR) + # immintrin.h: include(CheckIncludeFile) check_include_file(immintrin.h HAVE_IMMINTRIN_H) |