Skip to content

Commit f3efb9e

Browse files
committed
Fail in ./configure when no opcache shm backends exist
This can be seen when the `./configure` step fails to detect `HAVE_SHM_*`, e.g. due to missing a necessary dependency to compile the test scripts. (Run `./configure`, run `yum install libtool-ltdl-devel` for missing dependencies, then run `make`, and php can end up built with 0 shared memory opcache caches) Give a clearer error message than `unknown` Searching for `opcache "Fatal Error Unable to allocate shared memory segment of" "unknown: No such file or directory"` reveals issues such as termux/termux-packages#2234 Closes GH-5615
1 parent cebe750 commit f3efb9e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ext/opcache/config.m4

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ int main() {
167167
}
168168
]])],[dnl
169169
AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
170-
msg=yes],[msg=no],[msg=no])
171-
AC_MSG_RESULT([$msg])
170+
have_shm_ipc=yes],[have_shm_ipc=no],[have_shm_ipc=no])
171+
AC_MSG_RESULT([$have_shm_ipc])
172172

173173
AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
174174
AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -219,8 +219,8 @@ int main() {
219219
}
220220
]])],[dnl
221221
AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
222-
msg=yes],[msg=no],[msg=no])
223-
AC_MSG_RESULT([$msg])
222+
have_shm_mmap_anon=yes],[have_shm_mmap_anon=no],[have_shm_mmap_anon=no])
223+
AC_MSG_RESULT([$have_shm_mmap_anon=yes])
224224

225225
PHP_CHECK_FUNC_LIB(shm_open, rt)
226226
AC_MSG_CHECKING(for mmap() using shm_open() shared memory support)
@@ -290,6 +290,7 @@ int main() {
290290
]])],[dnl
291291
AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
292292
AC_MSG_RESULT([yes])
293+
have_shm_mmap_posix=yes
293294
PHP_CHECK_LIBRARY(rt, shm_unlink, [PHP_ADD_LIBRARY(rt,1,OPCACHE_SHARED_LIBADD)])
294295
],[
295296
AC_MSG_RESULT([no])
@@ -338,6 +339,10 @@ int main() {
338339
PHP_ADD_BUILD_DIR([$ext_builddir/Optimizer], 1)
339340
PHP_ADD_EXTENSION_DEP(opcache, pcre)
340341

342+
if test "$have_shm_ipc" != "yes" && test "$have_shm_mmap_posix" != "yes" && test "$have_shm_mmap_anon" != "yes"; then
343+
AC_MSG_ERROR([No supported shared memory caching support was found when configuring opcache. Check config.log for any errors or missing dependencies.])
344+
fi
345+
341346
if test "$PHP_OPCACHE_JIT" = "yes"; then
342347
PHP_ADD_BUILD_DIR([$ext_builddir/jit], 1)
343348
PHP_ADD_MAKEFILE_FRAGMENT($ext_srcdir/jit/Makefile.frag)

0 commit comments

Comments
 (0)