Skip to content

Commit eaa51e4

Browse files
committed
Merge branch 'PHP-8.4'
2 parents c988cf9 + cefe3a6 commit eaa51e4

File tree

8 files changed

+127
-130
lines changed

8 files changed

+127
-130
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,6 @@ include(PHP/SearchLibraries)
6868
# Configuration.
6969
################################################################################
7070

71-
cmake_dependent_option(
72-
ZEND_FIBER_ASM
73-
"Enable the use of Boost fiber assembly files"
74-
ON
75-
[[NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"]]
76-
ON
77-
)
78-
mark_as_advanced(ZEND_FIBER_ASM)
79-
8071
cmake_dependent_option(
8172
ZEND_SIGNALS
8273
"Enable Zend signal handling"
@@ -467,7 +458,10 @@ include(cmake/CheckFloatPrecision.cmake)
467458
include(cmake/CheckMMAlignment.cmake)
468459
include(cmake/CheckStackDirection.cmake)
469460
include(cmake/CheckStrerrorR.cmake)
461+
include(cmake/Fibers.cmake)
462+
include(cmake/GenerateGrammar.cmake)
470463
include(cmake/GlobalRegisterVariables.cmake)
464+
include(cmake/MaxExecutionTimers.cmake)
471465

472466
################################################################################
473467
# Zend signals.
@@ -491,27 +485,6 @@ add_feature_info(
491485
"signal handling for performance"
492486
)
493487

494-
################################################################################
495-
# Zend max execution timers.
496-
################################################################################
497-
498-
include(cmake/MaxExecutionTimers.cmake)
499-
500-
################################################################################
501-
# Generate parser and lexer files.
502-
################################################################################
503-
504-
include(cmake/GenerateGrammar.cmake)
505-
506-
################################################################################
507-
# Configure fibers.
508-
################################################################################
509-
510-
include(cmake/Fibers.cmake)
511-
if(TARGET Zend::Fibers)
512-
target_link_libraries(zend PRIVATE Zend::Fibers)
513-
endif()
514-
515488
################################################################################
516489
# Create files and set installation.
517490
################################################################################
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
#[=============================================================================[
22
Check whether the stack grows downwards. Assumes contiguous stack.
33
4-
Result/cache variables:
4+
Result variables:
55
6-
* ZEND_CHECK_STACK_LIMIT - Whether checking the stack limit is supported.
6+
* ZEND_CHECK_STACK_LIMIT
77
#]=============================================================================]
88

9-
# Skip in consecutive configuration phases.
10-
if(DEFINED ZEND_CHECK_STACK_LIMIT)
11-
return()
12-
endif()
9+
include(CheckSourceRuns)
10+
include(CMakePushCheckState)
1311

1412
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
1513
set(ZEND_CHECK_STACK_LIMIT TRUE)
1614
return()
1715
endif()
1816

19-
include(CheckSourceRuns)
20-
include(CMakePushCheckState)
21-
22-
message(CHECK_START "Checking whether the stack grows downwards")
17+
# Skip in consecutive configuration phases.
18+
if(NOT DEFINED PHP_ZEND_CHECK_STACK_LIMIT)
19+
message(CHECK_START "Checking whether the stack grows downwards")
2320

24-
cmake_push_check_state(RESET)
25-
set(CMAKE_REQUIRED_QUIET TRUE)
21+
cmake_push_check_state(RESET)
22+
set(CMAKE_REQUIRED_QUIET TRUE)
2623

27-
check_source_runs(C [[
28-
#include <stdint.h>
24+
check_source_runs(C [[
25+
#include <stdint.h>
2926

30-
#ifdef __has_builtin
31-
# if __has_builtin(__builtin_frame_address)
32-
# define builtin_frame_address __builtin_frame_address(0)
33-
# endif
34-
#endif
27+
#ifdef __has_builtin
28+
# if __has_builtin(__builtin_frame_address)
29+
# define builtin_frame_address __builtin_frame_address(0)
30+
# endif
31+
#endif
3532

36-
int (*volatile f)(uintptr_t);
33+
int (*volatile f)(uintptr_t);
3734

38-
int stack_grows_downwards(uintptr_t arg)
39-
{
40-
#ifdef builtin_frame_address
41-
uintptr_t addr = (uintptr_t)builtin_frame_address;
42-
#else
43-
int local;
44-
uintptr_t addr = (uintptr_t)&local;
45-
#endif
35+
int stack_grows_downwards(uintptr_t arg)
36+
{
37+
#ifdef builtin_frame_address
38+
uintptr_t addr = (uintptr_t)builtin_frame_address;
39+
#else
40+
int local;
41+
uintptr_t addr = (uintptr_t)&local;
42+
#endif
4643

47-
return addr < arg;
48-
}
44+
return addr < arg;
45+
}
4946

50-
int main(void)
51-
{
52-
#ifdef builtin_frame_address
53-
uintptr_t addr = (uintptr_t)builtin_frame_address;
54-
#else
55-
int local;
56-
uintptr_t addr = (uintptr_t)&local;
57-
#endif
47+
int main(void)
48+
{
49+
#ifdef builtin_frame_address
50+
uintptr_t addr = (uintptr_t)builtin_frame_address;
51+
#else
52+
int local;
53+
uintptr_t addr = (uintptr_t)&local;
54+
#endif
5855

59-
f = stack_grows_downwards;
60-
return f(addr) ? 0 : 1;
61-
}
62-
]] ZEND_CHECK_STACK_LIMIT)
63-
cmake_pop_check_state()
56+
f = stack_grows_downwards;
57+
return f(addr) ? 0 : 1;
58+
}
59+
]] PHP_ZEND_CHECK_STACK_LIMIT)
60+
cmake_pop_check_state()
6461

65-
if(ZEND_CHECK_STACK_LIMIT)
66-
message(CHECK_PASS "yes")
67-
else()
68-
message(CHECK_FAIL "no")
62+
if(PHP_ZEND_CHECK_STACK_LIMIT)
63+
message(CHECK_PASS "yes")
64+
else()
65+
message(CHECK_FAIL "no")
66+
endif()
6967
endif()
68+
69+
set(ZEND_CHECK_STACK_LIMIT ${PHP_ZEND_CHECK_STACK_LIMIT})

cmake/Zend/cmake/Fibers.cmake

Lines changed: 69 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,85 @@ Determine whether Fibers can be used and add Boost fiber assembly files support
33
if available for the platform. As a Boost fallback alternative ucontext support
44
is checked if it can be used.
55
6-
Control variables:
6+
Configuration options:
77
8-
* ZEND_FIBER_ASM - Whether to use Boost fiber assembly files.
8+
* ZEND_FIBER_ASM
99
10-
Cache variables:
10+
Result variables:
1111
12-
* ZEND_FIBER_UCONTEXT - Whether <ucontext.h> header file is available and should
13-
be used.
14-
15-
Interface library:
16-
17-
* Zend::Fibers
18-
19-
Interface library using Boost fiber assembly files and compile options if
20-
available.
12+
* ZEND_FIBER_UCONTEXT
2113
#]=============================================================================]
2214

2315
include(CheckIncludeFiles)
2416
include(CheckSourceRuns)
17+
include(CMakeDependentOption)
2518
include(CMakePushCheckState)
2619

20+
cmake_dependent_option(
21+
ZEND_FIBER_ASM
22+
"Enable the use of Boost fiber assembly files"
23+
ON
24+
[[NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"]]
25+
ON
26+
)
27+
mark_as_advanced(ZEND_FIBER_ASM)
28+
29+
# Create interface library for using Boost fiber assembly files and compile
30+
# options if available.
2731
add_library(zend_fibers INTERFACE)
2832
add_library(Zend::Fibers ALIAS zend_fibers)
33+
target_link_libraries(zend PRIVATE Zend::Fibers)
34+
35+
################################################################################
36+
# Check shadow stack.
37+
################################################################################
2938

30-
if(NOT DEFINED SHADOW_STACK_SYSCALL)
31-
message(CHECK_START "Whether syscall to create shadow stack exists")
32-
cmake_push_check_state(RESET)
33-
set(CMAKE_REQUIRED_QUIET TRUE)
34-
35-
check_source_runs(C [[
36-
#include <unistd.h>
37-
#include <sys/mman.h>
38-
int main(void)
39-
{
40-
void* base = (void *)syscall(451, 0, 0x20000, 0x1);
41-
if (base != (void*)-1) {
42-
munmap(base, 0x20000);
43-
return 0;
39+
function(_php_zend_fibers_shadow_stack_syscall)
40+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
41+
set(PHP_ZEND_SHADOW_STACK_SYSCALL FALSE)
42+
endif()
43+
44+
if(NOT DEFINED PHP_ZEND_SHADOW_STACK_SYSCALL)
45+
message(CHECK_START "Whether syscall to create shadow stack exists")
46+
cmake_push_check_state(RESET)
47+
set(CMAKE_REQUIRED_QUIET TRUE)
48+
49+
check_source_runs(C [[
50+
#include <unistd.h>
51+
#include <sys/mman.h>
52+
int main(void)
53+
{
54+
void* base = (void *)syscall(451, 0, 0x20000, 0x1);
55+
if (base != (void*)-1) {
56+
munmap(base, 0x20000);
57+
return 0;
58+
}
59+
return 1;
4460
}
45-
return 1;
46-
}
47-
]] SHADOW_STACK_SYSCALL)
48-
cmake_pop_check_state()
49-
if(SHADOW_STACK_SYSCALL)
50-
message(CHECK_PASS "yes")
51-
else()
52-
# If the syscall doesn't exist, we may block the final ELF from
53-
# __PROPERTY_SHSTK via redefine macro as "-D__CET__=1".
54-
message(CHECK_FAIL "no")
61+
]] PHP_ZEND_SHADOW_STACK_SYSCALL)
62+
cmake_pop_check_state()
63+
64+
if(PHP_ZEND_SHADOW_STACK_SYSCALL)
65+
message(CHECK_PASS "yes")
66+
else()
67+
# If the syscall doesn't exist, we may block the final ELF from
68+
# __PROPERTY_SHSTK via redefine macro as "-D__CET__=1".
69+
message(CHECK_FAIL "no")
70+
endif()
5571
endif()
56-
endif()
72+
73+
# Use compile definitions because ASM files can't see macro definitions from
74+
# the PHP configuration header (php_config.h/config.w32.h).
75+
target_compile_definitions(
76+
zend_fibers
77+
INTERFACE
78+
$<IF:$<BOOL:${PHP_ZEND_SHADOW_STACK_SYSCALL}>,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
79+
)
80+
endfunction()
81+
82+
################################################################################
83+
# Configure fibers.
84+
################################################################################
5785

5886
block()
5987
set(cpu "")
@@ -162,13 +190,7 @@ block()
162190

163191
target_sources(zend_fibers INTERFACE ${asmSources})
164192

165-
# Use compile definitions because ASM files can't see macro definitions from
166-
# the PHP configuration header (php_config.h/config.w32.h).
167-
target_compile_definitions(
168-
zend_fibers
169-
INTERFACE
170-
$<IF:$<BOOL:${SHADOW_STACK_SYSCALL}>,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
171-
)
193+
_php_zend_fibers_shadow_stack_syscall()
172194
else()
173195
cmake_push_check_state(RESET)
174196
# To use ucontext.h on macOS, the _XOPEN_SOURCE needs to be defined to any
@@ -189,16 +211,17 @@ block()
189211
)
190212
endif()
191213

192-
check_include_files(ucontext.h ZEND_FIBER_UCONTEXT)
214+
check_include_files(ucontext.h PHP_ZEND_FIBER_UCONTEXT)
193215
cmake_pop_check_state()
194216

195-
if(NOT ZEND_FIBER_UCONTEXT)
217+
if(NOT PHP_ZEND_FIBER_UCONTEXT)
196218
message(CHECK_FAIL "no")
197219
message(
198220
FATAL_ERROR
199221
"Fibers are not available on this platform, <ucontext.h> not found."
200222
)
201223
endif()
202224
message(CHECK_PASS "yes, ucontext")
225+
set(ZEND_FIBER_UCONTEXT TRUE PARENT_SCOPE)
203226
endif()
204227
endblock()

cmake/cmake/presets/windows.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"PHP_EXT_CALENDAR": true,
1313
"PHP_EXT_DL_TEST": true,
1414
"PHP_EXT_DOM": false,
15+
"PHP_EXT_EXIF": true,
1516
"PHP_EXT_FTP": true,
1617
"PHP_EXT_FTP_SSL": false,
1718
"PHP_EXT_ICONV": false,

cmake/cmake/toolchains/template.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ set(PHP_WRITE_STDOUT_EXITCODE 0)
3636
# Zend Engine
3737
################################################################################
3838

39-
# Set the exit code for the check if syscall to create shadow stack exists.
40-
set(SHADOW_STACK_SYSCALL_EXITCODE 1)
41-
4239
# Set the exit code of the stack limit check.
43-
set(ZEND_CHECK_STACK_LIMIT_EXITCODE 1)
40+
set(PHP_ZEND_CHECK_STACK_LIMIT_EXITCODE 0)
41+
42+
# Set the exit code of the check if syscall to create shadow stack exists.
43+
set(PHP_ZEND_SHADOW_STACK_SYSCALL_EXITCODE 1)
4444

4545
# Set the exit code and the output of the ZEND_MM check.
4646
# See CheckMMAlignment.cmake.

docs/cmake/cmake-code-style.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ set(VAR <value> CACHE <type> "<help_text>")
249249
option(FOO "<help_text>" [value])
250250
251251
# Cache variables created by CMake command invocations. For example
252-
find_program(SED_EXECUTABLE sed)
252+
find_program(PHP_SED_EXECUTABLE sed)
253253
```
254254

255255
### 3.2. Naming variables

docs/cmake/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ Some useful overridable configuration options built into CMake itself. All these
205205
* [`PHP_IPV6`](/docs/cmake/variables/PHP_IPV6.md)
206206
* [`PHP_LIBGCC`](/docs/cmake/variables/PHP_LIBGCC.md)
207207
* [`PHP_RE2C_COMPUTED_GOTOS`](/docs/cmake/variables/PHP_RE2C_COMPUTED_GOTOS.md)
208+
* [`PHP_SED_EXECUTABLE`](/docs/cmake/variables/PHP_SED_EXECUTABLE.md)
208209
* [`PHP_SIGCHILD`](/docs/cmake/variables/PHP_SIGCHILD.md)
209210
* [`PHP_SYSTEM_GLOB`](/docs/cmake/variables/PHP_SYSTEM_GLOB.md)
210211
* [`PHP_THREAD_SAFETY`](/docs/cmake/variables/PHP_THREAD_SAFETY.md)
211212
* [`PHP_UNDEFINED_SANITIZER`](/docs/variables/_PHP_UNDEFINED_SANITIZER.md)
212213
* [`PHP_USE_RTLD_NOW`](/docs/cmake/variables/PHP_USE_RTLD_NOW.md)
213214
* [`PHP_VALGRIND`](/docs/cmake/variables/PHP_VALGRIND.md)
214215
* [`PHP_VERBOSE_LINK`](/docs/cmake/variables/PHP_VERBOSE_LINK.md)
215-
* [`SED_EXECUTABLE`](/docs/cmake/variables/SED_EXECUTABLE.md)
216216

217217
* [`PEAR`](/docs/cmake/pear.md)
218218

docs/cmake/variables/SED_EXECUTABLE.md renamed to docs/cmake/variables/PHP_SED_EXECUTABLE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `SED_EXECUTABLE`
1+
# `PHP_SED_EXECUTABLE`
22

33
Default path to the `sed` on the host system.
44

0 commit comments

Comments
 (0)