Skip to content

Commit ca22505

Browse files
committed
Disable -fsanitize=function on Clang 17
Closes GH-12642
1 parent 7440a1b commit ca22505

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
@@ -1581,6 +1581,23 @@ if test "$PHP_UNDEFINED_SANITIZER" = "yes"; then
15811581
CFLAGS="$CFLAGS -fno-sanitize=object-size"
15821582
CXXFLAGS="$CFLAGS -fno-sanitize=object-size"
15831583
])
1584+
1585+
dnl Clang 17 adds stricter function pointer compatibility checks where pointer args cannot be
1586+
dnl cast to void*. In that case, set -fno-sanitize=function.
1587+
OLD_CFLAGS="$CFLAGS"
1588+
CFLAGS="$CFLAGS -fno-sanitize-recover=undefined"
1589+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
1590+
void foo(char *string) {}
1591+
int main(void) {
1592+
void (*f)(void *) = (void (*)(void *))foo;
1593+
f("foo");
1594+
}
1595+
]])],,[ubsan_needs_no_function=yes],)
1596+
CFLAGS="$OLD_CFLAGS"
1597+
if test "$ubsan_needs_no_function" = yes; then
1598+
CFLAGS="$CFLAGS -fno-sanitize=function"
1599+
CXXFLAGS="$CFLAGS -fno-sanitize=function"
1600+
fi
15841601
], [AC_MSG_ERROR([UndefinedBehaviorSanitizer is not available])])
15851602
fi
15861603

0 commit comments

Comments
 (0)