Skip to content

Commit ca55603

Browse files
authored
Wrap ext/opcache AC_RUN_IFELSE checks in AC_CACHE_CHECK (#14436)
Cache variables php_cv_shm_ipc and php_cv_shm_mmap_anon enable manual overriding of checks when cross-compiling.
1 parent 028cfda commit ca55603

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

ext/opcache/config.m4

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ if test "$PHP_OPCACHE" != "no"; then
105105

106106
AC_CHECK_FUNCS([mprotect shm_create_largepage])
107107

108-
AC_MSG_CHECKING(for sysvipc shared memory support)
109-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
108+
AC_CACHE_CHECK([for sysvipc shared memory support], [php_cv_shm_ipc],
109+
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
110110
#include <sys/types.h>
111111
#include <sys/wait.h>
112112
#include <sys/ipc.h>
@@ -170,14 +170,17 @@ int main(void) {
170170
}
171171
return 0;
172172
}
173-
]])],[have_shm_ipc=yes],[have_shm_ipc=no],[have_shm_ipc=no])
174-
if test "$have_shm_ipc" = "yes"; then
175-
AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
176-
fi
177-
AC_MSG_RESULT([$have_shm_ipc])
178-
179-
AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
180-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
173+
]])],
174+
[php_cv_shm_ipc=yes],
175+
[php_cv_shm_ipc=no],
176+
[php_cv_shm_ipc=no])])
177+
AS_VAR_IF([php_cv_shm_ipc], [yes],
178+
[AC_DEFINE([HAVE_SHM_IPC], [1],
179+
[Define to 1 if you have the SysV IPC SHM support.])])
180+
181+
AC_CACHE_CHECK([for mmap() using MAP_ANON shared memory support],
182+
[php_cv_shm_mmap_anon],
183+
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
181184
#include <sys/types.h>
182185
#include <sys/wait.h>
183186
#include <sys/mman.h>
@@ -223,20 +226,15 @@ int main(void) {
223226
}
224227
return 0;
225228
}
226-
]])],[have_shm_mmap_anon=yes],[have_shm_mmap_anon=no],[
227-
case $host_alias in
228-
*linux*|*midipix)
229-
have_shm_mmap_anon=yes
230-
;;
231-
*)
232-
have_shm_mmap_anon=no
233-
;;
234-
esac
235-
])
236-
if test "$have_shm_mmap_anon" = "yes"; then
237-
AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
238-
fi
239-
AC_MSG_RESULT([$have_shm_mmap_anon])
229+
]])],
230+
[php_cv_shm_mmap_anon=yes],
231+
[php_cv_shm_mmap_anon=no],
232+
[AS_CASE([host_alias],
233+
[*linux*|*midipix], [php_cv_shm_mmap_anon=yes],
234+
[php_cv_shm_mmap_anon=no])])])
235+
AS_VAR_IF([php_cv_shm_mmap_anon], [yes],
236+
[AC_DEFINE([HAVE_SHM_MMAP_ANON], [1],
237+
[Define to 1 if you have the mmap(MAP_ANON) SHM support.])])
240238

241239
dnl Check POSIX shared memory object operations and link required library as
242240
dnl needed: rt (older Linux and Solaris <= 10). Most systems have it in the C
@@ -343,7 +341,7 @@ int main(void) {
343341

344342
PHP_ADD_EXTENSION_DEP(opcache, pcre)
345343

346-
if test "$have_shm_ipc" != "yes" && test "$php_cv_shm_mmap_posix" != "yes" && test "$have_shm_mmap_anon" != "yes"; then
344+
if test "$php_cv_shm_ipc" != "yes" && test "$php_cv_shm_mmap_posix" != "yes" && test "$php_cv_shm_mmap_anon" != "yes"; then
347345
AC_MSG_ERROR([No supported shared memory caching support was found when configuring opcache. Check config.log for any errors or missing dependencies.])
348346
fi
349347

0 commit comments

Comments
 (0)