Skip to content

Commit e831e07

Browse files
committed
Merge branch 'PHP-8.4'
2 parents e7437e3 + d7f5619 commit e831e07

File tree

7 files changed

+103
-124
lines changed

7 files changed

+103
-124
lines changed

cmake/ext/opcache/CMakeLists.txt

Lines changed: 95 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#[=============================================================================[
2-
# The opcache extension
3-
4-
Configure the `opcache` extension.
2+
# The Zend OPcache extension
53
64
This extension enables the PHP OPcode caching engine.
75
@@ -17,7 +15,7 @@ Enable the extension. This extension is always built as shared when enabled.
1715
* Default: `ON`
1816
* Values: `ON|OFF`
1917
20-
Enable copying PHP CODE pages into HUGE PAGES
18+
Enable copying PHP CODE pages into HUGE PAGES.
2119
2220
## EXT_OPCACHE_JIT
2321
@@ -31,7 +29,7 @@ Enable JIT (Just-In-Time compiler).
3129
* Default: `OFF`
3230
* Values: `ON|OFF`
3331
34-
Enable opcache JIT disassembly through Capstone.
32+
Enable OPcache JIT disassembly through Capstone engine.
3533
#]=============================================================================]
3634

3735
project(
@@ -44,8 +42,7 @@ include(CMakeDependentOption)
4442
include(FeatureSummary)
4543
include(PHP/SearchLibraries)
4644

47-
option(EXT_OPCACHE "Enable the opcache extension" ON)
48-
45+
option(EXT_OPCACHE "Enable the Zend OPcache extension" ON)
4946
add_feature_info(
5047
"ext/opcache"
5148
EXT_OPCACHE
@@ -64,21 +61,15 @@ cmake_dependent_option(
6461
EXT_OPCACHE_JIT
6562
"Enable JIT"
6663
ON
67-
"EXT_OPCACHE"
64+
EXT_OPCACHE
6865
OFF
6966
)
7067

71-
add_feature_info(
72-
"ext/opcache JIT"
73-
EXT_OPCACHE_JIT
74-
"Opcache's JIT (Just-In-Time compiler)"
75-
)
76-
7768
cmake_dependent_option(
7869
EXT_OPCACHE_CAPSTONE
79-
"Support opcache JIT disassembly through Capstone"
70+
"Support OPcache JIT disassembly through Capstone engine"
8071
OFF
81-
"EXT_OPCACHE"
72+
EXT_OPCACHE
8273
OFF
8374
)
8475

@@ -112,13 +103,6 @@ target_sources(
112103
ZendAccelerator.c
113104
)
114105

115-
target_include_directories(
116-
php_opcache
117-
PRIVATE
118-
${CMAKE_CURRENT_SOURCE_DIR}/jit
119-
${CMAKE_CURRENT_BINARY_DIR}/jit
120-
)
121-
122106
add_dependencies(php_opcache php_date php_pcre)
123107

124108
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
@@ -141,7 +125,7 @@ endif()
141125
# JIT.
142126
################################################################################
143127

144-
# Check JIT requirements.
128+
# Check if JIT is supported by the target architecture.
145129
if(EXT_OPCACHE_JIT)
146130
if(
147131
# *nix:
@@ -168,50 +152,6 @@ if(EXT_OPCACHE_JIT)
168152
endif()
169153

170154
if(EXT_OPCACHE_JIT)
171-
set(HAVE_JIT 1)
172-
173-
target_sources(
174-
php_opcache
175-
PRIVATE
176-
jit/ir/ir_cfg.c
177-
jit/ir/ir_check.c
178-
jit/ir/ir_dump.c
179-
jit/ir/ir_emit.c
180-
jit/ir/ir_gcm.c
181-
$<$<NOT:$<PLATFORM_ID:Windows>>:jit/ir/ir_gdb.c>
182-
jit/ir/ir_patch.c
183-
$<$<NOT:$<PLATFORM_ID:Windows>>:jit/ir/ir_perf.c>
184-
jit/ir/ir_ra.c
185-
jit/ir/ir_save.c
186-
jit/ir/ir_sccp.c
187-
jit/ir/ir_strtab.c
188-
jit/ir/ir.c
189-
jit/zend_jit_vm_helpers.c
190-
jit/zend_jit.c
191-
)
192-
193-
target_include_directories(
194-
php_opcache
195-
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/jit/ir
196-
)
197-
198-
# Check for Capstone.
199-
if(EXT_OPCACHE_CAPSTONE)
200-
find_package(Capstone 3.0.0)
201-
set_package_properties(
202-
Capstone
203-
PROPERTIES
204-
TYPE REQUIRED
205-
PURPOSE "Necessary to enable OPcache JIT disassembly through Capstone."
206-
)
207-
208-
target_sources(php_opcache PRIVATE jit/ir/ir_disasm.c)
209-
210-
target_link_libraries(php_opcache PRIVATE Capstone::Capstone)
211-
212-
set(HAVE_CAPSTONE 1)
213-
endif()
214-
215155
# Find out which ABI to use.
216156
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64|ARM64)$")
217157
set(IR_TARGET "IR_TARGET_X64")
@@ -243,23 +183,12 @@ if(EXT_OPCACHE_JIT)
243183
list(APPEND DASM_FLAGS -D X64WIN=1)
244184
endif()
245185

246-
target_compile_definitions(
247-
php_opcache
248-
PRIVATE
249-
IR_PHP
250-
${IR_TARGET}
251-
$<$<CONFIG:Debug,DebugAssertions>:IR_DEBUG>
252-
)
253-
254-
add_executable(
255-
php_opcache_jit_minilua
256-
jit/ir/dynasm/minilua.c
257-
)
186+
# Generate ir_emit_<arch>.h file.
187+
add_executable(php_opcache_jit_minilua jit/ir/dynasm/minilua.c)
258188
set_target_properties(
259189
php_opcache_jit_minilua
260190
PROPERTIES
261-
OUTPUT_NAME minilua
262-
RUNTIME_OUTPUT_DIRECTORY jit/ir
191+
RUNTIME_OUTPUT_DIRECTORY CMakeFiles
263192
)
264193

265194
# Link math library as needed.
@@ -271,18 +200,27 @@ if(EXT_OPCACHE_JIT)
271200
TARGET php_opcache_jit_minilua PRIVATE
272201
)
273202

274-
# Create jit directory in the current build directory if it doesn't exist yet.
203+
# Help generators create a jit/ir build directory.
204+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/jit/ir)
205+
206+
# Generate native code generator for selected architecture.
275207
add_custom_command(
276-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/jit
277-
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/jit
278-
COMMENT "[ext/opcache] Creating ext/opcache/jit directory"
208+
OUTPUT jit/ir/ir_emit_${DASM_ARCH}.h
209+
COMMAND
210+
php_opcache_jit_minilua ${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/dynasm/dynasm.lua
211+
${DASM_FLAGS}
212+
-o ${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${DASM_ARCH}.h
213+
${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/ir_${DASM_ARCH}.dasc
214+
COMMENT "[ext/opcache] Generating native code generator ext/opcache/jit/ir/ir_emit_${DASM_ARCH}.h"
215+
DEPENDS
216+
jit/ir/dynasm/dynasm.lua
217+
jit/ir/ir_${DASM_ARCH}.dasc
218+
VERBATIM
219+
COMMAND_EXPAND_LISTS
279220
)
280221

281222
# Create IR folding engine generator.
282-
add_executable(
283-
php_opcache_jit_generator
284-
jit/ir/gen_ir_fold_hash.c
285-
)
223+
add_executable(php_opcache_jit_generator jit/ir/gen_ir_fold_hash.c)
286224
target_compile_definitions(
287225
php_opcache_jit_generator
288226
PRIVATE
@@ -293,45 +231,90 @@ if(EXT_OPCACHE_JIT)
293231
set_target_properties(
294232
php_opcache_jit_generator
295233
PROPERTIES
296-
OUTPUT_NAME gen_ir_fold_hash
297-
RUNTIME_OUTPUT_DIRECTORY jit/ir
234+
RUNTIME_OUTPUT_DIRECTORY CMakeFiles
298235
)
299236

300237
# Generate IR folding engine rules header.
301238
add_custom_command(
302-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_fold_hash.h
239+
OUTPUT jit/ir/ir_fold_hash.h
303240
COMMAND php_opcache_jit_generator
304241
< ${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/ir_fold.h
305242
> ${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_fold_hash.h
306-
DEPENDS php_opcache_jit_generator ${CMAKE_CURRENT_BINARY_DIR}/jit
307243
COMMENT "[ext/opcache] Generating folding engine rules ext/opcache/jit/ir/ir_fold_hash.h"
308-
)
309-
310-
# Generate native code generator for selected architecture.
311-
add_custom_command(
312-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${DASM_ARCH}.h
313-
COMMAND
314-
php_opcache_jit_minilua ${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/dynasm/dynasm.lua
315-
${DASM_FLAGS}
316-
-o ${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${DASM_ARCH}.h
317-
${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/ir_${DASM_ARCH}.dasc
318244
DEPENDS
319-
php_opcache_jit_minilua
320-
${CMAKE_CURRENT_BINARY_DIR}/jit
321-
COMMENT "[ext/opcache] Generating native code generator ext/opcache/jit/ir/ir_emit_${DASM_ARCH}.h"
245+
jit/ir/ir_fold.h
246+
VERBATIM
247+
COMMAND_EXPAND_LISTS
322248
)
323249

324-
add_custom_target(
325-
php_opcache_jit
326-
DEPENDS
250+
target_sources(
251+
php_opcache
252+
PRIVATE
253+
jit/ir/ir_cfg.c
254+
jit/ir/ir_check.c
255+
jit/ir/ir_dump.c
256+
jit/ir/ir_emit.c
257+
jit/ir/ir_gcm.c
258+
$<$<NOT:$<PLATFORM_ID:Windows>>:jit/ir/ir_gdb.c>
259+
jit/ir/ir_patch.c
260+
$<$<NOT:$<PLATFORM_ID:Windows>>:jit/ir/ir_perf.c>
261+
jit/ir/ir_ra.c
262+
jit/ir/ir_save.c
263+
jit/ir/ir_sccp.c
264+
jit/ir/ir_strtab.c
265+
jit/ir/ir.c
266+
jit/zend_jit_vm_helpers.c
267+
jit/zend_jit.c
327268
${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${DASM_ARCH}.h
328269
${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_fold_hash.h
329-
COMMENT "[ext/opcache] Building JIT for architecture ${DASM_ARCH}"
330270
)
331271

332-
add_dependencies(php_opcache php_opcache_jit)
272+
target_include_directories(
273+
php_opcache
274+
PRIVATE
275+
${CMAKE_CURRENT_BINARY_DIR}/jit/ir
276+
)
277+
278+
target_compile_definitions(
279+
php_opcache
280+
PRIVATE
281+
IR_PHP
282+
${IR_TARGET}
283+
$<$<CONFIG:Debug,DebugAssertions>:IR_DEBUG>
284+
)
285+
286+
# Check for Capstone.
287+
if(EXT_OPCACHE_CAPSTONE)
288+
find_package(Capstone 3.0.0)
289+
set_package_properties(
290+
Capstone
291+
PROPERTIES
292+
TYPE REQUIRED
293+
PURPOSE "Necessary to enable OPcache JIT disassembly through Capstone."
294+
)
295+
296+
target_sources(php_opcache PRIVATE jit/ir/ir_disasm.c)
297+
298+
target_link_libraries(php_opcache PRIVATE Capstone::Capstone)
299+
300+
set(HAVE_CAPSTONE 1)
301+
endif()
302+
303+
set(HAVE_JIT 1)
333304
endif()
334305

306+
add_feature_info(
307+
"ext/opcache JIT"
308+
HAVE_JIT
309+
"OPcache JIT (Just-In-Time compiler)"
310+
)
311+
312+
add_feature_info(
313+
"ext/opcache JIT Capstone"
314+
HAVE_CAPSTONE
315+
"OPcache JIT disassembly supported through Capstone engine"
316+
)
317+
335318
################################################################################
336319
# Configuration checks.
337320
################################################################################

docs/cmake/cmake-code-style.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ For convenience there is a custom helper script added to this repository that
675675
checks CMake files:
676676

677677
```sh
678-
./bin/check-cmake.php cmake
678+
./bin/check-cmake.php
679679
```
680680

681681
#### 10.1.6. cmake-format.json

docs/cmake/cmake.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ repository:
6868
└─📄 config.cmake.h.in # SAPI's configuration header template
6969
└─📂 scripts
7070
└─📄 CMakeLists.txt # CMake file for creating scripts files
71-
└─📂 TSRM
72-
└─📄 CMakeLists.txt # CMake file for Thread Safe Resource Manager
7371
└─📂 win32 # Windows build files
7472
└─📂 build # Windows build files
7573
└─📄 wsyslog.mc # Message template file for win32/wsyslog.h

docs/cmake/ext/opcache.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<!-- This is auto-generated file. -->
22
* Source code: [ext/opcache/CMakeLists.txt](https://github.com/petk/php-build-system/blob/master/cmake/ext/opcache/CMakeLists.txt)
33

4-
# The opcache extension
5-
6-
Configure the `opcache` extension.
4+
# The Zend OPcache extension
75

86
This extension enables the PHP OPcode caching engine.
97

@@ -19,7 +17,7 @@ Enable the extension. This extension is always built as shared when enabled.
1917
* Default: `ON`
2018
* Values: `ON|OFF`
2119

22-
Enable copying PHP CODE pages into HUGE PAGES
20+
Enable copying PHP CODE pages into HUGE PAGES.
2321

2422
## EXT_OPCACHE_JIT
2523

@@ -33,4 +31,4 @@ Enable JIT (Just-In-Time compiler).
3331
* Default: `OFF`
3432
* Values: `ON|OFF`
3533

36-
Enable opcache JIT disassembly through Capstone.
34+
Enable OPcache JIT disassembly through Capstone engine.

docs/cmake/ext/pcntl.md

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

docs/cmake/ext/readline.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Configure the `readline` extension.
88
This extension provides interface for using Editline library.
99

1010
> [!IMPORTANT]
11-
> This extension should be used only with cgi, cli, embed, or phpdbg SAPI.
11+
> This extension should be used only with CLI-based PHP SAPIs.
1212
1313
## EXT_READLINE
1414

docs/cmake/modules/FindCcache.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Find the Ccache compiler cache tool for faster compilation times.
1616

1717
## Hints
1818

19-
* The `CCACHE_DISABLE` environment variable disables the ccache and doesn't add
20-
it to the C and CXX launcher, see Ccache documentation for more info.
19+
* The `CCACHE_DISABLE` regular or environment variable which disables ccache and
20+
doesn't adjust the C and CXX launcher. For more info see Ccache documentation.
2121

2222
## Basic usage
2323

0 commit comments

Comments
 (0)