Skip to content

Commit c9a5a73

Browse files
authored
Improve consecutive configuration phases (#31)
1 parent 2dd65e1 commit c9a5a73

32 files changed

+274
-97
lines changed

cmake/Zend/cmake/CheckDlsym.cmake

+15-4
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ Some non-ELF platforms, such as OpenBSD, FreeBSD, NetBSD, Mac OSX (~10.3),
77
needed underscore character (`_`) prefix for symbols, when using `dlsym()`. This
88
module is obsolete on current platforms.
99
10-
## Result variables
10+
## Cache variables
1111
1212
* `DLSYM_NEEDS_UNDERSCORE`
13-
14-
Whether `dlsym()` requires a leading underscore in symbol names.
1513
#]=============================================================================]
1614

1715
include_guard(GLOBAL)
1816

17+
# Skip in consecutive configuration phases.
18+
if(DEFINED DLSYM_NEEDS_UNDERSCORE)
19+
return()
20+
endif()
21+
1922
include(CheckIncludeFile)
2023

2124
message(
@@ -112,9 +115,17 @@ block()
112115
)
113116
endblock()
114117

118+
set(
119+
DLSYM_NEEDS_UNDERSCORE
120+
""
121+
CACHE INTERNAL
122+
"Whether 'dlsym()' requires a leading underscore in symbol names."
123+
)
124+
115125
if(DLSYM_NEEDS_UNDERSCORE_COMPILED AND DLSYM_NEEDS_UNDERSCORE_EXITCODE EQUAL 2)
116-
set(DLSYM_NEEDS_UNDERSCORE TRUE)
126+
set_property(CACHE DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE TRUE)
117127
message(CHECK_PASS "yes")
118128
else()
129+
set_property(CACHE DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE FALSE)
119130
message(CHECK_FAIL "no")
120131
endif()

cmake/Zend/cmake/CheckGlobalRegisterVariables.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ See also: [GCC global register variables](https://gcc.gnu.org/onlinedocs/gcc/Glo
1616

1717
include_guard(GLOBAL)
1818

19+
# Skip in consecutive configuration phases.
20+
if(DEFINED HAVE_GCC_GLOBAL_REGS)
21+
return()
22+
endif()
23+
1924
include(CheckSourceCompiles)
2025
include(CMakePushCheckState)
2126

cmake/Zend/cmake/CheckStackDirection.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Check whether the stack grows downwards. Assumes contiguous stack.
1212

1313
include_guard(GLOBAL)
1414

15+
# Skip in consecutive configuration phases.
16+
if(DEFINED ZEND_CHECK_STACK_LIMIT)
17+
return()
18+
endif()
19+
1520
include(CheckSourceRuns)
1621
include(CMakePushCheckState)
1722

cmake/Zend/cmake/Fibers.cmake

+25-23
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,32 @@ include(CMakePushCheckState)
3535
add_library(zend_fibers INTERFACE)
3636
add_library(Zend::Fibers ALIAS zend_fibers)
3737

38-
message(CHECK_START "Whether syscall to create shadow stack exists")
39-
cmake_push_check_state(RESET)
40-
set(CMAKE_REQUIRED_QUIET TRUE)
41-
42-
check_source_runs(C [[
43-
#include <unistd.h>
44-
#include <sys/mman.h>
45-
int main(void)
46-
{
47-
void* base = (void *)syscall(451, 0, 0x20000, 0x1);
48-
if (base != (void*)-1) {
49-
munmap(base, 0x20000);
50-
return 0;
38+
if(NOT DEFINED SHADOW_STACK_SYSCALL)
39+
message(CHECK_START "Whether syscall to create shadow stack exists")
40+
cmake_push_check_state(RESET)
41+
set(CMAKE_REQUIRED_QUIET TRUE)
42+
43+
check_source_runs(C [[
44+
#include <unistd.h>
45+
#include <sys/mman.h>
46+
int main(void)
47+
{
48+
void* base = (void *)syscall(451, 0, 0x20000, 0x1);
49+
if (base != (void*)-1) {
50+
munmap(base, 0x20000);
51+
return 0;
52+
}
53+
return 1;
5154
}
52-
return 1;
53-
}
54-
]] SHADOW_STACK_SYSCALL)
55-
cmake_pop_check_state()
56-
if(SHADOW_STACK_SYSCALL)
57-
message(CHECK_PASS "yes")
58-
else()
59-
# If the syscall doesn't exist, we may block the final ELF from
60-
# __PROPERTY_SHSTK via redefine macro as "-D__CET__=1".
61-
message(CHECK_FAIL "no")
55+
]] SHADOW_STACK_SYSCALL)
56+
cmake_pop_check_state()
57+
if(SHADOW_STACK_SYSCALL)
58+
message(CHECK_PASS "yes")
59+
else()
60+
# If the syscall doesn't exist, we may block the final ELF from
61+
# __PROPERTY_SHSTK via redefine macro as "-D__CET__=1".
62+
message(CHECK_FAIL "no")
63+
endif()
6264
endif()
6365

6466
block()

cmake/Zend/cmake/MaxExecutionTimers.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Check whether to enable Zend max execution timers.
1616
* `ZEND_MAX_EXECUTION_TIMERS`
1717
1818
A local variable based on the cache variable and thread safety to be able to
19-
run consecutive configuration runs. When `ZEND_MAX_EXECUTION_TIMERS` cache
19+
run consecutive configuration phases. When `ZEND_MAX_EXECUTION_TIMERS` cache
2020
variable is set to 'auto', local variable default value is set to the
2121
`PHP_THREAD_SAFETY` value.
2222

cmake/cmake/ConfigureChecks.cmake

+9-7
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ cmake_pop_check_state()
138138
check_type_size("gid_t" SIZEOF_GID_T)
139139
if(NOT HAVE_SIZEOF_GID_T)
140140
set(
141-
gid_t int
142-
CACHE INTERNAL "Define as 'int' if <sys/types.h> doesn't define."
141+
gid_t
142+
int
143+
CACHE INTERNAL
144+
"Define as 'int' if not defined in <sys/types.h>."
143145
)
144146
endif()
145147

@@ -204,8 +206,10 @@ endif()
204206
check_type_size("uid_t" SIZEOF_UID_T)
205207
if(NOT HAVE_SIZEOF_UID_T)
206208
set(
207-
uid_t int
208-
CACHE INTERNAL "Define as 'int' if <sys/types.h> doesn't define."
209+
uid_t
210+
int
211+
CACHE INTERNAL
212+
"Define as 'int' if not defined in <sys/types.h>."
209213
)
210214
endif()
211215

@@ -438,9 +442,7 @@ endif()
438442
include(PHP/CheckByteOrder)
439443

440444
# Check for IPv6 support.
441-
if(PHP_IPV6)
442-
include(PHP/CheckIPv6)
443-
endif()
445+
include(PHP/CheckIPv6)
444446

445447
# Check how flush should be called.
446448
include(PHP/CheckFlushIo)

cmake/cmake/modules/FindACL.cmake

+4-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ if(NOT DEFINED ACL_IS_BUILT_IN)
125125

126126
if(_acl_works)
127127
set(
128-
ACL_IS_BUILT_IN TRUE
129-
CACHE INTERNAL "Whether ACL is a part of the C library"
128+
ACL_IS_BUILT_IN
129+
TRUE
130+
CACHE INTERNAL
131+
"Whether ACL is a part of the C library."
130132
)
131133
else()
132134
set(ACL_IS_BUILT_IN FALSE)

cmake/cmake/modules/PHP/Bison.cmake

+12-5
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,14 @@ function(php_bison name input output)
288288

289289
_php_bison_config()
290290

291+
# Skip consecutive find_package() calls when:
292+
# - project calls php_bison() multiple times and Bison will be downloaded
293+
# - the outer find_package() was called prior to php_bison()
294+
# - running consecutive configuration phases and Bison will be downloaded
291295
if(
292-
# Skip consecutive find_package() calls when:
293-
# - project calls php_bison() multiple times and Bison will be downloaded:
294296
NOT TARGET Bison::Bison
295-
# - the outer find_package() was called prior to php_bison():
296297
AND NOT DEFINED BISON_FOUND
297-
# - running consecutive configuration phases:
298-
AND NOT BISON_EXECUTABLE
298+
AND NOT _PHP_BISON_DOWNLOAD
299299
)
300300
find_package(BISON ${PHP_BISON_VERSION} ${quiet})
301301
endif()
@@ -650,5 +650,12 @@ function(_php_bison_download)
650650
get_property(packagesFound GLOBAL PROPERTY PACKAGES_FOUND)
651651
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND BISON)
652652

653+
set(
654+
_PHP_BISON_DOWNLOAD
655+
TRUE
656+
CACHE INTERNAL
657+
"Internal marker whether the Bison will be downloaded."
658+
)
659+
653660
return(PROPAGATE BISON_FOUND BISON_VERSION)
654661
endfunction()

cmake/cmake/modules/PHP/CheckAVX512.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ TODO: Adjust checks for MSVC.
2020

2121
include_guard(GLOBAL)
2222

23+
# Skip in consecutive configuration phases.
24+
if(DEFINED PHP_HAVE_AVX512_SUPPORTS AND DEFINED PHP_HAVE_AVX512_VBMI_SUPPORTS)
25+
return()
26+
endif()
27+
2328
include(CheckSourceCompiles)
2429
include(CMakePushCheckState)
2530

cmake/cmake/modules/PHP/CheckAttribute.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ function(_php_check_attribute what attribute result)
103103
message(FATAL_ERROR "Wrong argument passed: ${what}")
104104
endif()
105105

106+
# Skip in consecutive configuration phases.
107+
if(DEFINED ${result})
108+
return()
109+
endif()
110+
106111
message(CHECK_START "Checking for ${what} attribute ${attribute}")
107112

108113
cmake_push_check_state(RESET)

cmake/cmake/modules/PHP/CheckBrokenGccStrlenOpt.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86914
1515

1616
include_guard(GLOBAL)
1717

18+
# Skip in consecutive configuration phases.
19+
if(DEFINED PHP_HAVE_BROKEN_OPTIMIZE_STRLEN)
20+
return()
21+
endif()
22+
1823
include(CheckSourceRuns)
1924
include(CMakePushCheckState)
2025

cmake/cmake/modules/PHP/CheckBuiltin.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ include(CheckSourceCompiles)
2727
include(CMakePushCheckState)
2828

2929
function(php_check_builtin builtin result)
30+
# Skip in consecutive configuration phases.
31+
if(DEFINED ${result})
32+
return()
33+
endif()
34+
3035
message(CHECK_START "Checking for ${builtin}")
3136

3237
if(builtin STREQUAL "__builtin_clz")

cmake/cmake/modules/PHP/CheckByteOrder.cmake

+17-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,30 @@ Check whether system byte ordering is big-endian.
1010

1111
include_guard(GLOBAL)
1212

13+
# Skip in consecutive configuration phases.
14+
if(DEFINED WORDS_BIGENDIAN)
15+
return()
16+
endif()
17+
1318
include(CheckSourceRuns)
1419

1520
message(CHECK_START "Checking byte ordering")
1621

1722
if(CMAKE_C_BYTE_ORDER STREQUAL "BIG_ENDIAN")
1823
message(CHECK_PASS "big-endian")
19-
set(WORDS_BIGENDIAN TRUE CACHE INTERNAL "Whether byte ordering is big-endian.")
24+
set(
25+
WORDS_BIGENDIAN
26+
TRUE
27+
CACHE INTERNAL
28+
"Whether byte ordering is big-endian."
29+
)
2030
elseif(CMAKE_C_BYTE_ORDER STREQUAL "LITTLE_ENDIAN")
31+
set(
32+
WORDS_BIGENDIAN
33+
FALSE
34+
CACHE INTERNAL
35+
"Whether byte ordering is big-endian."
36+
)
2137
message(CHECK_PASS "little-endian")
2238
else()
2339
if(

cmake/cmake/modules/PHP/CheckCompilerFlag.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function(php_check_compiler_flag lang flag result)
6565
message(FATAL_ERROR "Missing arguments.")
6666
endif()
6767

68+
# Skip in consecutive configuration phases.
69+
if(DEFINED ${result})
70+
return()
71+
endif()
72+
6873
if(NOT CMAKE_REQUIRED_QUIET)
6974
message(CHECK_START "Checking whether the ${lang} compiler accepts ${flag}")
7075
endif()

cmake/cmake/modules/PHP/CheckCopyFileRange.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ only on Linux.
1414

1515
include_guard(GLOBAL)
1616

17+
# Skip in consecutive configuration phases.
18+
if(DEFINED HAVE_COPY_FILE_RANGE)
19+
return()
20+
endif()
21+
1722
include(CheckSourceCompiles)
1823
include(CMakePushCheckState)
1924

cmake/cmake/modules/PHP/CheckFlushIo.cmake

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ Check if flush should be called explicitly after buffered io.
66
## Cache variables
77
88
* `HAVE_FLUSHIO`
9-
10-
Whether flush should be called explicitly after a buffered io.
119
#]=============================================================================]
1210

1311
include_guard(GLOBAL)
1412

13+
# Skip in consecutive configuration phases.
14+
if(DEFINED HAVE_FLUSHIO)
15+
return()
16+
endif()
17+
1518
include(CheckIncludeFile)
1619
include(CheckSourceRuns)
1720
include(CMakePushCheckState)
@@ -22,7 +25,12 @@ message(CHECK_START
2225

2326
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
2427
message(CHECK_FAIL "no")
25-
set(HAVE_FLUSHIO FALSE CACHE INTERNAL "")
28+
set(
29+
HAVE_FLUSHIO
30+
FALSE
31+
CACHE INTERNAL
32+
"Whether flush should be called explicitly after a buffered io."
33+
)
2634
return()
2735
endif()
2836

cmake/cmake/modules/PHP/CheckFopencookie.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ if(NOT HAVE_FOPENCOOKIE)
4747
return()
4848
endif()
4949

50+
# Skip in consecutive configuration phases.
51+
if(DEFINED COOKIE_SEEKER_USES_OFF64_T)
52+
return()
53+
endif()
54+
5055
# GNU C library can have a different seeker definition using off64_t.
5156
message(CHECK_START "Checking whether fopencookie seeker uses off64_t")
5257

0 commit comments

Comments
 (0)