Skip to content

Autotools: Refactor thread safety checks #15214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Zend/Zend.m4
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ ZEND_DLSYM_CHECK
ZEND_CHECK_GLOBAL_REGISTER_VARIABLES
ZEND_CHECK_CPUID_COUNT

AC_MSG_CHECKING([whether to enable thread-safety])
AC_MSG_CHECKING([whether to enable thread safety])
AC_MSG_RESULT([$ZEND_ZTS])
AS_VAR_IF([ZEND_ZTS], [yes], [
AC_DEFINE([ZTS], [1], [Define to 1 if thread safety (ZTS) is enabled.])
AS_VAR_APPEND([CFLAGS], [" -DZTS"])
])

AC_MSG_CHECKING([whether to enable Zend debugging])
AC_MSG_RESULT([$ZEND_DEBUG])
Expand All @@ -191,11 +195,6 @@ AX_CHECK_COMPILE_FLAG([-fno-common], CFLAGS="-fno-common $CFLAGS", , [-Werror])

AS_VAR_IF([DEBUG_CFLAGS],,, [AS_VAR_APPEND([CFLAGS], [" $DEBUG_CFLAGS"])])

if test "$ZEND_ZTS" = "yes"; then
AC_DEFINE(ZTS,1,[ ])
CFLAGS="$CFLAGS -DZTS"
fi

ZEND_CHECK_ALIGNMENT
ZEND_CHECK_SIGNALS
ZEND_CHECK_MAX_EXECUTION_TIMERS
Expand Down
26 changes: 8 additions & 18 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,10 @@ if test -z "$PHP_INSTALLED_SAPIS"; then
AC_MSG_ERROR([Nothing to build.])
fi

dnl Force ZTS.
if test "$enable_zts" = "yes"; then
dnl Add pthreads linker and compiler flags.
dnl Add POSIX threads compilation and linker flags when thread safety is enabled
dnl with either the '--enable-zts' configure option or automatically enabled by
dnl PHP SAPIs. For example, Apache SAPI.
AS_VAR_IF([enable_zts], [yes], [
if test -n "$ac_cv_pthreads_lib"; then
LIBS="$LIBS -l$ac_cv_pthreads_lib"
fi
Expand All @@ -306,7 +307,7 @@ if test "$enable_zts" = "yes"; then
fi

PTHREADS_FLAGS
fi
])

dnl Starting system checks.
dnl ----------------------------------------------------------------------------
Expand Down Expand Up @@ -847,12 +848,7 @@ AC_ARG_ENABLE([zts],
[ZEND_ZTS=$enableval],
[ZEND_ZTS=no])

if test "$ZEND_ZTS" = "yes"; then
AC_DEFINE(ZTS, 1,[ ])
PHP_THREAD_SAFETY=yes
else
PHP_THREAD_SAFETY=no
fi
AS_VAR_IF([ZEND_ZTS], [yes], [PHP_THREAD_SAFETY=yes], [PHP_THREAD_SAFETY=no])

AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [
AS_VAR_IF([pthreads_working], [yes], [],
Expand Down Expand Up @@ -1368,17 +1364,11 @@ if test -z "$EXTENSION_DIR"; then
extbasedir=$ZEND_MODULE_API_NO
if test "$oldstyleextdir" = "yes"; then
AS_VAR_IF([PHP_DEBUG], [1], [part1=debug], [part1=no-debug])
if test "$enable_zts" = "yes"; then
part2=zts
else
part2=non-zts
fi
AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [part2=zts], [part2=non-zts])
extbasedir=$part1-$part2-$extbasedir
EXTENSION_DIR=$libdir/extensions/$extbasedir
else
if test "$enable_zts" = "yes"; then
extbasedir=$extbasedir-zts
fi
AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [extbasedir=$extbasedir-zts])
AS_VAR_IF([PHP_DEBUG], [1], [extbasedir=$extbasedir-debug])
EXTENSION_DIR=$libdir/$extbasedir
fi
Expand Down
12 changes: 5 additions & 7 deletions scripts/phpize.m4
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,17 @@ php_debug_is_enabled
CPPFLAGS=$old_CPPFLAGS
AC_MSG_RESULT([$PHP_DEBUG])

AC_MSG_CHECKING([if zts is enabled])
AC_MSG_CHECKING([if PHP is built with thread safety (ZTS)])
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$phpincludedir"
AC_EGREP_CPP(php_zts_is_enabled,[
AC_EGREP_CPP([php_zts_is_enabled], [
#include <main/php_config.h>
#ifdef ZTS
php_zts_is_enabled
#endif
],[
PHP_THREAD_SAFETY=yes
],[
PHP_THREAD_SAFETY=no
])
],
[PHP_THREAD_SAFETY=yes],
[PHP_THREAD_SAFETY=no])
CPPFLAGS=$old_CPPFLAGS
AC_MSG_RESULT([$PHP_THREAD_SAFETY])

Expand Down
2 changes: 1 addition & 1 deletion win32/php_win32_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef PHP_WIN32_GLOBALS_H
#define PHP_WIN32_GLOBALS_H

/* misc globals for thread-safety under win32 */
/* misc globals for thread safety under win32 */

#include "win32/sendmail.h"

Expand Down
Loading