Skip to content

Commit 0603d3b

Browse files
authored
improve configuration of pthread link for userfaultd thread under NTS (#7568)
1 parent 9ecec66 commit 0603d3b

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

sapi/phpdbg/config.m4

+20-12
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,34 @@ if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
4545
AC_MSG_RESULT([disabled])
4646
fi
4747

48-
AC_CACHE_CHECK([for userfaultfd faulting on write-protected memory support], ac_phpdbg_userfaultfd_writefault, AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
48+
AC_CACHE_CHECK([for userfaultfd faulting on write-protected memory support], ac_cv_phpdbg_userfaultfd_writefault, AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4949
#include <linux/userfaultfd.h>
5050
#ifndef UFFDIO_WRITEPROTECT_MODE_WP
5151
# error userfaults on write-protected memory not supported
5252
#endif
53-
]])], [ac_phpdbg_userfaultfd_writefault=yes], [ac_phpdbg_userfaultfd_writefault=no]))
54-
if test "$ac_phpdbg_userfaultfd_writefault" = "yes"; then
53+
]])], [ac_cv_phpdbg_userfaultfd_writefault=yes], [ac_cv_phpdbg_userfaultfd_writefault=no]))
54+
if test "$ac_cv_phpdbg_userfaultfd_writefault" = "yes"; then
5555
if test "$enable_zts" != "yes"; then
56-
dnl Add pthreads linker and compiler flags for userfaultfd background thread
57-
if test -n "$ac_cv_pthreads_lib"; then
58-
LIBS="$LIBS -l$ac_cv_pthreads_lib"
59-
fi
60-
if test -n "$ac_cv_pthreads_cflags"; then
61-
CFLAGS="$CFLAGS $ac_cv_pthreads_cflags"
56+
CFLAGS_SAVE="$CFLAGS"
57+
LIBS_SAVE="$LIBS"
58+
59+
PTHREADS_CHECK
60+
AC_MSG_CHECKING([working pthreads]);
61+
62+
if test "$pthreads_working" = "yes"; then
63+
AC_MSG_RESULT([$ac_cv_pthreads_cflags -l$ac_cv_pthreads_lib]);
64+
PHP_PHPDBG_CFLAGS="$PHP_PHPDBG_CFLAGS $ac_cv_pthreads_cflags"
65+
PHPDBG_EXTRA_LIBS="$PHPDBG_EXTRA_LIBS -l$ac_cv_pthreads_lib"
66+
AC_DEFINE(HAVE_USERFAULTFD_WRITEFAULT, 1, [Whether faulting on write-protected memory support can be compiled for userfaultfd])
67+
else
68+
AC_MSG_WARN([pthreads not available])
6269
fi
6370

64-
PTHREADS_FLAGS
71+
CFLAGS="$CLFAGS_SAVE"
72+
LIBS="$LIBS_SAVE"
73+
else
74+
AC_DEFINE(HAVE_USERFAULTFD_WRITEFAULT, 1, [Whether faulting on write-protected memory support can be compiled for userfaultfd])
6575
fi
66-
67-
AC_DEFINE(HAVE_USERFAULTFD_WRITEFAULT, 1, [Whether faulting on write-protected memory support can be compiled for userfaultfd])
6876
fi
6977

7078
PHP_SUBST(PHP_PHPDBG_CFLAGS)

0 commit comments

Comments
 (0)