From 42899dbfacdb8dd4da9e6e5ea68c7b60678705ed Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 19 May 2024 14:54:10 +0200 Subject: [PATCH] Enhance the ifunc attribute check and sync with upstream Clang 19 has fixed the false warning of unused function resolve_foo: https://github.com/llvm/llvm-project/pull/87130 --- cmake/cmake/modules/PHP/CheckAttribute.cmake | 11 +++++++---- cmake/main/php_config.cmake.h.in | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmake/cmake/modules/PHP/CheckAttribute.cmake b/cmake/cmake/modules/PHP/CheckAttribute.cmake index b7fbda48..9154913e 100644 --- a/cmake/cmake/modules/PHP/CheckAttribute.cmake +++ b/cmake/cmake/modules/PHP/CheckAttribute.cmake @@ -29,14 +29,17 @@ include(CMakePushCheckState) function(_php_check_attribute_get_function_code attribute result) if(attribute STREQUAL "ifunc") + # Clang versions prior to 19 emitted unused function warning for static + # resolvers: https://github.com/llvm/llvm-project/pull/87130 set(${result} [[ int my_foo(void) { return 0; } + #if defined(__clang__) && (__clang_major__ < 19) + int (*resolve_foo(void))(void) { return my_foo; } + #else static int (*resolve_foo(void))(void) { return my_foo; } + #endif int foo(void) __attribute__((ifunc("resolve_foo"))); - int main(void) { - resolve_foo(); - return 0; - } + int main(void) { return 0; } ]]) elseif(attribute STREQUAL "target") set(${result} [[ diff --git a/cmake/main/php_config.cmake.h.in b/cmake/main/php_config.cmake.h.in index b683334b..8b27d604 100644 --- a/cmake/main/php_config.cmake.h.in +++ b/cmake/main/php_config.cmake.h.in @@ -384,7 +384,7 @@ /* Define to 1 if you have the 'asprintf' function. */ #cmakedefine HAVE_ASPRINTF 1 -/* whether the compiler supports __attribute__ ((__aligned__)) */ +/* Define to 1 if the compiler supports the 'aligned' variable attribute. */ #cmakedefine HAVE_ATTRIBUTE_ALIGNED 1 /* Whether you have bcmath */