diff options
author | Hans Jansen <hansjansen162@outlook.com> | 2023-06-22 19:49:30 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2023-06-27 15:33:15 +0300 |
commit | b72d21202402a603db6d512fb9271cfa83249639 (patch) | |
tree | 1dd16ffe64c12853b89d5f990c1e8a6c3f335026 /CMakeLists.txt | |
parent | Add ifunc check to configure.ac (diff) | |
download | xz-b72d21202402a603db6d512fb9271cfa83249639.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | CMakeLists.txt | 19 |
1 files changed, 19 insertions, 0 deletions
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) |