@@ -17,6 +17,9 @@ Enable the extension. This extension is always built as shared when enabled.
1717
1818Enable copying PHP CODE pages into HUGE PAGES.
1919
20+ > [!NOTE]
21+ > This option is not available when the target system is Windows.
22+
2023## PHP_EXT_OPCACHE_JIT
2124
2225* Default: `ON`
@@ -59,6 +62,11 @@ cmake_dependent_option(
5962 [[PHP_EXT_OPCACHE AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"]]
6063 OFF
6164)
65+ add_feature_info(
66+ "ext/opcache HUGE PAGES"
67+ PHP_EXT_OPCACHE_HUGE_CODE_PAGES
68+ "PHP CODE pages are copied into HUGE PAGES"
69+ )
6270
6371cmake_dependent_option(
6472 PHP_EXT_OPCACHE_JIT
@@ -130,7 +138,10 @@ endif()
130138
131139# Check if JIT is supported by the target architecture.
132140if (PHP_EXT_OPCACHE_JIT)
133- if (NOT CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "(i[3456]86|x86_64|aarch64|arm64|x64|X86|ARM64)" )
141+ if (
142+ NOT CMAKE_C_COMPILER_ARCHITECTURE_ID
143+ MATCHES "(i[3456]86|x86_64|aarch64|arm64|x64|X86|ARM64)"
144+ )
134145 message (
135146 WARNING
136147 "JIT is not supported by target architecture "
@@ -160,35 +171,35 @@ target_include_directories(
160171if (PHP_EXT_OPCACHE_JIT)
161172 # Find out which ABI to use.
162173 if (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "(x86_64|x64)" )
163- set (DASM_FLAGS -D X64=1)
164- set (DASM_ARCH "x86" )
174+ set (dasm_flags -D X64=1)
175+ set (dasm_arch "x86" )
165176 elseif (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "(i[34567]86|X86)" )
166- set (DASM_ARCH "x86" )
177+ set (dasm_arch "x86" )
167178 elseif (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "(arm64|ARM64|aarch64)" )
168- set (DASM_FLAGS -D ARM64=1)
169- set (DASM_ARCH "arm64" )
179+ set (dasm_flags -D ARM64=1)
180+ set (dasm_arch "arm64" )
170181 endif ()
171182
172183 if (
173184 CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "x86_64"
174185 AND CMAKE_SYSTEM_NAME STREQUAL "Darwin"
175186 )
176- list (APPEND DASM_FLAGS -D X64APPLE=1)
187+ list (APPEND dasm_flags -D X64APPLE=1)
177188 endif ()
178189
179190 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
180- list (APPEND DASM_FLAGS -D WIN=1)
191+ list (APPEND dasm_flags -D WIN=1)
181192 endif ()
182193
183194 if (
184195 CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "(x86_64|x64|ARM64|aarch64)"
185196 AND CMAKE_SYSTEM_NAME STREQUAL "Windows"
186197 )
187- list (APPEND DASM_FLAGS -D X64WIN=1)
198+ list (APPEND dasm_flags -D X64WIN=1)
188199 endif ()
189200
190201 if (PHP_THREAD_SAFETY)
191- list (APPEND DASM_FLAGS -D ZTS=1)
202+ list (APPEND dasm_flags -D ZTS=1)
192203 endif ()
193204
194205 # Generate zend_jit_<arch>.c file.
@@ -220,16 +231,16 @@ if(PHP_EXT_OPCACHE_JIT)
220231
221232 # Generate Jit for architecture.
222233 add_custom_command (
223- OUTPUT jit/zend_jit_${DASM_ARCH } .c
234+ OUTPUT jit/zend_jit_${dasm_arch } .c
224235 COMMAND
225236 php_ext_opcache_jit_minilua ${CMAKE_CURRENT_SOURCE_DIR} /jit/dynasm/dynasm.lua
226- ${DASM_FLAGS }
227- -o ${CMAKE_CURRENT_BINARY_DIR} /jit/zend_jit_${DASM_ARCH } .c
228- ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_${DASM_ARCH } .dasc
229- COMMENT "[ext/opcache] Generating ${relativeDir} /jit/zend_jit_${DASM_ARCH } .c"
237+ ${dasm_flags }
238+ -o ${CMAKE_CURRENT_BINARY_DIR} /jit/zend_jit_${dasm_arch } .c
239+ ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_${dasm_arch } .dasc
240+ COMMENT "[ext/opcache] Generating ${relativeDir} /jit/zend_jit_${dasm_arch } .c"
230241 DEPENDS
231242 jit/dynasm/dynasm.lua
232- jit/zend_jit_${DASM_ARCH } .dasc
243+ jit/zend_jit_${dasm_arch } .dasc
233244 VERBATIM
234245 COMMAND_EXPAND_LISTS
235246 )
@@ -240,15 +251,37 @@ if(PHP_EXT_OPCACHE_JIT)
240251 $<$<NOT :$<PLATFORM_ID:Windows>>:jit/zend_jit_gdb.c>
241252 jit/zend_jit_vm_helpers.c
242253 jit/zend_jit.c
243- ${CMAKE_CURRENT_BINARY_DIR} /jit/zend_jit_${DASM_ARCH } .c
254+ ${CMAKE_CURRENT_BINARY_DIR} /jit/zend_jit_${dasm_arch } .c
244255 )
245256
246257 # Mark generated file as "header" to not get compiled into its own object.
247258 set_source_files_properties (
248- ${CMAKE_CURRENT_BINARY_DIR} /jit/zend_jit_${DASM_ARCH } .c
259+ ${CMAKE_CURRENT_BINARY_DIR} /jit/zend_jit_${dasm_arch } .c
249260 PROPERTIES HEADER_FILE_ONLY ON
250261 )
251262
263+ foreach (
264+ file IN ITEMS
265+ ${CMAKE_CURRENT_BINARY_DIR} /jit/zend_jit_${dasm_arch} .c
266+ ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_disasm.c
267+ ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_gdb.c
268+ ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_helpers.c
269+ ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_perf_dump.c
270+ ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_trace.c
271+ ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_jit_vtune.c
272+ )
273+ set_property (SOURCE jit/zend_jit.c APPEND PROPERTY OBJECT_DEPENDS "${file} " )
274+ endforeach ()
275+
276+ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows" )
277+ set_property (
278+ SOURCE jit/zend_jit.c
279+ APPEND
280+ PROPERTY
281+ OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /jit/zend_elf.c
282+ )
283+ endif ()
284+
252285 # The string.h header is always available with C89 standard. The bundled
253286 # ext/opcache/jit/libudis86 still includes it conditionally.
254287 target_compile_definitions (php_ext_opcache PRIVATE HAVE_STRING_H=1)
0 commit comments