Skip to content

Commit 7521fb6

Browse files
committed
Refactor checks
This simplifies and refactors checks a bit further.
1 parent 7d42c93 commit 7521fb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+669
-859
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ cmake_dependent_option(
7777
)
7878
mark_as_advanced(ZEND_FIBER_ASM)
7979

80-
option(ZEND_GLOBAL_REGISTER_VARIABLES "Enable global register variables" ON)
81-
mark_as_advanced(ZEND_GLOBAL_REGISTER_VARIABLES)
82-
8380
cmake_dependent_option(
8481
ZEND_SIGNALS
8582
"Enable Zend signal handling"
@@ -432,14 +429,10 @@ include(cmake/CheckAsmGoto.cmake)
432429
include(cmake/CheckCpuidCount.cmake)
433430
include(cmake/CheckDlsym.cmake)
434431
include(cmake/CheckFloatPrecision.cmake)
435-
436-
if(ZEND_GLOBAL_REGISTER_VARIABLES)
437-
include(cmake/CheckGlobalRegisterVariables.cmake)
438-
endif()
439-
440432
include(cmake/CheckMMAlignment.cmake)
441433
include(cmake/CheckStackDirection.cmake)
442434
include(cmake/CheckStrerrorR.cmake)
435+
include(cmake/GlobalRegisterVariables.cmake)
443436

444437
################################################################################
445438
# Zend signals.
Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,45 @@
11
#[=============================================================================[
2-
Check whether the C compiler has support for the asm goto.
2+
Check whether the C compiler supports the inline assembly __asm__ goto.
33
44
Result variables:
55
66
* HAVE_ASM_GOTO
77
#]=============================================================================]
88

9-
include_guard(GLOBAL)
10-
119
include(CheckSourceCompiles)
1210
include(CMakePushCheckState)
1311

14-
set(HAVE_ASM_GOTO FALSE)
12+
# The check below otherwise passes on Windows but it is disabled in PHP.
13+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
14+
set(HAVE_ASM_GOTO FALSE)
15+
return()
16+
endif()
1517

1618
# Skip in consecutive configuration phases.
17-
if(DEFINED PHP_ZEND_HAS_ASM_GOTO)
19+
if(NOT DEFINED PHP_ZEND_HAS_ASM_GOTO)
20+
message(CHECK_START "Checking for the inline assembly __asm__ goto support")
21+
22+
cmake_push_check_state(RESET)
23+
set(CMAKE_REQUIRED_QUIET TRUE)
24+
check_source_compiles(C [[
25+
int main(void)
26+
{
27+
#if defined(__x86_64__) || defined(__i386__)
28+
__asm__ goto("jmp %l0\n" :::: end);
29+
#elif defined(__aarch64__)
30+
__asm__ goto("b %l0\n" :::: end);
31+
#endif
32+
end:
33+
return 0;
34+
}
35+
]] PHP_ZEND_HAS_ASM_GOTO)
36+
cmake_pop_check_state()
37+
1838
if(PHP_ZEND_HAS_ASM_GOTO)
19-
set(HAVE_ASM_GOTO TRUE)
39+
message(CHECK_PASS "yes")
40+
else()
41+
message(CHECK_FAIL "no")
2042
endif()
21-
return()
2243
endif()
2344

24-
# TODO: The check in this module otherwise passes on Windows. Should this be
25-
# enabled on Windows?
26-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
27-
return()
28-
endif()
29-
30-
message(CHECK_START "Checking for asm goto support")
31-
cmake_push_check_state(RESET)
32-
set(CMAKE_REQUIRED_QUIET TRUE)
33-
check_source_compiles(C [[
34-
int main(void)
35-
{
36-
#if defined(__x86_64__) || defined(__i386__)
37-
__asm__ goto("jmp %l0\n" :::: end);
38-
#elif defined(__aarch64__)
39-
__asm__ goto("b %l0\n" :::: end);
40-
#endif
41-
end:
42-
return 0;
43-
}
44-
]] PHP_ZEND_HAS_ASM_GOTO)
45-
cmake_pop_check_state()
46-
47-
if(PHP_ZEND_HAS_ASM_GOTO)
48-
set(HAVE_ASM_GOTO TRUE)
49-
message(CHECK_PASS "yes")
50-
else()
51-
message(CHECK_FAIL "no")
52-
endif()
45+
set(HAVE_ASM_GOTO ${PHP_ZEND_HAS_ASM_GOTO})

cmake/Zend/cmake/CheckCpuidCount.cmake

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,36 @@ Result variables:
66
* HAVE_CPUID_COUNT
77
#]=============================================================================]
88

9-
include_guard(GLOBAL)
10-
119
include(CheckSourceCompiles)
1210
include(CMakePushCheckState)
1311

14-
set(HAVE_CPUID_COUNT FALSE)
12+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
13+
set(HAVE_CPUID_COUNT FALSE)
14+
return()
15+
endif()
1516

1617
# Skip in consecutive configuration phases.
17-
if(DEFINED PHP_ZEND_HAS_CPUID_COUNT)
18+
if(NOT DEFINED PHP_ZEND_HAS_CPUID_COUNT)
19+
message(CHECK_START "Checking whether __cpuid_count is available")
20+
21+
cmake_push_check_state(RESET)
22+
set(CMAKE_REQUIRED_QUIET TRUE)
23+
check_source_compiles(C [[
24+
#include <cpuid.h>
25+
int main(void)
26+
{
27+
unsigned eax, ebx, ecx, edx;
28+
__cpuid_count(0, 0, eax, ebx, ecx, edx);
29+
return 0;
30+
}
31+
]] PHP_ZEND_HAS_CPUID_COUNT)
32+
cmake_pop_check_state()
33+
1834
if(PHP_ZEND_HAS_CPUID_COUNT)
19-
set(HAVE_CPUID_COUNT TRUE)
35+
message(CHECK_PASS "yes")
36+
else()
37+
message(CHECK_FAIL "no")
2038
endif()
21-
return()
2239
endif()
2340

24-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
25-
return()
26-
endif()
27-
28-
message(CHECK_START "Checking whether __cpuid_count is available")
29-
cmake_push_check_state(RESET)
30-
set(CMAKE_REQUIRED_QUIET TRUE)
31-
check_source_compiles(C [[
32-
#include <cpuid.h>
33-
int main(void)
34-
{
35-
unsigned eax, ebx, ecx, edx;
36-
__cpuid_count(0, 0, eax, ebx, ecx, edx);
37-
return 0;
38-
}
39-
]] PHP_ZEND_HAS_CPUID_COUNT)
40-
cmake_pop_check_state()
41-
42-
if(PHP_ZEND_HAS_CPUID_COUNT)
43-
set(HAVE_CPUID_COUNT TRUE)
44-
message(CHECK_PASS "yes")
45-
else()
46-
message(CHECK_FAIL "no")
47-
endif()
41+
set(HAVE_CPUID_COUNT ${PHP_ZEND_HAS_CPUID_COUNT})

cmake/Zend/cmake/CheckDlsym.cmake

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,38 @@ Check if dlsym() requires a leading underscore in symbol name.
33
44
Some non-ELF platforms, such as OpenBSD, FreeBSD, NetBSD, Mac OSX (~10.3),
55
needed to prefix symbols with underscore character (_), when using dlsym(). This
6-
module is obsolete on current platforms.
6+
check is obsolete on current platforms.
77
88
Result variables:
99
1010
* DLSYM_NEEDS_UNDERSCORE
1111
#]=============================================================================]
1212

13-
include_guard(GLOBAL)
14-
15-
set(DLSYM_NEEDS_UNDERSCORE FALSE)
13+
include(CheckIncludeFiles)
1614

1715
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
16+
set(DLSYM_NEEDS_UNDERSCORE FALSE)
1817
return()
1918
endif()
2019

2120
# Skip in consecutive configuration phases.
2221
if(DEFINED PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE)
23-
if(PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE)
24-
set(DLSYM_NEEDS_UNDERSCORE TRUE)
25-
endif()
26-
22+
set(DLSYM_NEEDS_UNDERSCORE ${PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE})
2723
return()
2824
endif()
2925

30-
include(CheckIncludeFiles)
31-
3226
message(
3327
CHECK_START
3428
"Checking whether dlsym() needs to prefix symbols with underscore"
3529
)
3630

3731
# When cross-compiling without emulator, assume that target platform is recent
3832
# enough so that dlsym doesn't need leading underscores.
39-
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR)
33+
if(
34+
CMAKE_CROSSCOMPILING
35+
AND NOT CMAKE_CROSSCOMPILING_EMULATOR
36+
AND NOT DEFINED PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_EXITCODE
37+
)
4038
set(PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_EXITCODE 0)
4139
endif()
4240

@@ -135,9 +133,10 @@ if(
135133
AND PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_EXITCODE EQUAL 2
136134
)
137135
set_property(CACHE PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE TRUE)
138-
set(DLSYM_NEEDS_UNDERSCORE TRUE)
139136
message(CHECK_FAIL "yes")
140137
else()
141138
set_property(CACHE PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE FALSE)
142139
message(CHECK_PASS "no")
143140
endif()
141+
142+
set(DLSYM_NEEDS_UNDERSCORE ${PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE})

0 commit comments

Comments
 (0)