From eb0f1450ad9f23dac03050d9c8375980240aee21 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 14 Nov 2022 16:00:52 +0200 Subject: 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. --- CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'CMakeLists.txt') 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) -- cgit v1.2.3