Skip to content

Commit 18d49d1

Browse files
committed
Improve cross-compiling for stack limit check
1 parent 5327f49 commit 18d49d1

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

cmake/cmake/modules/Zend/CheckStackLimit.cmake

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,29 @@ message(CHECK_START "Checking whether the stack grows downwards")
1717
cmake_push_check_state(RESET)
1818
set(CMAKE_REQUIRED_QUIET TRUE)
1919

20-
if(NOT CMAKE_CROSSCOMPILING)
21-
check_source_runs(C [[
22-
#include <stdint.h>
20+
check_source_runs(C [[
21+
#include <stdint.h>
2322

24-
int (*volatile f)(uintptr_t);
23+
int (*volatile f)(uintptr_t);
2524

26-
int stack_grows_downwards(uintptr_t arg) {
27-
int local;
28-
return (uintptr_t)&local < arg;
29-
}
25+
int stack_grows_downwards(uintptr_t arg)
26+
{
27+
int local;
28+
return (uintptr_t)&local < arg;
29+
}
3030

31-
int main(void) {
32-
int local;
31+
int main(void)
32+
{
33+
int local;
3334

34-
f = stack_grows_downwards;
35-
return f((uintptr_t)&local) ? 0 : 1;
36-
}
37-
]] ZEND_CHECK_STACK_LIMIT)
38-
endif()
35+
f = stack_grows_downwards;
36+
return f((uintptr_t)&local) ? 0 : 1;
37+
}
38+
]] ZEND_CHECK_STACK_LIMIT)
3939
cmake_pop_check_state()
4040

4141
if(ZEND_CHECK_STACK_LIMIT)
4242
message(CHECK_PASS "yes")
43-
elseif(CMAKE_CROSSCOMPILING)
44-
message(CHECK_FAIL "no (cross-compiling)")
4543
else()
4644
message(CHECK_FAIL "no")
4745
endif()

cmake/cmake/toolchains/template.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ set(PHP_WRITE_STDOUT_EXITCODE 0)
5454

5555
# TODO: Fix this better.
5656
set(ZEND_MM_OUTPUT "(size_t)8 (size_t)3 0")
57+
58+
# Set to exit code of the stack limit check.
59+
set(ZEND_CHECK_STACK_LIMIT_EXITCODE 1)

0 commit comments

Comments
 (0)