Skip to content

Commit 8973cca

Browse files
committed
Sync with upstream: ext/opcache
1 parent 1e16f52 commit 8973cca

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

cmake/ext/opcache/CMakeLists.txt

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,35 +161,45 @@ target_include_directories(
161161
)
162162

163163
if(PHP_EXT_OPCACHE_JIT)
164+
set(dasm_arch "")
165+
set(dasm_flags "")
166+
set(ir_target "")
167+
set(tls_target "")
168+
164169
# Find out which ABI to use.
165170
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64|ARM64)$")
166-
set(IR_TARGET "IR_TARGET_X64")
167-
set(DASM_FLAGS -D X64=1)
168-
set(DASM_ARCH "x86")
171+
set(dasm_arch "x86")
172+
set(dasm_flags -D X64=1)
173+
set(ir_target "IR_TARGET_X64")
174+
set(tls_target "x86_64")
169175
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[34567]86.*|x86.*|X86)$")
170-
set(IR_TARGET "IR_TARGET_X86")
171-
set(DASM_ARCH "x86")
176+
set(dasm_arch "x86")
177+
set(ir_target "IR_TARGET_X86")
178+
set(tls_target "x86")
172179
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64.*")
173-
set(IR_TARGET "IR_TARGET_AARCH64")
174-
set(DASM_ARCH "aarch64")
180+
set(dasm_arch "aarch64")
181+
set(ir_target "IR_TARGET_AARCH64")
182+
set(tls_target "aarch64")
175183
endif()
176184

177185
if(
178186
CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
179187
AND CMAKE_SYSTEM_NAME STREQUAL "Darwin"
180188
)
181-
list(APPEND DASM_FLAGS -D X64APPLE=1)
189+
list(APPEND dasm_flags -D X64APPLE=1)
190+
set(tls_target "darwin")
182191
endif()
183192

184193
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
185-
list(APPEND DASM_FLAGS -D WIN=1)
194+
list(APPEND dasm_flags -D WIN=1)
195+
set(tls_target "win")
186196
endif()
187197

188198
if(
189199
CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|ARM64)$"
190200
AND CMAKE_SYSTEM_NAME STREQUAL "Windows"
191201
)
192-
list(APPEND DASM_FLAGS -D X64WIN=1)
202+
list(APPEND dasm_flags -D X64WIN=1)
193203
endif()
194204

195205
# Generate ir_emit_<arch>.h file.
@@ -221,16 +231,16 @@ if(PHP_EXT_OPCACHE_JIT)
221231

222232
# Generate native code generator for selected architecture.
223233
add_custom_command(
224-
OUTPUT jit/ir/ir_emit_${DASM_ARCH}.h
234+
OUTPUT jit/ir/ir_emit_${dasm_arch}.h
225235
COMMAND
226236
php_ext_opcache_jit_minilua ${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/dynasm/dynasm.lua
227-
${DASM_FLAGS}
228-
-o ${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${DASM_ARCH}.h
229-
${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/ir_${DASM_ARCH}.dasc
230-
COMMENT "[ext/opcache] Generating native code generator ${relativeDir}/jit/ir/ir_emit_${DASM_ARCH}.h"
237+
${dasm_flags}
238+
-o ${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${dasm_arch}.h
239+
${CMAKE_CURRENT_SOURCE_DIR}/jit/ir/ir_${dasm_arch}.dasc
240+
COMMENT "[ext/opcache] Generating native code generator ${relativeDir}/jit/ir/ir_emit_${dasm_arch}.h"
231241
DEPENDS
232242
jit/ir/dynasm/dynasm.lua
233-
jit/ir/ir_${DASM_ARCH}.dasc
243+
jit/ir/ir_${dasm_arch}.dasc
234244
VERBATIM
235245
COMMAND_EXPAND_LISTS
236246
)
@@ -240,7 +250,7 @@ if(PHP_EXT_OPCACHE_JIT)
240250
target_compile_definitions(
241251
php_ext_opcache_jit_generator
242252
PRIVATE
243-
${IR_TARGET}
253+
${ir_target}
244254
IR_PHP
245255
IR_PHP_MM=0
246256
)
@@ -281,10 +291,14 @@ if(PHP_EXT_OPCACHE_JIT)
281291
jit/ir/ir.c
282292
jit/zend_jit_vm_helpers.c
283293
jit/zend_jit.c
284-
${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${DASM_ARCH}.h
294+
${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_emit_${dasm_arch}.h
285295
${CMAKE_CURRENT_BINARY_DIR}/jit/ir/ir_fold_hash.h
286296
)
287297

298+
if(tls_target AND PHP_THREAD_SAFETY)
299+
target_sources(php_ext_opcache PRIVATE jit/tls/zend_jit_tls_${tls_target}.c)
300+
endif()
301+
288302
target_include_directories(
289303
php_ext_opcache
290304
PRIVATE
@@ -295,7 +309,7 @@ if(PHP_EXT_OPCACHE_JIT)
295309
php_ext_opcache
296310
PRIVATE
297311
IR_PHP
298-
${IR_TARGET}
312+
${ir_target}
299313
$<$<CONFIG:Debug,DebugAssertions>:IR_DEBUG>
300314
)
301315

0 commit comments

Comments
 (0)