Skip to content

Commit d01316a

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 64cd48e + 6344110 commit d01316a

File tree

19 files changed

+126
-104
lines changed

19 files changed

+126
-104
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ PHP tests and other associated files:
213213
└─📄 ...
214214
├─📂 ...
215215
└─📄 ext_skel.php # Helper script that creates a new PHP extension
216-
└─📂 main # Binding that ties extensions, SAPIs, Zend engine and TSRM together
216+
└─📂 main # Binding that ties extensions, SAPIs, Zend Engine and TSRM together
217217
├─📂 streams # Streams layer subsystem
218218
├─📄 debug_gdb_scripts.c # Generated by `scripts/gdb/debug_gdb_scripts_gen.php`
219219
└─📄 ...
@@ -227,10 +227,10 @@ PHP tests and other associated files:
227227
├─📂 scripts # php-config, phpize and internal development scripts
228228
├─📂 tests # Core features tests
229229
├─📂 TSRM # Thread safe resource manager
230-
└─📂 Zend # Zend engine
230+
└─📂 Zend # Zend Engine
231231
├─📂 asm # Bundled from src/asm in https://github.com/boostorg/context
232232
├─📂 Optimizer # For faster PHP execution through opcode caching and optimization
233-
├─📂 tests # PHP tests *.phpt files for Zend engine
233+
├─📂 tests # PHP tests *.phpt files for Zend Engine
234234
├─📄 zend_vm_execute.h # Generated by `Zend/zend_vm_gen.php`
235235
├─📄 zend_vm_opcodes.c # Generated by `Zend/zend_vm_gen.php`
236236
├─📄 zend_vm_opcodes.h # Generated by `Zend/zend_vm_gen.php`

cmake/Zend/CMakeLists.txt

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1-
################################################################################
2-
# Zend engine.
3-
################################################################################
1+
#[=============================================================================[
2+
Zend Engine.
3+
4+
CMake target properties for the `Zend::Zend` (`zend`) target:
5+
6+
* `VERSION`
7+
8+
Zend Engine version as defined in the `Zend/zend.h` file.
9+
10+
* `ZEND_EXTENSION_API_NO`
11+
12+
Custom target property with internal API version number for PHP extensions
13+
(dynamically loaded with the `extension` INI directive). This is the
14+
`ZEND_MODULE_API_NO` number from the `Zend/zend_modules.h` and ensures that
15+
built extension is compatible with particular PHP build.
16+
17+
* `ZEND_MODULE_API_NO`
18+
19+
Custom target property with internal API version number for Zend extensions in
20+
PHP (dynamically loaded with the `zend_extension` INI directive), such as
21+
opcache, debuggers, profilers, etc. This is the `ZEND_EXTENSION_API_NO` number
22+
from the `Zend/zend_extensions.h` and ensures that built extension is
23+
compatible with particular PHP build.
24+
#]=============================================================================]
425

526
message(STATUS "-----------------------")
6-
message(STATUS "Configuring Zend engine")
27+
message(STATUS "Configuring Zend Engine")
728
message(STATUS "-----------------------\n")
829

9-
# Read the Zend engine version.
30+
# Read the Zend Engine version.
1031
block(PROPAGATE Zend_VERSION Zend_VERSION_LABEL)
1132
file(READ zend.h content)
1233
string(
@@ -22,32 +43,12 @@ endblock()
2243
project(
2344
Zend
2445
VERSION ${Zend_VERSION}
25-
DESCRIPTION "Zend engine library"
46+
DESCRIPTION "Zend Engine library"
2647
LANGUAGES C CXX ASM
2748
)
2849

2950
string(APPEND Zend_VERSION "${Zend_VERSION_LABEL}")
30-
message(STATUS "Zend engine version: ${Zend_VERSION}")
31-
32-
block()
33-
file(READ zend_extensions.h content)
34-
string(
35-
REGEX MATCH
36-
"#[ \t]*define[ \t]+ZEND_EXTENSION_API_NO[ \t]+([0-9]+)"
37-
_
38-
"${content}"
39-
)
40-
message(STATUS "Zend extension API number: ${CMAKE_MATCH_1}")
41-
42-
file(READ zend_modules.h content)
43-
string(
44-
REGEX MATCH
45-
"#[ \t]*define[ \t]+ZEND_MODULE_API_NO[ \t]+([0-9]+)"
46-
_
47-
"${content}"
48-
)
49-
message(STATUS "Zend module API number: ${CMAKE_MATCH_1}")
50-
endblock()
51+
message(STATUS "Zend Engine version: ${Zend_VERSION}")
5152

5253
include(CheckIncludeFile)
5354
include(CheckSourceCompiles)
@@ -326,6 +327,34 @@ target_compile_definitions(
326327
$<$<PLATFORM_ID:Windows>:LIBZEND_EXPORTS>
327328
)
328329

330+
block()
331+
file(READ zend_extensions.h content)
332+
string(
333+
REGEX MATCH
334+
"#[ \t]*define[ \t]+ZEND_EXTENSION_API_NO[ \t]+([0-9]+)"
335+
_
336+
"${content}"
337+
)
338+
set(zendExtensionApiNumber "${CMAKE_MATCH_1}")
339+
340+
file(READ zend_modules.h content)
341+
string(
342+
REGEX MATCH
343+
"#[ \t]*define[ \t]+ZEND_MODULE_API_NO[ \t]+([0-9]+)"
344+
_
345+
"${content}"
346+
)
347+
set(zendModuleApiNumber "${CMAKE_MATCH_1}")
348+
349+
set_target_properties(
350+
zend
351+
PROPERTIES
352+
VERSION ${Zend_VERSION}
353+
ZEND_EXTENSION_API_NO ${zendExtensionApiNumber}
354+
ZEND_MODULE_API_NO ${zendModuleApiNumber}
355+
)
356+
endblock()
357+
329358
# Add Zend PUBLIC/INTERFACE compile options to configuration.
330359
# Cleaner COMPILE_ONLY generator expression is available in CMake >= 3.27.
331360
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)

cmake/cmake/Configuration.cmake

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,15 @@ mark_as_advanced(PHP_EXTENSION_DIR)
184184
# Assemble the PHP_EXTENSION_DIR default value.
185185
block()
186186
if(NOT PHP_EXTENSION_DIR)
187-
file(READ ${PHP_SOURCE_DIR}/Zend/zend_modules.h content)
188-
string(REGEX MATCH "#define ZEND_MODULE_API_NO ([0-9]*)" _ "${content}")
189-
set(zendModuleApiNo ${CMAKE_MATCH_1})
190-
191187
set(
192188
extensionDir
193-
"${CMAKE_INSTALL_LIBDIR}/php/${zendModuleApiNo}$<$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>:-zts>$<$<BOOL:$<CONFIG>>:-$<CONFIG>>"
189+
"${CMAKE_INSTALL_LIBDIR}/php/$<TARGET_PROPERTY:Zend::Zend,ZEND_MODULE_API_NO>$<$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>:-zts>$<$<BOOL:$<CONFIG>>:-$<CONFIG>>"
194190
)
195191

196192
# This would resemble the PHP Autotools --with-layout=GNU:
197-
#set(extensionDir "${CMAKE_INSTALL_LIBDIR}/php/${zendModuleApiNo}$<$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>:-zts>$<$<CONFIG:Debug,DebugAssertions>:-debug>")
193+
#set(extensionDir "${CMAKE_INSTALL_LIBDIR}/php/$<TARGET_PROPERTY:Zend::Zend,ZEND_MODULE_API_NO>$<$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>:-zts>$<$<CONFIG:Debug,DebugAssertions>:-debug>")
198194
# This would resemble the PHP Autotools --with-layout=PHP (default):
199-
#set(extensionDir "${CMAKE_INSTALL_LIBDIR}/php/extensions/$<IF:$<CONFIG:Debug,DebugAssertions>,debug,no-debug>$<IF:$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>,-zts,-non-zts>-${zendModuleApiNo}")
195+
#set(extensionDir "${CMAKE_INSTALL_LIBDIR}/php/extensions/$<IF:$<CONFIG:Debug,DebugAssertions>,debug,no-debug>$<IF:$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>,-zts,-non-zts>-$<TARGET_PROPERTY:Zend::Zend,ZEND_MODULE_API_NO>")
200196

201197
set_property(CACHE PHP_EXTENSION_DIR PROPERTY VALUE "${extensionDir}")
202198
endif()

cmake/cmake/Version.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ function(_php_post_project)
5050
+ ${PHP_VERSION_MINOR} * 100 \
5151
+ ${PHP_VERSION_PATCH}"
5252
)
53-
message(STATUS "PHP version ID: ${PHP_VERSION_ID}")
5453

5554
# Read PHP API version.
5655
set(regex "^[ \t]*#[ \t]*define[ \t]+PHP_API_VERSION[ \t]+([0-9]+)")
@@ -62,7 +61,6 @@ function(_php_post_project)
6261
endif()
6362

6463
set(PHP_API_VERSION "${CMAKE_MATCH_1}")
65-
message(STATUS "PHP API version: ${PHP_API_VERSION}")
6664

6765
return(PROPAGATE PHP_VERSION PHP_VERSION_ID PHP_API_VERSION)
6866
endfunction()

cmake/cmake/modules/PHP/Extensions.cmake

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ function(_php_extensions_parse_dependencies extension result)
187187

188188
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${extension}/CMakeLists.txt content)
189189

190-
# Remove line comments from CMake code content.
191-
string(REGEX REPLACE "#[^\r\n]*[\r\n]" "" content "${content}")
190+
_php_extensions_remove_comments(content)
192191

193192
string(CONCAT regex
194193
# Command invocation:
@@ -244,27 +243,19 @@ function(_php_extensions_option_regex option result)
244243
string(CONCAT _
245244
# Start of the option command invocation:
246245
"[ \t\r\n]?option[ \t]*\\([ \t\r\n]*"
247-
# Optional line comments:
248-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
249246
# Variable name:
250247
"[ \t\r\n]*${option}[ \t\r\n]+"
251-
# Optional line comments:
252-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
253248
# Documentation string without escaped double quotes (\"):
254249
# TODO: should escaped quotes be also matched?
255250
#"[ \t\r\n]*\"([^\"]|\\\")*\"[ \t\r\n]*"
256251
"[ \t\r\n]*\"[^\"]*\"[ \t\r\n]*"
257-
# Optional line comments:
258-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
259252
# Optional boolean or variable value:
260253
"([ \t\r\n]+("
261254
"ON|on|TRUE|true|YES|yes|Y|y|"
262255
"OFF|off|FALSE|false|NO|no|N|n|"
263256
"[0-9.]+|"
264257
"\\\$\\{[^\\}]+\\}"
265258
"))?"
266-
# Optional line comments:
267-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
268259
# End of option invocation:
269260
"[ \t\r\n]*\\)"
270261
)
@@ -277,40 +268,28 @@ function(_php_extensions_cmake_dependent_option_regex option result)
277268
string(CONCAT _
278269
# Start of the option command invocation:
279270
"[ \t\r\n]?cmake_dependent_option[ \t]*\\([ \t\r\n]*"
280-
# Possible inline comments:
281-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
282271
# Variable name:
283272
"[ \t\r\n]*${option}[ \t\r\n]+"
284-
# Optional line comments:
285-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
286273
# Documentation string without escaped double quotes (\"):
287274
# TODO: should escaped quotes be also matched?
288275
#"[ \t\r\n]*\"([^\"]|\\\")*\"[ \t\r\n]*"
289276
"[ \t\r\n]*\"[^\"]*\"[ \t\r\n]*"
290-
# Optional line comments:
291-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
292277
# Boolean or variable value:
293278
"[ \t\r\n]+("
294279
"ON|on|TRUE|true|YES|yes|Y|y|"
295280
"OFF|off|FALSE|false|NO|no|N|n|"
296281
"[0-9.]+|"
297282
"\\\$\\{[^\\}]+\\}"
298283
")"
299-
# Optional line comments:
300-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
301284
# Semicolon separated list of conditions:
302285
"[ \t\r\n]*\"[^\"]*\"[ \t\r\n]*"
303-
# Optional line comments:
304-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
305286
# Boolean or variable force value:
306287
"[ \t\r\n]+("
307288
"ON|on|TRUE|true|YES|yes|Y|y|"
308289
"OFF|off|FALSE|false|NO|no|N|n|"
309290
"[0-9.]+|"
310291
"\\\$\\{[^\\}]+\\}"
311292
")"
312-
# Optional line comments:
313-
"([ \t\r\n]*#[^\r\n]*[\r\n])*"
314293
# End of option invocation:
315294
"[ \t\r\n]*\\)"
316295
)
@@ -337,6 +316,7 @@ function(_php_extensions_eval_options directories)
337316
string(TOUPPER "${extension}" extensionUpper)
338317

339318
# Check if extension has option(EXT_<extension> ...).
319+
_php_extensions_remove_comments(content)
340320
_php_extensions_option_regex("EXT_${extensionUpper}" regex)
341321
string(REGEX MATCH "${regex}" code "${content}")
342322

@@ -374,6 +354,12 @@ function(_php_extensions_eval_options directories)
374354
endforeach()
375355
endfunction()
376356

357+
# Remove line comments from CMake code content.
358+
function(_php_extensions_remove_comments)
359+
string(REGEX REPLACE "[ \t]*#[^\r\n]*" "" ${ARGV0} "${${ARGV0}}")
360+
set(${ARGV0} "${${ARGV0}}" PARENT_SCOPE)
361+
endfunction()
362+
377363
# Postconfigure extension right after it has been configured.
378364
function(php_extensions_postconfigure extension)
379365
if(NOT TARGET php_${extension})

cmake/cmake/modules/PHP/FeatureSummary.cmake

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,30 @@ include_guard(GLOBAL)
1313

1414
include(FeatureSummary)
1515

16-
message(STATUS "-----------")
17-
message(STATUS "PHP summary")
18-
message(STATUS "-----------\n")
19-
20-
# Output enabled features.
16+
# Output summary prelude.
2117
block()
22-
feature_summary(
23-
WHAT ENABLED_FEATURES
24-
VAR enabledFeatures
18+
get_target_property(zendVersion Zend::Zend VERSION)
19+
get_target_property(zendExtensionApiNumber Zend::Zend ZEND_EXTENSION_API_NO)
20+
get_target_property(zendModuleApiNumber Zend::Zend ZEND_MODULE_API_NO)
21+
22+
set(info)
23+
string(
24+
APPEND
25+
info
26+
" * PHP version: ${PHP_VERSION}\n"
27+
" * PHP API version: ${PHP_API_VERSION}\n"
28+
" * Zend Engine version: ${zendVersion}\n"
29+
" * Zend extension API number: ${zendExtensionApiNumber}\n"
30+
" * Zend module API number: ${zendModuleApiNumber}\n"
2531
)
2632

33+
message(STATUS "-----------")
34+
message(STATUS "PHP summary")
35+
message(STATUS "-----------\n\n${info}")
36+
endblock()
37+
38+
# Output enabled features.
39+
block()
2740
get_property(enabledFeatures GLOBAL PROPERTY ENABLED_FEATURES)
2841

2942
if(enabledFeatures)
@@ -68,17 +81,17 @@ block()
6881
endif()
6982
endforeach()
7083

84+
if(php)
85+
message(STATUS "Enabled PHP features:\n\n${php}")
86+
endif()
87+
7188
if(sapis)
7289
message(STATUS "Enabled PHP SAPIs:\n\n${sapis}")
7390
endif()
7491

7592
if(extensions)
7693
message(STATUS "Enabled PHP extensions:\n\n${extensions}")
7794
endif()
78-
79-
if(php)
80-
message(STATUS "Enabled PHP features:\n\n${php}")
81-
endif()
8295
endblock()
8396

8497
# Get missing extensions.
@@ -164,19 +177,19 @@ block()
164177
message(STATUS "${message}")
165178
endif()
166179

180+
if(missingExtensions OR sharedExtensionsSummary)
181+
message(
182+
SEND_ERROR
183+
"PHP/FeatureSummary error: Please reconfigure PHP extensions, aborting "
184+
"CMake run."
185+
)
186+
endif()
187+
167188
# Output missing required packages.
168189
feature_summary(
169190
FATAL_ON_MISSING_REQUIRED_PACKAGES
170191
WHAT REQUIRED_PACKAGES_NOT_FOUND
171192
QUIET_ON_EMPTY
172193
DESCRIPTION "The following REQUIRED packages have not been found:\n"
173194
)
174-
175-
if(missingExtensions OR sharedExtensionsSummary)
176-
message(
177-
FATAL_ERROR
178-
"PHP/FeatureSummary error: Please reconfigure PHP extensions, aborting "
179-
"CMake run."
180-
)
181-
endif()
182195
endblock()

cmake/cmake/modules/Zend/MaxExecutionTimers.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ add_feature_info(
8686

8787
# Set the result variable also in the PARENT_SCOPE, to make it available for the
8888
# 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.
89+
# the Zend Engine which is added with add_subdirectory() in the PHP project.
9090
if(NOT PROJECT_IS_TOP_LEVEL)
9191
set(ZEND_MAX_EXECUTION_TIMERS ${ZEND_MAX_EXECUTION_TIMERS} PARENT_SCOPE)
9292
endif()

cmake/cmake/platforms/Windows.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
1616
# when targeting Windows. Left here for BC for possible PECL
1717
# extensions not being updated yet. In new code it is being
1818
# replaced with _WIN32.
19-
ZEND_WIN32 # For Zend engine
19+
ZEND_WIN32 # For Zend Engine
2020
)
2121

2222
# To speed up the Windows build experience with Visual Studio generators,

cmake/ext/session/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ target_compile_definitions(
6868
ZEND_ENABLE_STATIC_TSRMLS_CACHE=1
6969
)
7070

71-
# For spl autoloading https://bugs.php.net/53141
72-
if(TARGET php_spl)
73-
add_dependencies(php_session php_spl)
74-
endif()
75-
76-
add_dependencies(php_session php_date php_random)
71+
add_dependencies(
72+
php_session
73+
php_date
74+
php_random
75+
php_spl # For spl autoloading https://bugs.php.net/53141 (optonal dependency).
76+
)
7777

7878
# Check whether pread() and pwrite() work.
7979
include(PHP/CheckPreadPwrite)

0 commit comments

Comments
 (0)