Skip to content

Commit 92bd4e5

Browse files
committed
Fix minimum required Argon2 library version
PHP seems to require at least Argon2 library 20161029. This fixes the minimum required version and adds heuristic discovery for Argon2 library version, because Argon2 library doesn't advertise this important piece of information in the header. Some more CS syncs added.
1 parent 188053c commit 92bd4e5

File tree

7 files changed

+56
-13
lines changed

7 files changed

+56
-13
lines changed

cmake/Zend/cmake/CheckStrerrorR.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ include(CheckSourceCompiles)
2929
include(CheckSymbolExists)
3030
include(CMakePushCheckState)
3131

32-
check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
32+
check_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
3333

3434
if(NOT HAVE_STRERROR_R)
3535
return()

cmake/cmake/modules/FindArgon2.cmake

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ find_package(Argon2)
2727
```
2828
#]=============================================================================]
2929

30+
include(CheckSymbolExists)
31+
include(CMakePushCheckState)
3032
include(FeatureSummary)
3133
include(FindPackageHandleStandardArgs)
3234

@@ -67,9 +69,50 @@ if(NOT Argon2_LIBRARY)
6769
string(APPEND _reason "Argon2 library (libargon2) not found. ")
6870
endif()
6971

70-
# Argon2 headers don't provide version. Try pkg-config.
72+
# Argon2 headers don't provide version. Try pkg-config, or fallback to
73+
# heuristic version determination.
7174
if(PC_Argon2_VERSION AND Argon2_INCLUDE_DIR IN_LIST PC_Argon2_INCLUDE_DIRS)
7275
set(Argon2_VERSION ${PC_Argon2_VERSION})
76+
elseif(Argon2_LIBRARY AND Argon2_INCLUDE_DIR)
77+
cmake_push_check_state(RESET)
78+
set(CMAKE_REQUIRED_LIBRARIES "${Argon2_LIBRARY}")
79+
set(CMAKE_REQUIRED_INCLUDES "${Argon2_INCLUDE_DIR}")
80+
set(CMAKE_REQUIRED_QUIET TRUE)
81+
82+
check_symbol_exists(error_message argon2.h _Argon2_HAVE_ERROR_MESSAGE)
83+
84+
if(_Argon2_HAVE_ERROR_MESSAGE)
85+
set(Argon2_VERSION 20151206)
86+
else()
87+
check_symbol_exists(
88+
ARGON2_FLAG_CLEAR_MEMORY
89+
argon2.h
90+
_Argon2_HAVE_ARGON2_FLAG_CLEAR_MEMORY
91+
)
92+
endif()
93+
94+
if(_Argon2_HAVE_ARGON2_FLAG_CLEAR_MEMORY)
95+
set(Argon2_VERSION 20160406)
96+
else()
97+
check_symbol_exists(argon2id_hash_raw argon2.h _Argon2_HAVE_ARGON2ID_HASH_RAW)
98+
endif()
99+
100+
if(_Argon2_HAVE_ARGON2ID_HASH_RAW)
101+
set(Argon2_VERSION 20161029)
102+
endif()
103+
104+
check_symbol_exists(ARGON2_LOCAL argon2.h _Argon2_HAVE_ARGON2_LOCAL)
105+
if(_Argon2_HAVE_ARGON2_LOCAL)
106+
set(Argon2_VERSION 20171227)
107+
108+
file(STRINGS ${Argon2_INCLUDE_DIR}/argon2.h content REGEX " deafults ")
109+
110+
if(NOT content)
111+
set(Argon2_VERSION 20190702)
112+
endif()
113+
unset(content)
114+
endif()
115+
cmake_pop_check_state()
73116
endif()
74117

75118
mark_as_advanced(Argon2_INCLUDE_DIR Argon2_LIBRARY)

cmake/cmake/modules/PHP/CheckReentrantFunctions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function(_php_check_reentrant_function symbol header)
8080

8181
cmake_push_check_state(RESET)
8282
set(CMAKE_REQUIRED_QUIET TRUE)
83-
check_symbol_exists(${symbol} ${header} PHP_HAVE_DECL_${const})
83+
check_symbol_exists(${symbol} "${header}" PHP_HAVE_DECL_${const})
8484
cmake_pop_check_state()
8585

8686
if(NOT PHP_HAVE_DECL_${const})

cmake/ext/pspell/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ endif()
104104
if(TARGET ASPELL::ASPELL)
105105
cmake_push_check_state(RESET)
106106
set(CMAKE_REQUIRED_LIBRARIES ASPELL::ASPELL)
107-
check_symbol_exists(new_aspell_config "aspell.h" _PHP_EXT_PSPELL_CHECK)
107+
check_symbol_exists(new_aspell_config aspell.h _PHP_EXT_PSPELL_CHECK)
108108
cmake_pop_check_state()
109109

110110
if(NOT _PHP_EXT_PSPELL_CHECK)

cmake/ext/standard/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ include(cmake/GenerateGrammar.cmake)
235235
################################################################################
236236

237237
if(PHP_EXT_STANDARD_ARGON2)
238-
find_package(Argon2 20171227)
238+
find_package(Argon2 20161029)
239239
set_package_properties(
240240
Argon2
241241
PROPERTIES
@@ -323,9 +323,9 @@ endif()
323323
# Check if there is a support means of creating a new process and defining which
324324
# handles it receives.
325325
message(CHECK_START "Checking if OS can spawn processes with inherited handles")
326-
check_symbol_exists(fork "unistd.h" HAVE_FORK)
326+
check_symbol_exists(fork unistd.h HAVE_FORK)
327327
if(NOT HAVE_FORK)
328-
check_symbol_exists(CreateProcess "windows.h" HAVE_CREATEPROCESS)
328+
check_symbol_exists(CreateProcess windows.h HAVE_CREATEPROCESS)
329329
endif()
330330
if(HAVE_FORK OR HAVE_CREATEPROCESS)
331331
set(PHP_CAN_SUPPORT_PROC_OPEN TRUE)
@@ -342,12 +342,12 @@ php_search_libraries(
342342
LIBRARIES
343343
socket # Solaris 11..11.3, illumos
344344
network # Haiku
345-
VARIABLE _HAVE_GETIFADDRS
345+
VARIABLE _PHP_HAVE_GETIFADDRS
346346
LIBRARY_VARIABLE libraryForGetifaddrs
347347
TARGET php_ext_standard PRIVATE
348348
)
349349

350-
if(_HAVE_GETIFADDRS)
350+
if(_PHP_HAVE_GETIFADDRS)
351351
message(CHECK_START "Checking for usable getifaddrs")
352352
cmake_push_check_state(RESET)
353353
if(libraryForGetifaddrs)
@@ -469,7 +469,7 @@ php_search_libraries(
469469

470470
check_symbol_exists(
471471
posix_spawn_file_actions_addchdir_np
472-
"spawn.h"
472+
spawn.h
473473
HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP
474474
)
475475

@@ -518,7 +518,7 @@ endblock()
518518
# See: https://github.com/php/php-src/issues/11984
519519
################################################################################
520520

521-
check_symbol_exists(chroot "unistd.h" HAVE_CHROOT)
521+
check_symbol_exists(chroot unistd.h HAVE_CHROOT)
522522

523523
add_library(php_ext_standard_functions OBJECT)
524524
add_library(php_ext_standard_functions_cli OBJECT)

cmake/ext/standard/cmake/CheckStrptime.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ endif()
4242

4343
cmake_push_check_state(RESET)
4444
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
45-
check_symbol_exists(strptime "time.h" HAVE_STRPTIME)
45+
check_symbol_exists(strptime time.h HAVE_STRPTIME)
4646
cmake_pop_check_state()
4747

4848
if(HAVE_STRPTIME)

cmake/sapi/phpdbg/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ message(
235235
)
236236
check_symbol_exists(
237237
UFFDIO_WRITEPROTECT_MODE_WP
238-
"linux/userfaultfd.h"
238+
linux/userfaultfd.h
239239
HAVE_UFFDIO_WRITEPROTECT_MODE_WP
240240
)
241241
if(HAVE_UFFDIO_WRITEPROTECT_MODE_WP)

0 commit comments

Comments
 (0)