Skip to content

Commit 0e51d69

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 1a58946 + c8fe877 commit 0e51d69

File tree

7 files changed

+129
-106
lines changed

7 files changed

+129
-106
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,10 @@ endif()
464464

465465
if(PHPSystem_EXECUTABLE)
466466
set(PHP_EXECUTABLE ${PHPSystem_EXECUTABLE})
467-
elseif(NOT CMAKE_CROSSCOMPILING)
467+
elseif(
468+
NOT CMAKE_CROSSCOMPILING
469+
OR (CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR)
470+
)
468471
set(PHP_EXECUTABLE "$<TARGET_FILE:php_cli>")
469472
endif()
470473

cmake/cmake/Requirements.cmake

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,24 @@ endif()
4242
# Check whether the system uses EBCDIC (not ASCII) as its native character set.
4343
################################################################################
4444
message(CHECK_START "Checking system character set")
45-
if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
46-
cmake_push_check_state(RESET)
47-
set(CMAKE_REQUIRED_QUIET TRUE)
48-
check_source_runs(C [[
49-
int main(void) {
50-
return (unsigned char)'A' != (unsigned char)0xC1;
51-
}
52-
]] _php_is_ebcdic)
53-
cmake_pop_check_state()
54-
55-
if(_php_is_ebcdic)
56-
message(CHECK_FAIL "EBCDIC")
57-
message(FATAL_ERROR "PHP does not support EBCDIC targets")
58-
else()
59-
message(CHECK_PASS "ASCII")
60-
endif()
45+
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR)
46+
# EBCDIC targets are obsolete, assume that target uses ASCII when
47+
# cross-compiling without emulator.
48+
set(PHP_IS_EBCDIC_EXITCODE 1)
49+
endif()
50+
51+
cmake_push_check_state(RESET)
52+
set(CMAKE_REQUIRED_QUIET TRUE)
53+
check_source_runs(C [[
54+
int main(void) { return (unsigned char)'A' != (unsigned char)0xC1; }
55+
]] PHP_IS_EBCDIC)
56+
cmake_pop_check_state()
57+
58+
if(PHP_IS_EBCDIC)
59+
message(CHECK_FAIL "EBCDIC")
60+
message(FATAL_ERROR "PHP does not support EBCDIC targets")
6161
else()
62-
message(CHECK_FAIL "unknown, assuming ASCII (cross-compiling)")
62+
message(CHECK_PASS "ASCII")
6363
endif()
6464

6565
################################################################################

cmake/cmake/modules/PHP/CheckByteOrder.cmake

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,37 @@ if(CMAKE_C_BYTE_ORDER STREQUAL "BIG_ENDIAN")
1818
elseif(CMAKE_C_BYTE_ORDER STREQUAL "LITTLE_ENDIAN")
1919
message(CHECK_PASS "little-endian")
2020
else()
21-
if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
22-
check_source_runs(C [[
23-
int main(void)
24-
{
25-
short one = 1;
26-
char *cp = (char *)&one;
27-
28-
if (*cp == 0) {
29-
return 0;
30-
}
31-
32-
return 1;
33-
}
34-
]] WORDS_BIGENDIAN)
21+
if(
22+
NOT DEFINED WORDS_BIGENDIAN_EXITCODE
23+
AND CMAKE_CROSSCOMPILING
24+
AND NOT CMAKE_CROSSCOMPILING_EMULATOR
25+
)
26+
message(
27+
NOTICE
28+
"Byte ordering could not be detected, assuming the target system is "
29+
"little-endian. Set 'WORDS_BIGENDIAN_EXITCODE' to '0' if targeting a "
30+
"big-endian system."
31+
)
32+
set(WORDS_BIGENDIAN_EXITCODE 1)
3533
endif()
3634

35+
check_source_runs(C [[
36+
int main(void)
37+
{
38+
short one = 1;
39+
char *cp = (char *)&one;
40+
41+
if (*cp == 0) {
42+
return 0;
43+
}
44+
45+
return 1;
46+
}
47+
]] WORDS_BIGENDIAN)
48+
3749
if(WORDS_BIGENDIAN)
3850
message(CHECK_PASS "big-endian")
39-
elseif(DEFINED WORDS_BIGENDIAN)
40-
message(CHECK_PASS "little-endian")
4151
else()
42-
message(CHECK_FAIL "unknown (cross-compiling)")
43-
message(
44-
WARNING
45-
"Byte ordering could not be detected, assuming system is little-endian. "
46-
"Set 'WORDS_BIGENDIAN' to 'ON' if targeting a big-endian system."
47-
)
52+
message(CHECK_PASS "little-endian")
4853
endif()
4954
endif()

cmake/cmake/modules/Zend/CheckMMAlignment.cmake

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,70 +13,73 @@ include_guard(GLOBAL)
1313

1414
message(CHECK_START "Checking for Zend memory manager alignment and log values")
1515

16+
if(
17+
(NOT DEFINED ZEND_MM_EXITCODE OR NOT DEFINED ZEND_MM_EXITCODE__TRYRUN_OUTPUT)
18+
AND CMAKE_CROSSCOMPILING
19+
AND NOT CMAKE_CROSSCOMPILING_EMULATOR
20+
)
21+
# Set some sensible defaults when cross-compiling.
22+
set(ZEND_MM_EXITCODE 0)
23+
set(ZEND_MM_EXITCODE__TRYRUN_OUTPUT "(size_t)8 (size_t)3 0")
24+
endif()
25+
1626
block()
17-
if(NOT CMAKE_CROSSCOMPILING)
18-
try_run(
19-
ZEND_MM_RUN_RESULT
20-
ZEND_MM_COMPILE_RESULT
21-
SOURCE_FROM_CONTENT src.c [[
22-
#include <stdio.h>
23-
#include <stdlib.h>
24-
25-
typedef union _mm_align_test {
26-
void *ptr;
27-
double dbl;
28-
long lng;
29-
} mm_align_test;
30-
31-
#if (defined (__GNUC__) && __GNUC__ >= 2)
32-
# define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test))
33-
#else
34-
# define ZEND_MM_ALIGNMENT (sizeof(mm_align_test))
35-
#endif
36-
37-
int main(void) {
38-
size_t i = ZEND_MM_ALIGNMENT;
39-
int zeros = 0;
40-
41-
while (i & ~0x1) {
42-
zeros++;
43-
i = i >> 1;
44-
}
45-
46-
printf(
47-
"(size_t)%zu (size_t)%d %d\n",
48-
ZEND_MM_ALIGNMENT,
49-
zeros,
50-
ZEND_MM_ALIGNMENT < 4
51-
);
52-
53-
return 0;
27+
try_run(
28+
ZEND_MM_EXITCODE
29+
ZEND_MM_COMPILED
30+
SOURCE_FROM_CONTENT src.c [[
31+
#include <stdio.h>
32+
#include <stdlib.h>
33+
34+
typedef union _mm_align_test {
35+
void *ptr;
36+
double dbl;
37+
long lng;
38+
} mm_align_test;
39+
40+
#if (defined (__GNUC__) && __GNUC__ >= 2)
41+
# define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test))
42+
#else
43+
# define ZEND_MM_ALIGNMENT (sizeof(mm_align_test))
44+
#endif
45+
46+
int main(void)
47+
{
48+
size_t i = ZEND_MM_ALIGNMENT;
49+
int zeros = 0;
50+
51+
while (i & ~0x1) {
52+
zeros++;
53+
i = i >> 1;
5454
}
55-
]]
56-
RUN_OUTPUT_STDOUT_VARIABLE ZEND_MM_OUTPUT
57-
)
58-
59-
if(ZEND_MM_RUN_RESULT EQUAL 0 AND ZEND_MM_COMPILE_RESULT)
60-
message(CHECK_PASS "Success")
61-
62-
string(STRIP "${ZEND_MM_OUTPUT}" ZEND_MM_OUTPUT)
63-
string(REPLACE " " ";" ZEND_MM_OUTPUT "${ZEND_MM_OUTPUT}")
64-
65-
list(GET ZEND_MM_OUTPUT 0 zend_mm_alignment)
66-
list(GET ZEND_MM_OUTPUT 1 zend_mm_alignment_log2)
67-
list(GET ZEND_MM_OUTPUT 2 zend_mm_need_eight_byte_realignment)
68-
else()
69-
message(CHECK_FAIL "Failed")
70-
message(
71-
FATAL_ERROR
72-
"ZEND_MM alignment defines failed. Please, check CMake logs.")
73-
endif()
74-
else()
75-
message(CHECK_FAIL "Using defaults (cross-compiling)")
7655

77-
set(zend_mm_alignment "(size_t)8")
78-
set(zend_mm_alignment_log2 "(size_t)3")
79-
set(zend_mm_need_eight_byte_realignment 0)
56+
printf(
57+
"(size_t)%zu (size_t)%d %d\n",
58+
ZEND_MM_ALIGNMENT,
59+
zeros,
60+
ZEND_MM_ALIGNMENT < 4
61+
);
62+
63+
return 0;
64+
}
65+
]]
66+
RUN_OUTPUT_VARIABLE ZEND_MM_OUTPUT
67+
)
68+
69+
if(ZEND_MM_COMPILED AND ZEND_MM_EXITCODE EQUAL 0 AND ZEND_MM_OUTPUT)
70+
message(CHECK_PASS "Success")
71+
72+
string(STRIP "${ZEND_MM_OUTPUT}" ZEND_MM_OUTPUT)
73+
string(REPLACE " " ";" ZEND_MM_OUTPUT "${ZEND_MM_OUTPUT}")
74+
75+
list(GET ZEND_MM_OUTPUT 0 zend_mm_alignment)
76+
list(GET ZEND_MM_OUTPUT 1 zend_mm_alignment_log2)
77+
list(GET ZEND_MM_OUTPUT 2 zend_mm_need_eight_byte_realignment)
78+
else()
79+
message(CHECK_FAIL "Failed")
80+
message(
81+
FATAL_ERROR
82+
"ZEND_MM alignment defines failed. Please, check CMake logs.")
8083
endif()
8184

8285
set(

cmake/cmake/toolchains/template.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,14 @@ set(HAVE_SHM_MMAP_POSIX_EXITCODE 0)
109109
# needs to be added for the PHP_UNDEFINED_SANITIZER option, otherwise set to 0.
110110
set(PHP_HAVE_UBSAN_EXITCODE 0)
111111

112-
# TODO: Fix this better.
113-
set(ZEND_MM_OUTPUT "(size_t)8 (size_t)3 0")
112+
# Set the exit code of the byte ordering fallback check. When targeting a
113+
# big-endian system, set it to 0, and for little-endian set it to 1.
114+
set(WORDS_BIGENDIAN_EXITCODE 1)
115+
116+
# Set the exit code and the output of the ZEND_MM check.
117+
# See CheckMMAlignment.cmake.
118+
set(ZEND_MM_EXITCODE 0)
119+
set(ZEND_MM_EXITCODE__TRYRUN_OUTPUT "(size_t)8 (size_t)3 0")
114120

115121
# Set the exit code of the sched_getcpu check.
116122
set(HAVE_SCHED_GETCPU_EXITCODE 0)

cmake/ext/phar/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ endif()
7373
# Generate files.
7474
################################################################################
7575

76-
# When cross-compiling php cli target executable cannot be executed.
77-
if(NOT CMAKE_CROSSCOMPILING)
76+
# When cross-compiling without emulator PHP CLI target executable cannot be run.
77+
if(
78+
NOT CMAKE_CROSSCOMPILING
79+
OR (CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR)
80+
)
7881
block()
7982
# Create CMake script that generates phar.phar file.
8083
file(

cmake/ext/tokenizer/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ add_dependencies(php_tokenizer Zend::Zend)
3939

4040
if(PHPSystem_EXECUTABLE)
4141
set(PHP_EXECUTABLE ${PHPSystem_EXECUTABLE})
42-
elseif(NOT CMAKE_CROSSCOMPILING)
42+
elseif(
43+
NOT CMAKE_CROSSCOMPILING
44+
OR (CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR)
45+
)
4346
set(PHP_EXECUTABLE "$<TARGET_FILE:php_cli>")
4447
endif()
4548

0 commit comments

Comments
 (0)