Skip to content

Commit f3d4ad9

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 79b6877 + ddc368d commit f3d4ad9

File tree

13 files changed

+169
-117
lines changed

13 files changed

+169
-117
lines changed

cmake/TSRM/CMakeLists.txt

Lines changed: 0 additions & 53 deletions
This file was deleted.

cmake/Zend/CMakeLists.txt

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[=============================================================================[
22
Zend Engine.
33
4-
CMake target properties for the `Zend::Zend` (`zend`) target:
4+
CMake target properties for the `Zend::Zend` target:
55
66
* `VERSION`
77
@@ -304,16 +304,7 @@ target_sources(
304304
$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_CURRENT_BINARY_DIR}/zend_config.h>
305305
)
306306

307-
# Add TSRM.
308-
add_subdirectory(../TSRM ../TSRM)
309-
310-
target_link_libraries(
311-
zend
312-
PRIVATE
313-
PHP::configuration
314-
PUBLIC
315-
TSRM::TSRM
316-
)
307+
target_link_libraries(zend PRIVATE PHP::configuration)
317308

318309
target_include_directories(
319310
zend
@@ -358,18 +349,58 @@ block()
358349
)
359350
endblock()
360351

361-
# Add Zend PUBLIC/INTERFACE compile options to configuration.
352+
# Add Zend PUBLIC/INTERFACE compile properties to configuration.
362353
# Cleaner COMPILE_ONLY generator expression is available in CMake >= 3.27.
363354
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)
364-
target_link_libraries(php_configuration INTERFACE $<COMPILE_ONLY:Zend::Zend>)
355+
target_link_libraries(php_configuration INTERFACE $<COMPILE_ONLY:zend>)
365356
else()
366357
target_include_directories(
367358
php_configuration
368359
INTERFACE
369-
$<TARGET_PROPERTY:Zend::Zend,INTERFACE_INCLUDE_DIRECTORIES>
360+
$<TARGET_PROPERTY:zend,INTERFACE_INCLUDE_DIRECTORIES>
361+
)
362+
target_compile_definitions(
363+
php_configuration
364+
INTERFACE
365+
$<TARGET_PROPERTY:zend,INTERFACE_COMPILE_DEFINITIONS>
370366
)
371367
endif()
372368

369+
################################################################################
370+
# TSRM (Thread Safe Resource Manager) is a separate directory in php-src as it
371+
# was once a standalone project. Ideally, it should be moved into Zend Engine at
372+
# some point.
373+
################################################################################
374+
375+
target_sources(
376+
zend
377+
PRIVATE
378+
$<$<PLATFORM_ID:Windows>:${CMAKE_CURRENT_SOURCE_DIR}/../TSRM/tsrm_win32.c>
379+
${CMAKE_CURRENT_SOURCE_DIR}/../TSRM/TSRM.c
380+
PUBLIC
381+
FILE_SET tsrm
382+
TYPE HEADERS
383+
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../TSRM
384+
FILES
385+
$<$<PLATFORM_ID:Windows>:${CMAKE_CURRENT_SOURCE_DIR}/../TSRM/tsrm_win32.h>
386+
${CMAKE_CURRENT_SOURCE_DIR}/../TSRM/TSRM.h
387+
)
388+
389+
target_include_directories(
390+
zend
391+
INTERFACE
392+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../TSRM>
393+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PHP_INCLUDE_PREFIX}/TSRM>
394+
)
395+
396+
target_compile_definitions(zend PUBLIC $<$<PLATFORM_ID:Windows>:TSRM_EXPORTS>)
397+
398+
install(
399+
TARGETS zend
400+
FILE_SET tsrm
401+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PHP_INCLUDE_PREFIX}/TSRM
402+
)
403+
373404
################################################################################
374405
# Configuration checks.
375406
################################################################################

cmake/cmake/modules/FindRE2C.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ function(re2c_target)
286286
${input}
287287
DEPENDS ${input} ${parsed_DEPENDS}
288288
COMMENT "[RE2C][${ARGV0}] Building lexer with re2c ${RE2C_VERSION}"
289+
VERBATIM
290+
COMMAND_EXPAND_LISTS
289291
)
290292

291293
add_custom_target(

cmake/ext/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ foreach(extension IN LISTS extensions)
8989
if(TARGET php_${extension})
9090
set_property(GLOBAL APPEND PROPERTY PHP_EXTENSIONS ${extension})
9191

92-
# Add extension's PUBLIC/INTERFACE compile options to configuration.
92+
# Add extension's PUBLIC/INTERFACE compile properties to configuration.
9393
# Cleaner COMPILE_ONLY generator expression is available in CMake >= 3.27.
9494
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)
9595
target_link_libraries(
@@ -98,6 +98,10 @@ foreach(extension IN LISTS extensions)
9898
$<COMPILE_ONLY:PHP::${extension}>
9999
)
100100
else()
101+
# TODO: Fix this better. Either require 3.27, or limit/adjust compile
102+
# properties propagated globally. Also, shared extensions shouldn't
103+
# propagate globally.
104+
# https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#id36
101105
target_include_directories(
102106
php_configuration
103107
INTERFACE
@@ -114,7 +118,7 @@ foreach(extension IN LISTS extensions)
114118
$<TARGET_PROPERTY:php_configuration,INTERFACE_COMPILE_OPTIONS>
115119
)
116120

117-
add_dependencies(php_${extension} zend)
121+
add_dependencies(php_${extension} Zend::Zend)
118122

119123
get_target_property(type php_${extension} TYPE)
120124
if(NOT type MATCHES "^(MODULE|SHARED)_LIBRARY$")

cmake/ext/pcntl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This extension provides support for process control support.
99
> This extension is available only on \*nix systems.
1010
1111
> [!IMPORTANT]
12-
> This extension should be used only with cgi, cli, embed, or phpdbg SAPI.
12+
> This extension should be used only with CLI-based PHP SAPIs.
1313
1414
## EXT_PCNTL
1515

cmake/ext/readline/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Configure the `readline` extension.
66
This extension provides interface for using Editline library.
77
88
> [!IMPORTANT]
9-
> This extension should be used only with cgi, cli, embed, or phpdbg SAPI.
9+
> This extension should be used only with CLI-based PHP SAPIs.
1010
1111
## EXT_READLINE
1212

cmake/main/CMakeLists.txt

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@ PHP main binding.
1010
include(CheckSymbolExists)
1111
include(FeatureSummary)
1212

13-
add_library(php INTERFACE)
14-
add_library(PHP::PHP ALIAS php)
13+
################################################################################
14+
# Add library.
15+
################################################################################
1516

1617
add_library(php_main OBJECT)
17-
add_library(PHP::main ALIAS php_main)
1818

1919
# These contain a list of built-in extensions based on the SAPI types.
2020
add_library(php_main_internal_functions OBJECT internal_functions.c)
2121
add_library(php_main_internal_functions_cli OBJECT internal_functions_cli.c)
2222

23-
# Configuration library to transitively pass build options to php_main* targets.
24-
add_library(php_main_configuration INTERFACE)
25-
add_library(PHP::mainConfiguration ALIAS php_main_configuration)
26-
2723
target_sources(
2824
php_main
2925
PRIVATE
@@ -140,51 +136,83 @@ if(_HAVE_ELF)
140136
endif()
141137

142138
target_compile_definitions(
143-
php_main_configuration
144-
INTERFACE
145-
ZEND_ENABLE_STATIC_TSRMLS_CACHE=1
139+
php_main
140+
PUBLIC
146141
$<$<PLATFORM_ID:Windows>:SAPI_EXPORTS>
147142
)
148143

149-
target_link_libraries(
150-
php_main_configuration
151-
INTERFACE
152-
PHP::configuration
153-
$<$<TARGET_EXISTS:PHP::win32>:PHP::win32 $<TARGET_OBJECTS:PHP::win32>>
154-
)
155-
156-
target_link_libraries(php_main PRIVATE PHP::mainConfiguration)
157-
target_link_libraries(php_main_internal_functions PRIVATE PHP::mainConfiguration)
158-
target_link_libraries(php_main_internal_functions_cli PRIVATE PHP::mainConfiguration)
159-
160144
target_include_directories(
161145
php_main
162146
INTERFACE
163147
${CMAKE_CURRENT_BINARY_DIR}
164148
${CMAKE_CURRENT_SOURCE_DIR}
165149
)
166150

167-
# Add main PUBLIC/INTERFACE include directories to configuration.
168-
target_include_directories(
169-
php_configuration
170-
INTERFACE
171-
$<TARGET_PROPERTY:PHP::main,INTERFACE_INCLUDE_DIRECTORIES>
151+
set_property(
152+
TARGET
153+
php_main
154+
php_main_internal_functions
155+
php_main_internal_functions_cli
156+
APPEND
157+
PROPERTY COMPILE_DEFINITIONS ZEND_ENABLE_STATIC_TSRMLS_CACHE=1
172158
)
173159

160+
# Add main PUBLIC/INTERFACE compile properties to configuration.
161+
# Cleaner COMPILE_ONLY generator expression is available in CMake >= 3.27.
162+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)
163+
target_link_libraries(php_configuration INTERFACE $<COMPILE_ONLY:php_main>)
164+
else()
165+
target_include_directories(
166+
php_configuration
167+
INTERFACE
168+
$<TARGET_PROPERTY:php_main,INTERFACE_INCLUDE_DIRECTORIES>
169+
)
170+
target_compile_definitions(
171+
php_configuration
172+
INTERFACE
173+
$<TARGET_PROPERTY:php_main,INTERFACE_COMPILE_DEFINITIONS>
174+
)
175+
endif()
176+
177+
target_link_libraries(php_main PRIVATE PHP::configuration)
178+
target_link_libraries(php_main_internal_functions PRIVATE PHP::configuration)
179+
target_link_libraries(php_main_internal_functions_cli PRIVATE PHP::configuration)
180+
181+
################################################################################
182+
# Add PHP::PHP.
183+
################################################################################
184+
185+
add_library(php INTERFACE)
186+
add_library(PHP::PHP ALIAS php)
187+
174188
target_link_libraries(
175189
php
176190
INTERFACE
177191
PHP::configuration
178-
PHP::main
179-
$<TARGET_OBJECTS:PHP::main>
180-
# Pass transitively depending on the SAPI type.
181-
$<IF:$<IN_LIST:$<TARGET_PROPERTY:NAME>,php_cgi;php_cli;php_embed;php_phpdbg>,php_main_internal_functions_cli $<TARGET_OBJECTS:php_main_internal_functions_cli>,php_main_internal_functions $<TARGET_OBJECTS:php_main_internal_functions>>
192+
php_main
182193
Zend::Zend
183-
$<TARGET_OBJECTS:Zend::Zend>
194+
$<$<TARGET_EXISTS:PHP::windows>::PHP::windows>
184195
PHP::extensions
185196
)
186197

198+
# OBJECT libraries propagate only compile properties to static libraries without
199+
# objects as there is no "linking" involved on the compiler level. This is a
200+
# workaround using interface target sources to make PHP::PHP more intuitive to
201+
# work with SAPIs.
202+
target_sources(
203+
php
204+
INTERFACE
205+
$<TARGET_OBJECTS:php_main>
206+
# Internal functions objects based on the SAPI type.
207+
$<IF:$<BOOL:$<TARGET_PROPERTY:PHP_SAPI_CLI>>,$<TARGET_OBJECTS:php_main_internal_functions_cli>,$<TARGET_OBJECTS:php_main_internal_functions>>
208+
$<TARGET_OBJECTS:Zend::Zend>
209+
$<$<TARGET_EXISTS:PHP::windows>:$<TARGET_OBJECTS:PHP::windows>>
210+
)
211+
212+
################################################################################
187213
# Add DTrace.
214+
################################################################################
215+
188216
if(PHP_DTRACE)
189217
message(CHECK_START "Checking for DTrace support")
190218

@@ -223,7 +251,10 @@ add_feature_info(
223251
"performance analysis and troubleshooting"
224252
)
225253

254+
################################################################################
226255
# Add Dmalloc.
256+
################################################################################
257+
227258
if(PHP_DMALLOC)
228259
message(CHECK_START "Checking for Dmalloc support")
229260

@@ -238,7 +269,7 @@ if(PHP_DMALLOC)
238269
target_compile_definitions(
239270
php_configuration
240271
INTERFACE
241-
$<$<COMPILE_LANGUAGE:ASM,C,CXX>:MALLOC_FUNC_CHECK>
272+
$<$<COMPILE_LANGUAGE:ASM,C,CXX>:DMALLOC_FUNC_CHECK>
242273
)
243274

244275
target_link_libraries(php_main PRIVATE Dmalloc::Dmalloc)

cmake/sapi/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Add subdirectories of PHP SAPIs.
1010
* `PHP_SAPIS`
1111
1212
Global property with a list of all enabled PHP SAPIs.
13+
14+
* `PHP_SAPI_CLI`
15+
16+
Target property that designates PHP SAPI as CLI-based. These SAPIs can utilize
17+
CLI-based PHP extensions (for example, pcntl) and include
18+
main/internal_functions_cli.c object instead of the main/internal_functions.c.
1319
#]=============================================================================]
1420

1521
message(STATUS "----------------------------")
@@ -28,6 +34,12 @@ define_property(
2834
BRIEF_DOCS "A list of all enabled PHP SAPIs"
2935
)
3036

37+
define_property(
38+
TARGET
39+
PROPERTY PHP_SAPI_CLI
40+
BRIEF_DOCS "Whether the PHP SAPI is CLI-based to run in a CLI environment"
41+
)
42+
3143
list(APPEND CMAKE_MESSAGE_CONTEXT "sapi")
3244

3345
# Traverse CMakeLists.txt files of PHP SAPIs.

cmake/sapi/cgi/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ set_target_properties(
5757
OUTPUT_NAME ${PHP_PROGRAM_PREFIX}php-cgi${PHP_PROGRAM_SUFFIX}
5858
# TODO: Check if there's a better solution here:
5959
ENABLE_EXPORTS TRUE
60+
PHP_SAPI_CLI TRUE
6061
)
6162

6263
# BSD systems.

cmake/sapi/cli/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ set_target_properties(
118118
OUTPUT_NAME ${PHP_PROGRAM_PREFIX}php${PHP_PROGRAM_SUFFIX}
119119
# TODO: Check if there's a better solution here:
120120
ENABLE_EXPORTS TRUE
121+
PHP_SAPI_CLI TRUE
121122
)
122123

123124
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")

0 commit comments

Comments
 (0)