Skip to content

Commit

Permalink
Enhance the ifunc attribute check and sync with upstream
Browse files Browse the repository at this point in the history
Clang 19 has fixed the false warning of unused function resolve_foo:
llvm/llvm-project#87130
  • Loading branch information
petk committed May 19, 2024
1 parent 3497c1f commit 42899db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions cmake/cmake/modules/PHP/CheckAttribute.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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} [[
Expand Down
2 changes: 1 addition & 1 deletion cmake/main/php_config.cmake.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 42899db

Please sign in to comment.