[php-src] master: Merge branch 'PHP-8.6'
| From: | Arnaud Le Blanc | Date: | Mon, 19 Oct 2026 10:20:33 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142437@lists.php.net to get a copy of this message | ||
Author: Arnaud Le Blanc (arnaud-lb)
Date: 2026-10-19T12:20:19+02:00
Commit: https://github.com/php/php-src/commit/0c4b6bd2eea1bebdbaf49c4a619d21bd897c3e2c
Raw diff: https://github.com/php/php-src/commit/0c4b6bd2eea1bebdbaf49c4a619d21bd897c3e2c.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
fix GH-24262: default apache build to global-dynamic TLS (#24301)
Changed paths:
M TSRM/TSRM.c
M TSRM/TSRM.h
M configure.ac
M sapi/apache2handler/config.m4
Diff:
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index a9f6ed5c59bb..39b1db9b712d 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -855,7 +855,10 @@ TSRM_API void *tsrm_get_ls_cache(void)
/* Returns offset of tsrm_ls_cache slot from Thread Control Block address */
TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void)
{/*{{{*/
-#if defined(__APPLE__) && defined(__x86_64__)
+#if defined(TSRM_TLS_MODEL_USE_DEFAULT) && defined(__PIC__) && !defined(__PIE__)
+ /* The compiler may use dynamic TLS. Do not force a static TLS relocation. */
+ return 0;
+#elif defined(__APPLE__) && defined(__x86_64__)
// TODO: Implement support for fast JIT ZTS code ???
return 0;
#elif defined(__x86_64__) && defined(__GNUC__) && !defined(__FreeBSD__) &&
\
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index 6a72dd3c02f3..5fe5fb1cf354 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -167,8 +167,13 @@ TSRM_API bool tsrm_is_managed_thread(void);
# define TSRM_TLS_MODEL_ATTR
# define TSRM_TLS_MODEL_DEFAULT
#elif defined(__PIC__) && !defined(__PIE__)
-# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
-# define TSRM_TLS_MODEL_INITIAL_EXEC
+# if defined(TSRM_TLS_MODEL_USE_DEFAULT)
+# define TSRM_TLS_MODEL_ATTR
+# define TSRM_TLS_MODEL_DEFAULT
+# else
+# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
+# define TSRM_TLS_MODEL_INITIAL_EXEC
+# endif
#else
# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("local-exec")))
# define TSRM_TLS_MODEL_LOCAL_EXEC
diff --git a/configure.ac b/configure.ac
index f48f1e8de90e..b5dcf0da17f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,6 +276,9 @@ SAPI_SHARED=libs/$SAPI_LIBNAME_SHARED
SAPI_STATIC=libs/$SAPI_LIBNAME_STATIC
SAPI_LIBTOOL=libphp.la
+dnl Set by SAPIs whose host program dlopen()s libphp without linking against it.
+php_tsrm_dlopened_sapi=no
+
PHP_CONFIGURE_PART([Configuring SAPI modules])
esyscmd(./build/config-stubs sapi)
@@ -875,6 +878,20 @@ AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [
AC_MSG_CHECKING([for POSIX threads])
AC_MSG_RESULT([yes])
+
+ AS_VAR_IF([php_tsrm_dlopened_sapi], [yes], [
+ php_tsrm_tls_model=
+ for flag in $CFLAGS $EXTRA_CFLAGS; do
+ AS_CASE([$flag], [-ftls-model=*], [php_tsrm_tls_model=$flag])
+ done
+
+ dnl Define TSRM_TLS_MODEL_USE_DEFAULT to avoid forcing static TLS in dlopened SAPIs.
+ dnl Omit it for explicit initial-exec to enable the TCB offset fast path.
+ AS_IF([test "$php_tsrm_tls_model" != "-ftls-model=initial-exec"], [
+ AC_DEFINE([TSRM_TLS_MODEL_USE_DEFAULT], [1],
+ [Define to 1 to use the compiler's default TLS model.])
+ ])
+ ])
])
PHP_ARG_ENABLE([rtld-now],
diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4
index 3001a4d61d9a..b000acbef198 100644
--- a/sapi/apache2handler/config.m4
+++ b/sapi/apache2handler/config.m4
@@ -94,6 +94,11 @@ if test "$PHP_APXS2" != "no"; then
LIBPHP_CFLAGS="-shared"
PHP_SUBST([LIBPHP_CFLAGS])
+ dnl httpd dlopen's libphp.so without linking against it, so we must
+ dnl use global-dynamic by default. Use -ftls-model=initial-exec to
+ dnl override the compiler choice, see UPGRADING.INTERNALS
+ php_tsrm_dlopened_sapi=yes
+
php_sapi_apache2handler_type=shared
AS_CASE([$host_alias],
[*aix*], [