Skip to content

Commit f7f9401

Browse files
iluuu1994ramsey
authored andcommitted
Disable -fsanitize=function on Clang 17
Closes GH-12642
1 parent db8c91a commit f7f9401

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,23 @@ if test "$PHP_UNDEFINED_SANITIZER" = "yes"; then
15341534
AX_CHECK_COMPILE_FLAG([-fsanitize=undefined], [
15351535
CFLAGS="$CFLAGS -fsanitize=undefined"
15361536
CXXFLAGS="$CXXFLAGS -fsanitize=undefined"
1537+
1538+
dnl Clang 17 adds stricter function pointer compatibility checks where pointer args cannot be
1539+
dnl cast to void*. In that case, set -fno-sanitize=function.
1540+
OLD_CFLAGS="$CFLAGS"
1541+
CFLAGS="$CFLAGS -fno-sanitize-recover=undefined"
1542+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
1543+
void foo(char *string) {}
1544+
int main(void) {
1545+
void (*f)(void *) = (void (*)(void *))foo;
1546+
f("foo");
1547+
}
1548+
]])],,[ubsan_needs_no_function=yes],)
1549+
CFLAGS="$OLD_CFLAGS"
1550+
if test "$ubsan_needs_no_function" = yes; then
1551+
CFLAGS="$CFLAGS -fno-sanitize=function"
1552+
CXXFLAGS="$CFLAGS -fno-sanitize=function"
1553+
fi
15371554
], [AC_MSG_ERROR([UndefinedBehaviorSanitizer is not available])])
15381555
fi
15391556

0 commit comments

Comments
 (0)