Skip to content

Commit 7d2c6a7

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 74b5d06 + d009fd6 commit 7d2c6a7

File tree

11 files changed

+185
-132
lines changed

11 files changed

+185
-132
lines changed

cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ project(
1818
VERSION ${PHP_VERSION}
1919
DESCRIPTION "Widely-used general-purpose scripting language"
2020
HOMEPAGE_URL "https://www.php.net"
21-
LANGUAGES C CXX ASM
21+
LANGUAGES C
2222
)
2323

2424
set(CMAKE_C_STANDARD 11)

cmake/Zend/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ project(
4444
Zend
4545
VERSION ${Zend_VERSION}
4646
DESCRIPTION "Zend Engine library"
47-
LANGUAGES C CXX ASM
47+
LANGUAGES C
4848
)
4949

50+
include(CheckLanguage)
51+
check_language(ASM)
52+
if(CMAKE_ASM_COMPILER)
53+
enable_language(ASM)
54+
endif()
55+
5056
string(APPEND Zend_VERSION "${Zend_VERSION_LABEL}")
5157
message(STATUS "Zend Engine version: ${Zend_VERSION}")
5258

cmake/cmake/Bootstrap.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ Configure project after the project() call.
44

55
include_guard(GLOBAL)
66

7+
# Optionally enable CXX for extensions and ASM for Zend Engine. ASM is enabled
8+
# last so CMake checks whether enabled compilers can also work for assembly.
9+
include(CheckLanguage)
10+
foreach(language CXX ASM)
11+
check_language(${language})
12+
if(CMAKE_${language}_COMPILER)
13+
enable_language(${language})
14+
endif()
15+
endforeach()
16+
717
# Output linker information.
818
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)
919
if(CMAKE_C_COMPILER_LINKER)

cmake/cmake/Flags.cmake

Lines changed: 106 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ include(CheckSourceRuns)
88
include(CMakePushCheckState)
99
include(PHP/CheckCompilerFlag)
1010

11+
get_cmake_property(enabledLanguages ENABLED_LANGUAGES)
12+
1113
# Check for broken GCC optimize-strlen.
1214
include(PHP/CheckBrokenGccStrlenOpt)
1315
if(PHP_HAVE_BROKEN_OPTIMIZE_STRLEN)
@@ -78,14 +80,16 @@ if(HAVE_WNO_CLOBBERED_C)
7880
$<$<COMPILE_LANGUAGE:ASM,C>:-Wno-clobbered>
7981
)
8082
endif()
81-
php_check_compiler_flag(CXX -Wno-clobbered HAVE_WNO_CLOBBERED_CXX)
82-
if(HAVE_WNO_CLOBBERED_CXX)
83-
target_compile_options(
84-
php_configuration
85-
BEFORE
86-
INTERFACE
87-
$<$<COMPILE_LANGUAGE:CXX>:-Wno-clobbered>
88-
)
83+
if(CXX IN_LIST enabledLanguages)
84+
php_check_compiler_flag(CXX -Wno-clobbered HAVE_WNO_CLOBBERED_CXX)
85+
if(HAVE_WNO_CLOBBERED_CXX)
86+
target_compile_options(
87+
php_configuration
88+
BEFORE
89+
INTERFACE
90+
$<$<COMPILE_LANGUAGE:CXX>:-Wno-clobbered>
91+
)
92+
endif()
8993
endif()
9094

9195
# Check for support for implicit fallthrough level 1, also add after previous
@@ -102,17 +106,19 @@ if(HAVE_WIMPLICIT_FALLTHROUGH_1_C)
102106
$<$<COMPILE_LANGUAGE:ASM,C>:-Wimplicit-fallthrough=1>
103107
)
104108
endif()
105-
php_check_compiler_flag(
106-
CXX
107-
-Wimplicit-fallthrough=1
108-
HAVE_WIMPLICIT_FALLTHROUGH_1_CXX
109-
)
110-
if(HAVE_WIMPLICIT_FALLTHROUGH_1_CXX)
111-
target_compile_options(
112-
php_configuration
113-
INTERFACE
114-
$<$<COMPILE_LANGUAGE:CXX>:-Wimplicit-fallthrough=1>
109+
if(CXX IN_LIST enabledLanguages)
110+
php_check_compiler_flag(
111+
CXX
112+
-Wimplicit-fallthrough=1
113+
HAVE_WIMPLICIT_FALLTHROUGH_1_CXX
115114
)
115+
if(HAVE_WIMPLICIT_FALLTHROUGH_1_CXX)
116+
target_compile_options(
117+
php_configuration
118+
INTERFACE
119+
$<$<COMPILE_LANGUAGE:CXX>:-Wimplicit-fallthrough=1>
120+
)
121+
endif()
116122
endif()
117123

118124
php_check_compiler_flag(C -Wduplicated-cond HAVE_WDUPLICATED_COND_C)
@@ -124,14 +130,16 @@ if(HAVE_WDUPLICATED_COND_C)
124130
$<$<COMPILE_LANGUAGE:ASM,C>:-Wduplicated-cond>
125131
)
126132
endif()
127-
php_check_compiler_flag(CXX -Wduplicated-cond HAVE_WDUPLICATED_COND_CXX)
128-
if(HAVE_WDUPLICATED_COND_CXX)
129-
target_compile_options(
130-
php_configuration
131-
BEFORE
132-
INTERFACE
133-
$<$<COMPILE_LANGUAGE:CXX>:-Wduplicated-cond>
134-
)
133+
if(CXX IN_LIST enabledLanguages)
134+
php_check_compiler_flag(CXX -Wduplicated-cond HAVE_WDUPLICATED_COND_CXX)
135+
if(HAVE_WDUPLICATED_COND_CXX)
136+
target_compile_options(
137+
php_configuration
138+
BEFORE
139+
INTERFACE
140+
$<$<COMPILE_LANGUAGE:CXX>:-Wduplicated-cond>
141+
)
142+
endif()
135143
endif()
136144

137145
php_check_compiler_flag(C -Wlogical-op HAVE_WLOGICAL_OP_C)
@@ -143,14 +151,16 @@ if(HAVE_WLOGICAL_OP_C)
143151
$<$<COMPILE_LANGUAGE:ASM,C>:-Wlogical-op>
144152
)
145153
endif()
146-
php_check_compiler_flag(CXX -Wlogical-op HAVE_WLOGICAL_OP_CXX)
147-
if(HAVE_WLOGICAL_OP_CXX)
148-
target_compile_options(
149-
php_configuration
150-
BEFORE
151-
INTERFACE
152-
$<$<COMPILE_LANGUAGE:CXX>:-Wlogical-op>
153-
)
154+
if(CXX IN_LIST enabledLanguages)
155+
php_check_compiler_flag(CXX -Wlogical-op HAVE_WLOGICAL_OP_CXX)
156+
if(HAVE_WLOGICAL_OP_CXX)
157+
target_compile_options(
158+
php_configuration
159+
BEFORE
160+
INTERFACE
161+
$<$<COMPILE_LANGUAGE:CXX>:-Wlogical-op>
162+
)
163+
endif()
154164
endif()
155165

156166
php_check_compiler_flag(C -Wformat-truncation HAVE_WFORMAT_TRUNCATION_C)
@@ -162,14 +172,16 @@ if(HAVE_WFORMAT_TRUNCATION_C)
162172
$<$<COMPILE_LANGUAGE:ASM,C>:-Wformat-truncation>
163173
)
164174
endif()
165-
php_check_compiler_flag(CXX -Wformat-truncation HAVE_WFORMAT_TRUNCATION_CXX)
166-
if(HAVE_WFORMAT_TRUNCATION_CXX)
167-
target_compile_options(
168-
php_configuration
169-
BEFORE
170-
INTERFACE
171-
$<$<COMPILE_LANGUAGE:CXX>:-Wformat-truncation>
172-
)
175+
if(CXX IN_LIST enabledLanguages)
176+
php_check_compiler_flag(CXX -Wformat-truncation HAVE_WFORMAT_TRUNCATION_CXX)
177+
if(HAVE_WFORMAT_TRUNCATION_CXX)
178+
target_compile_options(
179+
php_configuration
180+
BEFORE
181+
INTERFACE
182+
$<$<COMPILE_LANGUAGE:CXX>:-Wformat-truncation>
183+
)
184+
endif()
173185
endif()
174186

175187
php_check_compiler_flag(C -Wstrict-prototypes HAVE_WSTRICT_PROTOTYPES_C)
@@ -191,14 +203,16 @@ if(HAVE_FNO_COMMON_C)
191203
$<$<COMPILE_LANGUAGE:ASM,C>:-fno-common>
192204
)
193205
endif()
194-
php_check_compiler_flag(CXX -fno-common HAVE_FNO_COMMON_CXX)
195-
if(HAVE_FNO_COMMON_C_XX)
196-
target_compile_options(
197-
php_configuration
198-
BEFORE
199-
INTERFACE
200-
$<$<COMPILE_LANGUAGE:CXX>:-fno-common>
201-
)
206+
if(CXX IN_LIST enabledLanguages)
207+
php_check_compiler_flag(CXX -fno-common HAVE_FNO_COMMON_CXX)
208+
if(HAVE_FNO_COMMON_C_XX)
209+
target_compile_options(
210+
php_configuration
211+
BEFORE
212+
INTERFACE
213+
$<$<COMPILE_LANGUAGE:CXX>:-fno-common>
214+
)
215+
endif()
202216
endif()
203217

204218
# Explicitly disable floating-point expression contraction, even if already done
@@ -240,14 +254,16 @@ if(PHP_MEMORY_SANITIZER)
240254
HAVE_MEMORY_SANITIZER_C
241255
)
242256

243-
php_check_compiler_flag(
244-
CXX
245-
"-fsanitize=memory;-fsanitize-memory-track-origins"
246-
HAVE_MEMORY_SANITIZER_CXX
247-
)
257+
if(CXX IN_LIST enabledLanguages)
258+
php_check_compiler_flag(
259+
CXX
260+
"-fsanitize=memory;-fsanitize-memory-track-origins"
261+
HAVE_MEMORY_SANITIZER_CXX
262+
)
263+
endif()
248264
cmake_pop_check_state()
249265

250-
if(HAVE_MEMORY_SANITIZER_C AND HAVE_MEMORY_SANITIZER_CXX)
266+
if(HAVE_MEMORY_SANITIZER_C OR HAVE_MEMORY_SANITIZER_CXX)
251267
target_compile_options(
252268
php_configuration
253269
INTERFACE
@@ -284,10 +300,12 @@ if(PHP_ADDRESS_SANITIZER)
284300
set(CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=address")
285301

286302
php_check_compiler_flag(C -fsanitize=address HAVE_ADDRESS_SANITIZER_C)
287-
php_check_compiler_flag(CXX -fsanitize=address HAVE_ADDRESS_SANITIZER_CXX)
303+
if(CXX IN_LIST enabledLanguages)
304+
php_check_compiler_flag(CXX -fsanitize=address HAVE_ADDRESS_SANITIZER_CXX)
305+
endif()
288306
cmake_pop_check_state()
289307

290-
if(HAVE_ADDRESS_SANITIZER_C AND HAVE_ADDRESS_SANITIZER_CXX)
308+
if(HAVE_ADDRESS_SANITIZER_C OR HAVE_ADDRESS_SANITIZER_CXX)
291309
target_compile_options(
292310
php_configuration
293311
INTERFACE
@@ -325,14 +343,16 @@ if(PHP_UNDEFINED_SANITIZER)
325343
-fsanitize=undefined
326344
HAVE_UNDEFINED_SANITIZER_C
327345
)
328-
php_check_compiler_flag(
329-
CXX
330-
-fsanitize=undefined
331-
HAVE_UNDEFINED_SANITIZER_CXX
332-
)
346+
if(CXX IN_LIST enabledLanguages)
347+
php_check_compiler_flag(
348+
CXX
349+
-fsanitize=undefined
350+
HAVE_UNDEFINED_SANITIZER_CXX
351+
)
352+
endif()
333353
cmake_pop_check_state()
334354

335-
if(HAVE_UNDEFINED_SANITIZER_C AND HAVE_UNDEFINED_SANITIZER_CXX)
355+
if(HAVE_UNDEFINED_SANITIZER_C OR HAVE_UNDEFINED_SANITIZER_CXX)
336356
target_compile_options(
337357
php_configuration
338358
INTERFACE
@@ -355,14 +375,16 @@ if(PHP_UNDEFINED_SANITIZER)
355375
-fno-sanitize=object-size
356376
HAVE_OBJECT_SIZE_SANITIZER_C
357377
)
358-
php_check_compiler_flag(
359-
CXX
360-
-fno-sanitize=object-size
361-
HAVE_OBJECT_SIZE_SANITIZER_CXX
362-
)
378+
if(CXX IN_LIST enabledLanguages)
379+
php_check_compiler_flag(
380+
CXX
381+
-fno-sanitize=object-size
382+
HAVE_OBJECT_SIZE_SANITIZER_CXX
383+
)
384+
endif()
363385
cmake_pop_check_state()
364386

365-
if(HAVE_OBJECT_SIZE_SANITIZER_C AND HAVE_OBJECT_SIZE_SANITIZER_CXX)
387+
if(HAVE_OBJECT_SIZE_SANITIZER_C OR HAVE_OBJECT_SIZE_SANITIZER_CXX)
366388
target_compile_options(
367389
php_configuration
368390
INTERFACE
@@ -412,11 +434,13 @@ if(PHP_UNDEFINED_SANITIZER)
412434
-fno-sanitize=function
413435
HAVE_FNO_SANITIZE_FUNCTION_C
414436
)
415-
php_check_compiler_flag(
416-
CXX
417-
-fno-sanitize=function
418-
HAVE_FNO_SANITIZE_FUNCTION_CXX
419-
)
437+
if(CXX IN_LIST enabledLanguages)
438+
php_check_compiler_flag(
439+
CXX
440+
-fno-sanitize=function
441+
HAVE_FNO_SANITIZE_FUNCTION_CXX
442+
)
443+
endif()
420444

421445
if(HAVE_FNO_SANITIZE_FUNCTION_C)
422446
target_compile_options(
@@ -448,11 +472,13 @@ if(PHP_MEMORY_SANITIZER OR PHP_ADDRESS_SANITIZER OR PHP_UNDEFINED_SANITIZER)
448472
-fno-omit-frame-pointer
449473
HAVE_FNO_OMIT_FRAME_POINTER_C
450474
)
451-
php_check_compiler_flag(
452-
CXX
453-
-fno-omit-frame-pointer
454-
HAVE_FNO_OMIT_FRAME_POINTER_CXX
455-
)
475+
if(CXX IN_LIST enabledLanguages)
476+
php_check_compiler_flag(
477+
CXX
478+
-fno-omit-frame-pointer
479+
HAVE_FNO_OMIT_FRAME_POINTER_CXX
480+
)
481+
endif()
456482

457483
if(HAVE_FNO_OMIT_FRAME_POINTER_C)
458484
target_compile_options(

0 commit comments

Comments
 (0)