File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -823,7 +823,10 @@ TSRM_API void *tsrm_get_ls_cache(void)
823823/* Returns offset of tsrm_ls_cache slot from Thread Control Block address */
824824TSRM_API size_t tsrm_get_ls_cache_tcb_offset (void )
825825{/*{{{*/
826- #if defined(__APPLE__ ) && defined(__x86_64__ )
826+ #if defined(TSRM_TLS_MODEL_GLOBAL_DYNAMIC )
827+ /* No constant TCB offset under global-dynamic, can't use fast path */
828+ return 0 ;
829+ #elif defined(__APPLE__ ) && defined(__x86_64__ )
827830 // TODO: Implement support for fast JIT ZTS code ???
828831 return 0 ;
829832#elif defined(__x86_64__ ) && defined(__GNUC__ ) && !defined(__FreeBSD__ ) && \
Original file line number Diff line number Diff line change @@ -158,8 +158,13 @@ TSRM_API bool tsrm_is_managed_thread(void);
158158# define TSRM_TLS_MODEL_ATTR
159159# define TSRM_TLS_MODEL_DEFAULT
160160#elif __PIC__ && !defined(__PIE__ )
161- # define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
162- # define TSRM_TLS_MODEL_INITIAL_EXEC
161+ # if defined(TSRM_TLS_MODEL_USE_GLOBAL_DYNAMIC )
162+ # define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("global-dynamic")))
163+ # define TSRM_TLS_MODEL_GLOBAL_DYNAMIC
164+ # else
165+ # define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
166+ # define TSRM_TLS_MODEL_INITIAL_EXEC
167+ # endif
163168#else
164169# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("local-exec")))
165170# define TSRM_TLS_MODEL_LOCAL_EXEC
Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ if test "$PHP_APXS2" != "no"; then
8585 LIBPHP_CFLAGS="-shared"
8686 PHP_SUBST([ LIBPHP_CFLAGS] )
8787
88+ dnl httpd dlopen's libphp.so without linking against it, so _tsrm_ls_cache can't
89+ dnl use initial-exec (overflows the static TLS surplus)
90+ AS_VAR_APPEND ( [ CFLAGS] , [ " -DTSRM_TLS_MODEL_USE_GLOBAL_DYNAMIC"] )
91+
8892 php_sapi_apache2handler_type=shared
8993 AS_CASE ( [ $host_alias] ,
9094 [ *aix*] , [
You can’t perform that action at this time.
0 commit comments