From f7f9401cc842824bccc3c79873d6e9f9dfe92997 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 9 Nov 2023 20:44:30 +0100 Subject: [PATCH] Disable -fsanitize=function on Clang 17 Closes GH-12642 --- configure.ac | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/configure.ac b/configure.ac index 0c5304b9e48..91cb9e2fe4c 100644 --- a/configure.ac +++ b/configure.ac @@ -1534,6 +1534,23 @@ if test "$PHP_UNDEFINED_SANITIZER" = "yes"; then AX_CHECK_COMPILE_FLAG([-fsanitize=undefined], [ CFLAGS="$CFLAGS -fsanitize=undefined" CXXFLAGS="$CXXFLAGS -fsanitize=undefined" + + dnl Clang 17 adds stricter function pointer compatibility checks where pointer args cannot be + dnl cast to void*. In that case, set -fno-sanitize=function. + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-sanitize-recover=undefined" + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +void foo(char *string) {} +int main(void) { + void (*f)(void *) = (void (*)(void *))foo; + f("foo"); +} + ]])],,[ubsan_needs_no_function=yes],) + CFLAGS="$OLD_CFLAGS" + if test "$ubsan_needs_no_function" = yes; then + CFLAGS="$CFLAGS -fno-sanitize=function" + CXXFLAGS="$CFLAGS -fno-sanitize=function" + fi ], [AC_MSG_ERROR([UndefinedBehaviorSanitizer is not available])]) fi