From b72d21202402a603db6d512fb9271cfa83249639 Mon Sep 17 00:00:00 2001 From: Hans Jansen Date: Thu, 22 Jun 2023 19:49:30 +0200 Subject: [PATCH] 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. --- CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 458ad49d..fb5d2582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)