Skip to content

Commit 95b3fa1

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 6ed17ad + 5a19de4 commit 95b3fa1

File tree

5 files changed

+135
-57
lines changed

5 files changed

+135
-57
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ include(CheckSourceCompiles)
5050
include(CheckSymbolExists)
5151
include(CMakePushCheckState)
5252
include(PHP/AddCustomCommand)
53-
include(PHP/SearchLibraries)
5453

5554
################################################################################
5655
# Configuration.
@@ -65,15 +64,6 @@ mark_as_advanced(ZEND_FIBER_ASM)
6564
option(ZEND_SIGNALS "Enable Zend signal handling" ON)
6665
mark_as_advanced(ZEND_SIGNALS)
6766

68-
# TODO: Check if default value can be improved. Once cached variable is set, it
69-
# can't be changed to PHP_THREAD_SAFETY value on the 2nd configuration run.
70-
option(
71-
ZEND_MAX_EXECUTION_TIMERS
72-
"Enable Zend max execution timers"
73-
${PHP_THREAD_SAFETY}
74-
)
75-
mark_as_advanced(ZEND_MAX_EXECUTION_TIMERS)
76-
7767
################################################################################
7868
# Add library.
7969
################################################################################
@@ -295,7 +285,14 @@ target_sources(
295285
$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_CURRENT_BINARY_DIR}/zend_config.h>
296286
)
297287

298-
target_link_libraries(zend PRIVATE PHP::configuration)
288+
target_link_libraries(
289+
zend
290+
PRIVATE
291+
PHP::configuration
292+
PUBLIC
293+
PHP::TSRM
294+
$<TARGET_OBJECTS:PHP::TSRM>
295+
)
299296

300297
target_include_directories(
301298
zend
@@ -304,8 +301,6 @@ target_include_directories(
304301
${CMAKE_CURRENT_BINARY_DIR}
305302
)
306303

307-
target_link_libraries(zend PUBLIC PHP::TSRM)
308-
309304
target_compile_definitions(
310305
zend
311306
PRIVATE
@@ -426,31 +421,9 @@ else()
426421
endif()
427422

428423
# Check Zend max execution timers.
429-
message(CHECK_START "Checking whether to enable Zend max execution timers")
430-
if(ZEND_MAX_EXECUTION_TIMERS AND CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD)$")
431-
php_search_libraries(
432-
timer_create
433-
HAVE_TIMER_CREATE
434-
HEADERS time.h
435-
LIBRARIES
436-
rt # Solaris <= 10, older Linux
437-
TARGET zend PRIVATE
438-
)
439-
440-
if(NOT HAVE_TIMER_CREATE)
441-
set_property(CACHE ZEND_MAX_EXECUTION_TIMERS PROPERTY VALUE 0)
442-
endif()
443-
444-
if(ZEND_MAX_EXECUTION_TIMERS)
445-
set_property(CACHE ZEND_MAX_EXECUTION_TIMERS PROPERTY VALUE 1)
446-
endif()
447-
else()
448-
set_property(CACHE ZEND_MAX_EXECUTION_TIMERS PROPERTY VALUE 0)
449-
endif()
450-
if(ZEND_MAX_EXECUTION_TIMERS)
451-
message(CHECK_PASS "yes")
452-
else()
453-
message(CHECK_FAIL "no")
424+
include(Zend/MaxExecutionTimers)
425+
if(TARGET Zend::MaxExecutionTimers)
426+
target_link_libraries(zend PRIVATE Zend::MaxExecutionTimers)
454427
endif()
455428

456429
# Check MM alignment.
@@ -473,10 +446,6 @@ if(ZEND_SIGNALS)
473446
target_compile_definitions(zend PRIVATE ZEND_SIGNALS)
474447
endif()
475448

476-
if(ZEND_MAX_EXECUTION_TIMERS)
477-
target_compile_definitions(zend PRIVATE ZEND_MAX_EXECUTION_TIMERS)
478-
endif()
479-
480449
################################################################################
481450
# Generate lexers and parsers.
482451
################################################################################

cmake/cmake/Requirements.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ if(
9090
PURPOSE "Necessary to generate PHP parser files."
9191
)
9292
# Add Bison options based on the build type.
93-
set(PHP_DEFAULT_BISON_FLAGS "$<IF:$<CONFIG:Release,MinSizeRel>,-lWall,-Wall>")
94-
# Nicer way would be the one below, but GNU Bison errors out because it cannot
95-
# process empty double quoted arguments in the command-line.
96-
# See: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9921
97-
#set(PHP_DEFAULT_BISON_FLAGS "-Wall $<$<CONFIG:Release,MinSizeRel>:-l>")
93+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.32)
94+
# See: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9921
95+
set(PHP_DEFAULT_BISON_FLAGS "-Wall $<$<CONFIG:Release,MinSizeRel>:-l>")
96+
else()
97+
set(PHP_DEFAULT_BISON_FLAGS "$<IF:$<CONFIG:Release,MinSizeRel>,-lWall,-Wall>")
98+
endif()
9899
endif()
99100

100101
# Check if re2c is required.

cmake/cmake/modules/PHP/FeatureSummary.cmake

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,16 @@ block()
4141
if(parent AND feature MATCHES "^${parent} ")
4242
set(item " * ${feature}")
4343
else()
44-
set(type)
44+
set(parent "${feature}")
45+
set(item " * ${feature}")
4546
if(feature MATCHES "^ext/([^ ]+)$")
4647
if(CMAKE_MATCH_1)
4748
get_target_property(type php_${CMAKE_MATCH_1} TYPE)
4849
if(type MATCHES "^(MODULE|SHARED)_LIBRARY$")
49-
set(type " (shared)")
50-
else()
51-
set(type)
50+
string(APPEND item " (shared)")
5251
endif()
5352
endif()
5453
endif()
55-
set(item " * ${feature}${type}")
56-
set(parent "${feature}")
5754
endif()
5855

5956
get_property(description GLOBAL PROPERTY _CMAKE_${feature}_DESCRIPTION)

cmake/cmake/modules/PHP/ThreadSafety.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[=============================================================================[
22
Check for thread safety, a.k.a. ZTS (Zend thread safety) build.
33
4-
## Cache variables
4+
## Result variables
55
66
* `ZTS`
77
@@ -34,9 +34,9 @@ function(_php_thread_safety)
3434
message(CHECK_START "Checking whether to enable thread safety (ZTS)")
3535

3636
add_feature_info(
37-
"Thread safety"
37+
"PHP thread safety (ZTS)"
3838
PHP_THREAD_SAFETY
39-
"PHP thread safety (ZTS) enabled"
39+
"ensures safe execution in multi-threaded environments"
4040
)
4141

4242
if(NOT PHP_THREAD_SAFETY)
@@ -62,7 +62,7 @@ function(_php_thread_safety)
6262

6363
target_link_libraries(php_configuration INTERFACE Threads::Threads)
6464

65-
set(ZTS 1 CACHE INTERNAL "Whether PHP thread safety is enabled.")
65+
set(ZTS 1 PARENT_SCOPE)
6666

6767
# Add ZTS compile definition. Some PHP headers might not have php_config.h
6868
# directly available. For example, some Zend headers.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#[=============================================================================[
2+
Check whether to enable Zend max execution timers.
3+
4+
## Cache variables
5+
6+
* [`ZEND_MAX_EXECUTION_TIMERS`](/docs/cmake/ZEND_MAX_EXECUTION_TIMERS.md)
7+
8+
* `HAVE_TIMER_CREATE`
9+
10+
Whether the system has `timer_create()`.
11+
12+
## Result variables
13+
14+
* `ZEND_MAX_EXECUTION_TIMERS`
15+
16+
A regular variable based on the cache variable and thread safety to be able to
17+
run consecutive configuration runs. When `ZEND_MAX_EXECUTION_TIMERS` cache
18+
variable is set to 'auto', regular variable default value is set to the
19+
`PHP_THREAD_SAFETY` value.
20+
21+
## INTERFACE IMPORTED library
22+
23+
* `Zend::MaxExecutionTimers`
24+
25+
Includes possible additional library to be linked for using `timer_create()`
26+
and a compile definition.
27+
#]=============================================================================]
28+
29+
include_guard(GLOBAL)
30+
31+
message(CHECK_START "Checking whether to enable Zend max execution timers")
32+
33+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
34+
message(CHECK_FAIL "no")
35+
return()
36+
endif()
37+
38+
include(PHP/SearchLibraries)
39+
include(FeatureSummary)
40+
41+
set(
42+
ZEND_MAX_EXECUTION_TIMERS "auto"
43+
CACHE STRING "Enable Zend max execution timers"
44+
)
45+
mark_as_advanced(ZEND_MAX_EXECUTION_TIMERS)
46+
set_property(
47+
CACHE ZEND_MAX_EXECUTION_TIMERS
48+
PROPERTY STRINGS "auto" "ON" "OFF"
49+
)
50+
51+
# Set a regular variable based on the cache variable.
52+
if(ZEND_MAX_EXECUTION_TIMERS STREQUAL "auto")
53+
set(ZEND_MAX_EXECUTION_TIMERS "${PHP_THREAD_SAFETY}")
54+
else()
55+
set(ZEND_MAX_EXECUTION_TIMERS "${ZEND_MAX_EXECUTION_TIMERS}")
56+
endif()
57+
58+
if(ZEND_MAX_EXECUTION_TIMERS AND CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD)$")
59+
php_search_libraries(
60+
timer_create
61+
HAVE_TIMER_CREATE
62+
HEADERS time.h
63+
LIBRARIES
64+
rt # Solaris <= 10, older Linux
65+
LIBRARY_VARIABLE libraryForTimerCreate
66+
)
67+
68+
if(NOT HAVE_TIMER_CREATE)
69+
set(ZEND_MAX_EXECUTION_TIMERS OFF)
70+
endif()
71+
else()
72+
set(ZEND_MAX_EXECUTION_TIMERS OFF)
73+
endif()
74+
75+
if(ZEND_MAX_EXECUTION_TIMERS)
76+
message(CHECK_PASS "yes")
77+
else()
78+
message(CHECK_FAIL "no")
79+
endif()
80+
81+
add_feature_info(
82+
"Zend max execution timers"
83+
ZEND_MAX_EXECUTION_TIMERS
84+
"enhanced timeout and signal handling"
85+
)
86+
87+
# Set the result variable also in the PARENT_SCOPE, to make it available for the
88+
# parent project PHP in its configuration headers. This module is included in
89+
# the Zend engine which is added with add_subdirectory() in the PHP project.
90+
if(NOT PROJECT_IS_TOP_LEVEL)
91+
set(ZEND_MAX_EXECUTION_TIMERS ${ZEND_MAX_EXECUTION_TIMERS} PARENT_SCOPE)
92+
endif()
93+
94+
add_library(Zend::MaxExecutionTimers INTERFACE IMPORTED)
95+
if(libraryForTimerCreate)
96+
target_link_libraries(
97+
Zend::MaxExecutionTimers
98+
INTERFACE
99+
${libraryForTimerCreate}
100+
)
101+
endif()
102+
103+
# The configuration header with ZEND_MAX_EXECUTION_TIMERS might not be included
104+
# in some source files, therefore also compilation definitions is added.
105+
if(ZEND_MAX_EXECUTION_TIMERS)
106+
target_compile_definitions(
107+
Zend::MaxExecutionTimers
108+
INTERFACE
109+
ZEND_MAX_EXECUTION_TIMERS
110+
)
111+
endif()

0 commit comments

Comments
 (0)