-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[RFC][PoC] Allow opcache to be built statically #18660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
arnaud-lb
wants to merge
8
commits into
php:master
Choose a base branch
from
arnaud-lb:static-opcache-hybrid
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Opcache is both a Zend extension and a PHP module. When Opcache is built statically, the engine will attempt to initialize it as a PHP module, but will not initialize the Zend extension. Here I make Opcache a two-way hybrid extension [1] so that initializing it as a PHP module also initializes the Zend extension. [1] https://www.phpinternalsbook.com/php7/extensions_design/zend_extensions.html#hybrid-extensions
…`_tsrm_ls_cache' at 0x12fc3 in section `.text' failed" In order to get information about the _tsrm_ls_cache TLS variable, we emit ASM code with TLS-related relocations [1]. These relocations, once adjusted by the linker, give us the offset or address of the variable's TLS descriptor. Specifically, we use relocations meant for use in the "General Dynamic" model described in [1]. When building Opcache statically in a binary, the linker will attempt to optimize the General Dynamic code sequence to a more efficient one. Unfortunately, linkers will break as we don't use the exact code sequence they are expecting. Here I use a different approach to get information about the TLS variable: * Emit the exact code sequence expected by linker, so that linking works * Extract the information we want by inspecting the ASM code. If the linker did something we didn't expect, we fallback to a safer (but slower) mechanism. [1] https://www.akkadia.org/drepper/tls.pdf
13a234a
to
ba04798
Compare
I remember low level extension like xdebug, blackfire, taint and opcache had problems in the past when enabled at the same time. I am not sure whether thats still the case with the latest php versions. Just want to leave this here in case it rings a bell for someone |
SAPIs such as phpdbg may run multiple startup-shutdown cycles in the same process.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes it possible to build opcache statically (and always enables it).
JIT/ZTS is supported.
See commits for details.
RFC: https://wiki.php.net/rfc/make_opcache_required