Skip to content

Conversation

arnaud-lb
Copy link
Member

@arnaud-lb arnaud-lb commented Aug 2, 2025

Currently, ./configure fails when no SHM backend is available (we support a wide range of systems with mmap(MAP_ANONYMOUS), shmget(), shm_open(), but some non-standard systems may not have any of these). Additionally, even after bypassing the configure check, Opcache emits a fatal error if no SHM backend is available.

Changes in this PR:

  • Make the configure check non-fatal (a warning is printed)
  • At runtime, disable opacche if no backend is available, in the same way we disable opcache by default on CLI

cc @krakjoe @derickr

@arnaud-lb arnaud-lb marked this pull request as ready for review August 2, 2025 09:49
@arnaud-lb arnaud-lb requested a review from dstogov as a code owner August 2, 2025 09:49
Copy link
Member

@derickr derickr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

zps_startup_failure("No available SHM backend", NULL, accelerator_remove_cb);
/* Do not abort PHP startup */
return SUCCESS;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Whitespace that isn't consistent with rest of switch cases. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get. You compile opcache into PHP just to say it can't work on this platform...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dstogov This comes after https://wiki.php.net/rfc/make_opcache_required. The aim is to consistently provide opcache without having to install it separately, and without having to load the extension, but keep PHP compatible with rare systems that don't support any of Opcache's backends.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, for these systems we provide a feature that can't work and just waste resources.
Note that compilation of opcache for these systems may be a problem as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we could at least make the file cache work, at least when opcache.file_cache is specified. In the long term, always building opcache will help reduce complexity and some inconsistencies, even if it ends up being disabled as in this PR, or by opcache.enable(_cli)=0.

I've measured the overhead of building opcache: It is about 110KiB of .text in a -Os build. The total size of the .text section in a minimal PHP build is about 6MiB.

Note that compilation of opcache for these systems may be a problem as well.

I'm happy making changes to address these problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Maybe it make sense to extend the error message with a suggestion to set opcache.enable=0 to "hide" it.

@arnaud-lb arnaud-lb closed this in e4078a6 Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants