Skip to content

Commit b34020a

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 3cd3ced + 04e948a commit b34020a

File tree

1 file changed

+69
-76
lines changed

1 file changed

+69
-76
lines changed

cmake/Zend/cmake/Fibers.cmake

Lines changed: 69 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ else()
6161
message(CHECK_FAIL "no")
6262
endif()
6363

64-
block(PROPAGATE zend_fibers_asm_file zend_fibers_asm_sources)
64+
block()
65+
set(cpu "")
66+
set(asmFile "")
67+
set(prefix "")
68+
set(compileOptions "")
69+
set(compileDefinitions "")
70+
6571
# Determine files based on the architecture and platform.
6672
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$")
6773
set(prefix "x86_64_sysv")
@@ -91,125 +97,112 @@ block(PROPAGATE zend_fibers_asm_file zend_fibers_asm_sources)
9197
endif()
9298

9399
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
94-
set(zend_fibers_asm_file "combined_sysv_macho_gas.S")
100+
set(asmFile "combined_sysv_macho_gas.S")
95101
elseif(CMAKE_SYSTEM_NAME STREQUAL "AIX")
96102
# AIX uses a different calling convention (shared with non-_CALL_ELF Linux).
97103
# The AIX assembler isn't GNU, but the file is compatible.
98-
set(zend_fibers_asm_file "${prefix}_xcoff_gas.S")
104+
set(asmFile "${prefix}_xcoff_gas.S")
99105
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
100106
if(NOT cpu STREQUAL "i386")
101-
set(zend_fibers_asm_file "${prefix}_elf_gas.S")
107+
set(asmFile "${prefix}_elf_gas.S")
102108
endif()
103109
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
104110
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$")
105-
set(zend_fibers_asm_file "x86_64_ms_pe_masm.asm")
111+
set(asmFile "x86_64_ms_pe_masm.asm")
106112
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86|i.?86.*|pentium)$")
107-
set(zend_fibers_asm_file "i386_ms_pe_masm.asm")
113+
set(asmFile "i386_ms_pe_masm.asm")
108114
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$")
109-
set(zend_fibers_asm_file "arm64_aapcs_pe_armasm.asm")
115+
set(asmFile "arm64_aapcs_pe_armasm.asm")
110116

111117
set(
112-
compile_options
118+
compileOptions
113119
/nologo
114120
# TODO: Recheck; "-machine" is a linker option.
115121
-machine ARM64
116122
)
117123
endif()
118124

119-
if(
120-
zend_fibers_asm_file
121-
AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$"
122-
)
123-
set(
124-
compile_options
125-
/nologo
126-
)
125+
if(asmFile AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$")
126+
set(compileOptions /nologo)
127127

128-
set(
129-
compile_definitions
130-
"BOOST_CONTEXT_EXPORT=EXPORT"
131-
)
128+
set(compileDefinitions "BOOST_CONTEXT_EXPORT=EXPORT")
132129
endif()
133130
elseif(CMAKE_SYSTEM_NAME STREQUAL "Midipix")
134131
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$")
135132
set(zend_fibers_asm_file "x86_64_ms_pe_gas.S")
136133
endif()
137134
elseif(prefix)
138-
set(zend_fibers_asm_file "${prefix}_elf_gas.S")
135+
set(asmFile "${prefix}_elf_gas.S")
139136
endif()
140137

141-
if(zend_fibers_asm_file)
138+
if(asmFile)
142139
set(
143-
zend_fibers_asm_sources
144-
${CMAKE_CURRENT_SOURCE_DIR}/asm/jump_${zend_fibers_asm_file}
145-
${CMAKE_CURRENT_SOURCE_DIR}/asm/make_${zend_fibers_asm_file}
140+
asmSources
141+
${CMAKE_CURRENT_SOURCE_DIR}/asm/jump_${asmFile}
142+
${CMAKE_CURRENT_SOURCE_DIR}/asm/make_${asmFile}
146143
)
147144

148-
if(compile_options)
145+
if(compileOptions)
149146
set_source_files_properties(
150-
${zend_fibers_asm_sources}
147+
${asmSources}
151148
PROPERTIES
152-
COMPILE_OPTIONS ${compile_options}
149+
COMPILE_OPTIONS ${compileOptions}
153150
)
154151
endif()
155152

156-
if(compile_definitions)
153+
if(compileDefinitions)
157154
set_source_files_properties(
158-
${zend_fibers_asm_sources}
155+
${asmSources}
159156
PROPERTIES
160-
COMPILE_DEFINITIONS ${compile_definitions}
157+
COMPILE_DEFINITIONS ${compileDefinitions}
161158
)
162159
endif()
163160
endif()
164-
endblock()
165161

166-
message(CHECK_START "Checking for fibers switching context support")
162+
message(CHECK_START "Checking for fibers switching context support")
167163

168-
if(ZEND_FIBER_ASM AND zend_fibers_asm_file)
169-
message(CHECK_PASS "yes, Zend/asm/*.${zend_fibers_asm_file}")
164+
if(ZEND_FIBER_ASM AND asmFile)
165+
message(CHECK_PASS "yes, Zend/asm/*.${asmFile}")
170166

171-
target_sources(
172-
zend_fibers
173-
INTERFACE
174-
${zend_fibers_asm_sources}
175-
)
167+
target_sources(zend_fibers INTERFACE ${asmSources})
176168

177-
# Use compile definitions because ASM files can't see macro definitions from
178-
# the PHP configuration header (php_config.h/config.w32.h).
179-
target_compile_definitions(
180-
zend_fibers
181-
INTERFACE
182-
$<IF:$<BOOL:${SHADOW_STACK_SYSCALL}>,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
183-
)
184-
else()
185-
cmake_push_check_state(RESET)
186-
# To use ucontext.h on macOS, the _XOPEN_SOURCE needs to be defined to any
187-
# value. POSIX marked ucontext functions as obsolete and on macOS the
188-
# ucontext.h functions are deprecated. At the time of writing no solution is
189-
# on the horizon yet. Here, the _XOPEN_SOURCE is defined to empty value to
190-
# enable proper X/Open symbols yet still to not enable some of the Single
191-
# Unix specification definitions (values 500 or greater where the PHP
192-
# thread-safe build would fail).
193-
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
194-
set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE)
195-
196-
set_property(
197-
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/zend_fibers.c
198-
APPEND
199-
PROPERTY
200-
COMPILE_DEFINITIONS _XOPEN_SOURCE
169+
# Use compile definitions because ASM files can't see macro definitions from
170+
# the PHP configuration header (php_config.h/config.w32.h).
171+
target_compile_definitions(
172+
zend_fibers
173+
INTERFACE
174+
$<IF:$<BOOL:${SHADOW_STACK_SYSCALL}>,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
175+
)
176+
else()
177+
cmake_push_check_state(RESET)
178+
# To use ucontext.h on macOS, the _XOPEN_SOURCE needs to be defined to any
179+
# value. POSIX marked ucontext functions as obsolete and on macOS the
180+
# ucontext.h functions are deprecated. At the time of writing no solution is
181+
# on the horizon yet. Here, the _XOPEN_SOURCE is defined to empty value to
182+
# enable proper X/Open symbols yet still to not enable some of the Single
183+
# Unix specification definitions (values 500 or greater where the PHP
184+
# thread-safe build would fail).
185+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
186+
set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE)
187+
188+
set_property(
189+
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/zend_fibers.c
190+
APPEND
191+
PROPERTY
192+
COMPILE_DEFINITIONS _XOPEN_SOURCE
193+
)
194+
endif()
195+
196+
check_include_file(ucontext.h ZEND_FIBER_UCONTEXT)
197+
cmake_pop_check_state()
198+
199+
if(NOT ZEND_FIBER_UCONTEXT)
200+
message(CHECK_FAIL "no")
201+
message(
202+
FATAL_ERROR
203+
"Fibers are not available on this platform, ucontext.h not found"
201204
)
202205
endif()
203-
204-
check_include_file(ucontext.h ZEND_FIBER_UCONTEXT)
205-
cmake_pop_check_state()
206-
207-
if(NOT ZEND_FIBER_UCONTEXT)
208-
message(CHECK_FAIL "no")
209-
message(
210-
FATAL_ERROR
211-
"Fibers are not available on this platform, ucontext.h not found"
212-
)
206+
message(CHECK_PASS "yes, ucontext")
213207
endif()
214-
message(CHECK_PASS "yes, ucontext")
215-
endif()
208+
endblock()

0 commit comments

Comments
 (0)