Skip to content

Commit 86015b3

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 77a3903 + 75414d6 commit 86015b3

File tree

14 files changed

+137
-651
lines changed

14 files changed

+137
-651
lines changed

cmake/cmake/Flags.cmake

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,8 @@ endif()
219219
if(PHP_MEMORY_SANITIZER)
220220
message(CHECK_START "Checking memory sanitizer compiler options")
221221

222-
cmake_push_check_state(RESET)
223-
set(
224-
CMAKE_REQUIRED_LINK_OPTIONS
225-
-fsanitize=memory
226-
-fsanitize-memory-track-origins
227-
)
222+
block()
223+
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
228224

229225
php_check_compiler_flag(
230226
C
@@ -239,19 +235,19 @@ if(PHP_MEMORY_SANITIZER)
239235
PHP_HAS_MEMORY_SANITIZER_CXX
240236
)
241237
endif()
242-
cmake_pop_check_state()
238+
endblock()
243239

244240
if(PHP_HAS_MEMORY_SANITIZER_C OR PHP_HAS_MEMORY_SANITIZER_CXX)
245241
target_compile_options(
246242
php_config
247243
INTERFACE
248-
$<$<COMPILE_LANGUAGE:ASM,C,CXX>:-fsanitize=memory;-fsanitize-memory-track-origins>
244+
$<$<COMPILE_LANGUAGE:C,CXX>:-fsanitize=memory;-fsanitize-memory-track-origins>
249245
)
250246

251247
target_link_options(
252248
php_config
253249
INTERFACE
254-
$<$<COMPILE_LANGUAGE:ASM,C,CXX>:-fsanitize=memory;-fsanitize-memory-track-origins>
250+
$<$<LINK_LANGUAGE:C,CXX>:-fsanitize=memory;-fsanitize-memory-track-origins>
255251
)
256252

257253
message(CHECK_PASS "Success")

cmake/cmake/modules/PHP/CheckCompilerFlag.cmake

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,25 @@ Bypasses:
2525
Module exposes the following function:
2626
2727
```cmake
28-
php_check_compiler_flag(<lang> <flag> <result_var>)
28+
php_check_compiler_flag(<lang> <flags> <result_var>)
2929
```
3030
31-
Check that the <flag> is accepted by the <lang> compiler without issuing any
32-
diagnostic message. The result is stored in an internal cache entry named
33-
`<result_var>`. The language `<lang>` can be one of the supported languages by
34-
the CMake's `CheckCompilerFlag` module.
31+
Check that the given flag(s) specified in `<flags>` are accepted by the `<lang>`
32+
compiler without issuing any diagnostic message. The result is stored in an
33+
internal cache entry named `<result_var>`. The language `<lang>` can be one of
34+
the supported languages by the CMake's `CheckCompilerFlag` module. Multiple
35+
flags can be passed as a semicolon-separated list.
3536
36-
For example:
37+
# Examples
3738
38-
```cmake
39-
include(PHP/CheckCompilerFlag)
40-
41-
php_check_compiler_flag(C -Wno-clobbered PHP_HAVE_WNO_CLOBBERED)
42-
```
43-
44-
## Usage
39+
Usage example:
4540
4641
```cmake
4742
# CMakeLists.txt
43+
4844
include(PHP/CheckCompilerFlag)
45+
46+
php_check_compiler_flag(C -Wno-clobbered PHP_HAS_WNO_CLOBBERED)
4947
```
5048
#]=============================================================================]
5149

@@ -54,7 +52,7 @@ include_guard(GLOBAL)
5452
include(CheckCompilerFlag)
5553
include(CMakePushCheckState)
5654

57-
function(php_check_compiler_flag lang flag result)
55+
function(php_check_compiler_flag lang flags result)
5856
cmake_parse_arguments(
5957
PARSE_ARGV
6058
3
@@ -78,27 +76,37 @@ function(php_check_compiler_flag lang flag result)
7876
endif()
7977

8078
if(NOT CMAKE_REQUIRED_QUIET)
81-
message(CHECK_START "Checking whether the ${lang} compiler accepts ${flag}")
79+
message(CHECK_START "Checking whether the ${lang} compiler accepts ${flags}")
8280
endif()
8381

8482
cmake_push_check_state()
8583
set(CMAKE_REQUIRED_QUIET TRUE)
8684

8785
# Bypass the '-Wno-*' compile options for all compilers except those known
8886
# to emit diagnostic messages for unknown -Wno-* flags.
89-
if(
90-
NOT CMAKE_${lang}_COMPILER_ID MATCHES "^(AppleClang|Clang|MSVC)$"
91-
AND flag MATCHES "^-Wno-"
92-
# Exclude the '-Wno-error' and '-Wno-attributes=*' flags.
93-
AND NOT flag MATCHES "^-Wno-error(=|$)|^-Wno-attributes="
94-
)
95-
string(REGEX REPLACE "^-Wno-" "-W" flag ${flag})
96-
endif()
87+
set(processedFlags "")
88+
foreach(flag IN LISTS flags)
89+
if(
90+
NOT CMAKE_${lang}_COMPILER_ID MATCHES "^(AppleClang|Clang|MSVC)$"
91+
AND flag MATCHES "^-Wno-"
92+
# Exclude the '-Wno-error' and '-Wno-attributes=*' flags.
93+
AND NOT flag MATCHES "^-Wno-error(=|$)|^-Wno-attributes="
94+
)
95+
string(REGEX REPLACE "^-Wno-" "-W" flag "${flag}")
96+
endif()
97+
98+
list(APPEND processedFlags "${flag}")
99+
endforeach()
100+
set(flags ${processedFlags})
97101

98102
# Append -Wunknown-warning-option option if compiler supports it (Clang or
99103
# similar) and was by any chance configured with -Wno-unknown-warning-option
100104
# (via environment CFLAGS or CMAKE_C_FLAGS).
101-
if(flag MATCHES "^-W")
105+
foreach(flag IN LISTS flags)
106+
if(NOT flag MATCHES "^-W")
107+
continue()
108+
endif()
109+
102110
check_compiler_flag(
103111
${lang}
104112
-Wunknown-warning-option
@@ -108,9 +116,11 @@ function(php_check_compiler_flag lang flag result)
108116
if(_php_check_compiler_flag_${lang}_unknown_warning_option)
109117
string(APPEND CMAKE_REQUIRED_FLAGS " -Wunknown-warning-option")
110118
endif()
111-
endif()
112119

113-
check_compiler_flag(${lang} ${flag} ${result})
120+
break()
121+
endforeach()
122+
123+
check_compiler_flag(${lang} "${flags}" ${result})
114124
cmake_pop_check_state()
115125

116126
if(NOT CMAKE_REQUIRED_QUIET)

cmake/sapi/cgi/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ target_link_libraries(
4545
$<$<PLATFORM_ID:Windows>:ws2_32;kernel32;advapi32>
4646
)
4747

48-
target_link_options(
49-
php_sapi_cgi
50-
PRIVATE
51-
$<$<COMPILE_LANG_AND_ID:C,MSVC>:/stack:67108864>
52-
)
48+
if(MSVC)
49+
target_link_options(php_sapi_cgi PRIVATE /stack:67108864)
50+
endif()
5351

5452
set_target_properties(
5553
php_sapi_cgi

cmake/sapi/cli/CMakeLists.txt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,9 @@ target_link_libraries(
114114
$<$<PLATFORM_ID:Windows>:ws2_32;shell32>
115115
)
116116

117-
target_link_options(
118-
php_sapi_cli
119-
PRIVATE
120-
$<$<COMPILE_LANG_AND_ID:C,MSVC>:/stack:67108864>
121-
)
117+
if(MSVC)
118+
target_link_options(php_sapi_cli PRIVATE /stack:67108864)
119+
endif()
122120

123121
set_target_properties(
124122
php_sapi_cli
@@ -188,11 +186,9 @@ if(PHP_SAPI_CLI_WIN_NO_CONSOLE)
188186
shell32
189187
)
190188

191-
target_link_options(
192-
php_sapi_cli_win
193-
PRIVATE
194-
$<$<COMPILE_LANG_AND_ID:C,MSVC>:/stack:67108864>
195-
)
189+
if(MSVC)
190+
target_link_options(php_sapi_cli_win PRIVATE /stack:67108864)
191+
endif()
196192
endif()
197193

198194
################################################################################

cmake/sapi/embed/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ php_pkgconfig_generate_pc(
102102
PHP_DEBUG "$<IF:$<CONFIG:Debug,DebugAssertions>,yes,no>"
103103
PHP_THREAD_SAFETY "$<IF:$<BOOL:$<TARGET_PROPERTY:PHP::config,PHP_THREAD_SAFETY>>,yes,no>"
104104
PHP_EMBED_SAPI_NAME "$<GENEX_EVAL:$<TARGET_PROPERTY:php_sapi_embed_shared,OUTPUT_NAME>>"
105+
PHP_API_VERSION "${PHP_API_VERSION}"
106+
PHP_ZEND_EXTENSION_API_NO "$<TARGET_PROPERTY:Zend::Zend,ZEND_EXTENSION_API_NO>"
107+
PHP_ZEND_MODULE_API_NO "$<TARGET_PROPERTY:Zend::Zend,ZEND_MODULE_API_NO>"
105108
)
106109

107110
install(

cmake/sapi/embed/php-embed.pc.in

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,40 @@ exec_prefix=@exec_prefix@
1414
includedir=@includedir@
1515
php_include_prefix=@php_include_prefix@
1616
libdir=@libdir@
17+
1718
# The extension_dir PHP INI directive absolute path.
1819
extensiondir=@PHP_EXTENSION_DIR@
20+
1921
# PHP version as integer.
2022
php_vernum=@PHP_VERSION_ID@
23+
2124
# The path where to scan for additional INI configuration files.
2225
php_ini_dir=@PHP_CONFIG_FILE_SCAN_DIR@
26+
2327
# The path in which to look for php.ini.
2428
php_ini_path=@PHP_CONFIG_FILE_PATH@
29+
2530
# Whether PHP is built in debug mode (yes) or not (no).
2631
php_debug=@PHP_DEBUG@
32+
2733
# Whether PHP is built with thread safety (yes) or not (no).
2834
php_zts=@PHP_THREAD_SAFETY@
2935

36+
# Internal PHP API version number.
37+
php_api_version=@PHP_API_VERSION@
38+
39+
# Internal API version number for Zend extensions in PHP (dynamically loaded
40+
# with zend_extension INI directive), such as opcache, debuggers, profilers,
41+
# etc. This is the ZEND_EXTENSION_API_NO number in Zend/zend_extensions.h and
42+
# ensures that built extension is compatible with particular PHP build.
43+
php_zend_extension_api_no=@PHP_ZEND_EXTENSION_API_NO@
44+
45+
# Internal API version number for PHP extensions (dynamically loaded with
46+
# extension INI directive). This is the ZEND_MODULE_API_NO number in
47+
# Zend/zend_modules.h and ensures that built extension is compatible with
48+
# particular PHP build.
49+
php_zend_module_api_no=@PHP_ZEND_MODULE_API_NO@
50+
3051
Name: PHP Embed SAPI
3152
Description: A lightweight SAPI to embed PHP into application using C bindings
3253
URL: https://www.php.net

cmake/sapi/phpdbg/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,9 @@ foreach(target IN ITEMS php_sapi_phpdbg php_sapi_phpdbg_shared)
169169
)
170170
endforeach()
171171

172-
target_link_options(
173-
php_sapi_phpdbg
174-
PRIVATE
175-
$<$<COMPILE_LANG_AND_ID:C,MSVC>:/stack:8388608>
176-
)
172+
if(MSVC)
173+
target_link_options(php_sapi_phpdbg PRIVATE /stack:8388608)
174+
endif()
177175

178176
set_target_properties(
179177
php_sapi_phpdbg
@@ -305,6 +303,9 @@ if(TARGET php_sapi_phpdbg_shared)
305303
PHP_DEBUG "$<IF:$<CONFIG:Debug,DebugAssertions>,yes,no>"
306304
PHP_THREAD_SAFETY "$<IF:$<BOOL:$<TARGET_PROPERTY:PHP::config,PHP_THREAD_SAFETY>>,yes,no>"
307305
PHP_PHPDBG_SAPI_NAME "$<GENEX_EVAL:$<TARGET_PROPERTY:php_sapi_phpdbg_shared,OUTPUT_NAME>>"
306+
PHP_API_VERSION "${PHP_API_VERSION}"
307+
PHP_ZEND_EXTENSION_API_NO "$<TARGET_PROPERTY:Zend::Zend,ZEND_EXTENSION_API_NO>"
308+
PHP_ZEND_MODULE_API_NO "$<TARGET_PROPERTY:Zend::Zend,ZEND_MODULE_API_NO>"
308309
)
309310

310311
install(

cmake/sapi/phpdbg/phpdbg.pc.in

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,40 @@ exec_prefix=@exec_prefix@
1414
includedir=@includedir@
1515
php_include_prefix=@php_include_prefix@
1616
libdir=@libdir@
17+
1718
# The extension_dir PHP INI directive absolute path.
1819
extensiondir=@PHP_EXTENSION_DIR@
20+
1921
# PHP version as integer.
2022
php_vernum=@PHP_VERSION_ID@
23+
2124
# The path where to scan for additional INI configuration files.
2225
php_ini_dir=@PHP_CONFIG_FILE_SCAN_DIR@
26+
2327
# The path in which to look for php.ini.
2428
php_ini_path=@PHP_CONFIG_FILE_PATH@
29+
2530
# Whether PHP is built in debug mode (yes) or not (no).
2631
php_debug=@PHP_DEBUG@
32+
2733
# Whether PHP is built with thread safety (yes) or not (no).
2834
php_zts=@PHP_THREAD_SAFETY@
2935

36+
# Internal PHP API version number.
37+
php_api_version=@PHP_API_VERSION@
38+
39+
# Internal API version number for Zend extensions in PHP (dynamically loaded
40+
# with zend_extension INI directive), such as opcache, debuggers, profilers,
41+
# etc. This is the ZEND_EXTENSION_API_NO number in Zend/zend_extensions.h and
42+
# ensures that built extension is compatible with particular PHP build.
43+
php_zend_extension_api_no=@PHP_ZEND_EXTENSION_API_NO@
44+
45+
# Internal API version number for PHP extensions (dynamically loaded with
46+
# extension INI directive). This is the ZEND_MODULE_API_NO number in
47+
# Zend/zend_modules.h and ensures that built extension is compatible with
48+
# particular PHP build.
49+
php_zend_module_api_no=@PHP_ZEND_MODULE_API_NO@
50+
3051
Name: PHP debugger
3152
Description: Interactive PHP debugger
3253
URL: https://www.php.net

cmake/scripts/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ php_pkgconfig_generate_pc(
2020
PHP_CONFIG_FILE_PATH "$<PATH:ABSOLUTE_PATH,NORMALIZE,${PHP_CONFIG_FILE_PATH},$<INSTALL_PREFIX>>"
2121
PHP_DEBUG "$<IF:$<CONFIG:Debug,DebugAssertions>,yes,no>"
2222
PHP_THREAD_SAFETY "$<IF:$<BOOL:$<TARGET_PROPERTY:PHP::config,PHP_THREAD_SAFETY>>,yes,no>"
23+
PHP_API_VERSION "${PHP_API_VERSION}"
24+
PHP_ZEND_EXTENSION_API_NO "$<TARGET_PROPERTY:Zend::Zend,ZEND_EXTENSION_API_NO>"
25+
PHP_ZEND_MODULE_API_NO "$<TARGET_PROPERTY:Zend::Zend,ZEND_MODULE_API_NO>"
2326
)
2427

2528
install(

cmake/scripts/php.pc.in

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The pkg-config .pc file for PHP Embed SAPI.
1+
# The pkg-config .pc file for PHP installation.
22
# https://en.wikipedia.org/wiki/Pkg-config
33
#
44
# Usage:
@@ -14,19 +14,40 @@ exec_prefix=@exec_prefix@
1414
includedir=@includedir@
1515
php_include_prefix=@php_include_prefix@
1616
libdir=@libdir@
17+
1718
# The extension_dir PHP INI directive absolute path.
1819
extensiondir=@PHP_EXTENSION_DIR@
20+
1921
# PHP version as integer.
2022
php_vernum=@PHP_VERSION_ID@
23+
2124
# The path where to scan for additional INI configuration files.
2225
php_ini_dir=@PHP_CONFIG_FILE_SCAN_DIR@
26+
2327
# The path in which to look for php.ini.
2428
php_ini_path=@PHP_CONFIG_FILE_PATH@
29+
2530
# Whether PHP is built in debug mode (yes) or not (no).
2631
php_debug=@PHP_DEBUG@
32+
2733
# Whether PHP is built with thread safety (yes) or not (no).
2834
php_zts=@PHP_THREAD_SAFETY@
2935

36+
# Internal PHP API version number.
37+
php_api_version=@PHP_API_VERSION@
38+
39+
# Internal API version number for Zend extensions in PHP (dynamically loaded
40+
# with zend_extension INI directive), such as opcache, debuggers, profilers,
41+
# etc. This is the ZEND_EXTENSION_API_NO number in Zend/zend_extensions.h and
42+
# ensures that built extension is compatible with particular PHP build.
43+
php_zend_extension_api_no=@PHP_ZEND_EXTENSION_API_NO@
44+
45+
# Internal API version number for PHP extensions (dynamically loaded with
46+
# extension INI directive). This is the ZEND_MODULE_API_NO number in
47+
# Zend/zend_modules.h and ensures that built extension is compatible with
48+
# particular PHP build.
49+
php_zend_module_api_no=@PHP_ZEND_MODULE_API_NO@
50+
3051
Name: PHP
3152
Description: Build extension for a PHP general-purpose scripting language
3253
URL: https://www.php.net

0 commit comments

Comments
 (0)