Add ifunc check to CMakeLists.txt

CMake build system will now verify if __attribute__((__ifunc__())) can be
used in the build system. If so, HAVE_FUNC_ATTRIBUTE_IFUNC will be
defined to 1.
This commit is contained in:
Hans Jansen 2023-06-22 19:49:30 +02:00 committed by Lasse Collin
parent 23b5c36fb7
commit b72d212024
1 changed files with 19 additions and 0 deletions

View File

@ -763,6 +763,25 @@ check_c_source_compiles("
cmake_pop_check_state()
tuklib_add_definition_if(liblzma HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR)
# Check for __attribute__((__ifunc__())) support.
option(CHECK_ATTR_IFUNC "Use __attribute__((__ifunc__())) if supported by \
the system" ON)
if (CHECK_ATTR_IFUNC)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "-Werror")
check_c_source_compiles("
static void func(void) { return; }
static void (*resolve_func (void)) (void) { return func; }
void func_ifunc (void)
__attribute__ ((__ifunc__ (\"resolve_func\")));
int main(void) { return 0; }
"
HAVE_FUNC_ATTRIBUTE_IFUNC)
cmake_pop_check_state()
tuklib_add_definition_if(liblzma HAVE_FUNC_ATTRIBUTE_IFUNC)
endif()
# cpuid.h
check_include_file(cpuid.h HAVE_CPUID_H)
tuklib_add_definition_if(liblzma HAVE_CPUID_H)