Skip to content

Make OPcache non-optional #18961

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ jobs:
--prefix=/usr \
--enable-phpdbg \
--enable-fpm \
--enable-opcache \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pgsql \
Expand Down Expand Up @@ -168,7 +167,6 @@ jobs:
no_output_timeout: 30m
command: |
sapi/cli/php run-tests.php \
-d zend_extension=opcache.so \
-d opcache.enable_cli=1 \
-d opcache.jit_buffer_size=64M \
-d opcache.jit=tracing \
Expand Down
1 change: 0 additions & 1 deletion .github/actions/freebsd/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,3 @@ runs:
--show-diff \
--show-slow 1000 \
--set-timeout 120 \
-d zend_extension=opcache.so
1 change: 0 additions & 1 deletion .github/scripts/windows/test_task.bat
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ mkdir %PHP_BUILD_DIR%\test_file_cache
rem generate php.ini
echo extension_dir=%PHP_BUILD_DIR% > %PHP_BUILD_DIR%\php.ini
echo opcache.file_cache=%PHP_BUILD_DIR%\test_file_cache >> %PHP_BUILD_DIR%\php.ini
if "%OPCACHE%" equ "1" echo zend_extension=php_opcache.dll >> %PHP_BUILD_DIR%\php.ini
rem work-around for some spawned PHP processes requiring OpenSSL and sockets
echo extension=php_openssl.dll >> %PHP_BUILD_DIR%\php.ini
echo extension=php_sockets.dll >> %PHP_BUILD_DIR%\php.ini
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ jobs:
jitType: tracing
runTestsParameters: >-
--asan -x
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Notify Slack
if: failure()
Expand Down Expand Up @@ -240,14 +239,12 @@ jobs:
jitType: tracing
runTestsParameters: >-
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Test OpCache
uses: ./.github/actions/test-linux
with:
runTestsParameters: >-
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Test Function JIT
# ASAN frequently timeouts. Each test run takes ~90 minutes, we can
Expand All @@ -258,7 +255,6 @@ jobs:
jitType: function
runTestsParameters: >-
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
Expand Down Expand Up @@ -332,22 +328,19 @@ jobs:
jitType: tracing
runTestsParameters: >-
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Test OpCache
uses: ./.github/actions/test-linux
with:
runTestsParameters: >-
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Test Function JIT
uses: ./.github/actions/test-linux
with:
jitType: function
runTestsParameters: >-
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Notify Slack
if: failure()
Expand Down Expand Up @@ -392,21 +385,18 @@ jobs:
with:
jitType: tracing
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Test OpCache
uses: ./.github/actions/test-macos
with:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Test Function JIT
if: matrix.os != '14' || !matrix.zts
uses: ./.github/actions/test-macos
with:
jitType: function
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
Expand Down Expand Up @@ -468,7 +458,6 @@ jobs:
with:
jitType: tracing
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- uses: codecov/codecov-action@v4
if: ${{ !cancelled() }}
Expand Down Expand Up @@ -522,7 +511,6 @@ jobs:
- name: Enable Opcache
run: |
echo memory_limit=-1 >> /etc/php.d/opcache.ini
echo zend_extension=opcache.so > /etc/php.d/opcache.ini
echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
echo opcache.enable=1 >> /etc/php.d/opcache.ini
echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
Expand Down Expand Up @@ -713,37 +701,32 @@ jobs:
uses: ./.github/actions/test-linux
with:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
--file-cache-prime
- name: Test File Cache (prime shm, use shm)
uses: ./.github/actions/test-linux
with:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
--file-cache-use
- name: Test File Cache (prime shm, use file)
uses: ./.github/actions/test-linux
with:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
--file-cache-use
-d opcache.file_cache_only=1
- name: Test File Cache Only (prime)
uses: ./.github/actions/test-linux
with:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
--file-cache-prime
-d opcache.file_cache_only=1
- name: Test File Cache Only (use)
uses: ./.github/actions/test-linux
with:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
--file-cache-use
-d opcache.file_cache_only=1
Expand Down Expand Up @@ -837,7 +820,6 @@ jobs:
with:
runTestsParameters: >-
--msan
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ jobs:
with:
jitType: tracing
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
${{ matrix.asan && '--asan -x' || '' }}
- name: Verify generated files are up to date
Expand Down Expand Up @@ -190,7 +189,6 @@ jobs:
with:
jitType: tracing
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
MACOS_DEBUG_NTS:
if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
Expand Down Expand Up @@ -229,7 +227,6 @@ jobs:
with:
jitType: tracing
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
Expand Down Expand Up @@ -299,7 +296,6 @@ jobs:
./configure \
--disable-debug \
--enable-mbstring \
--enable-opcache \
--enable-option-checking=fatal \
--enable-sockets \
--enable-werror \
Expand All @@ -319,7 +315,6 @@ jobs:
sudo mkdir -p /etc/php.d
sudo chmod 777 /etc/php.d
echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
echo zend_extension=opcache.so >> /etc/php.d/opcache.ini
echo opcache.enable=1 >> /etc/php.d/opcache.ini
echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
- name: Setup
Expand Down
8 changes: 4 additions & 4 deletions docs/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ slightly different steps. We'll call attention where the steps differ.
# With ZTS
make distclean || \
./buildconf --force \
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache-jit \
&& make -j$(nproc) \
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
|| ./sapi/cli/php -v

# Without ZTS
make distclean || \
./buildconf --force \
&& ./configure --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
&& ./configure --disable-all --enable-debug --enable-opcache-jit \
&& make -j$(nproc) \
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
|| ./sapi/cli/php -v
Expand Down Expand Up @@ -528,15 +528,15 @@ slightly different steps. We'll call attention where the steps differ.
# With ZTS
make distclean || \
./buildconf --force \
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache-jit \
&& make -j$(nproc) \
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
|| ./sapi/cli/php -v

# Without ZTS
make distclean || \
./buildconf --force \
&& ./configure --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
&& ./configure --disable-all --enable-debug --enable-opcache-jit \
&& make -j$(nproc) \
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
|| ./sapi/cli/php -v
Expand Down
22 changes: 9 additions & 13 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "zend_extensions.h"
#include "zend_compile.h"
#include "ZendAccelerator.h"
#include "zend_modules.h"
#include "zend_persist.h"
#include "zend_shared_alloc.h"
#include "zend_accelerator_module.h"
Expand Down Expand Up @@ -102,15 +103,12 @@ typedef int gid_t;

#include "zend_simd.h"

ZEND_EXTENSION();
static zend_extension opcache_extension_entry;

#ifndef ZTS
zend_accel_globals accel_globals;
#else
int accel_globals_id;
#if defined(COMPILE_DL_OPCACHE)
ZEND_TSRMLS_CACHE_DEFINE()
#endif
#endif

/* Points to the structure shared across all PHP processes */
Expand Down Expand Up @@ -2969,9 +2967,6 @@ static zend_result zend_accel_init_shm(void)

static void accel_globals_ctor(zend_accel_globals *accel_globals)
{
#if defined(COMPILE_DL_OPCACHE) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
memset(accel_globals, 0, sizeof(zend_accel_globals));
accel_globals->key = zend_string_alloc(ZCG_KEY_LEN, true);
GC_MAKE_PERSISTENT_LOCAL(accel_globals->key);
Expand Down Expand Up @@ -3156,6 +3151,11 @@ static void accel_move_code_to_huge_pages(void)
# endif /* defined(MAP_HUGETLB) || defined(MADV_HUGEPAGE) */
#endif /* HAVE_HUGE_CODE_PAGES */

void start_accel_extension(void)
{
zend_register_extension(&opcache_extension_entry, NULL);
}

static int accel_startup(zend_extension *extension)
{
#ifdef ZTS
Expand All @@ -3174,11 +3174,7 @@ static int accel_startup(zend_extension *extension)
# endif
#endif

if (start_accel_module() == FAILURE) {
accel_startup_ok = false;
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME ": module registration failed!");
return FAILURE;
}
zend_accel_register_ini_entries();

#ifdef ZEND_WIN32
if (UNEXPECTED(accel_gen_uname_id() == FAILURE)) {
Expand Down Expand Up @@ -5084,7 +5080,7 @@ static void accel_activate(void) {
}
}

ZEND_EXT_API zend_extension zend_extension_entry = {
static zend_extension opcache_extension_entry = {
ACCELERATOR_PRODUCT_NAME, /* name */
PHP_VERSION, /* version */
"Zend Technologies", /* author */
Expand Down
4 changes: 1 addition & 3 deletions ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,6 @@ extern zend_accel_shared_globals *accel_shared_globals;
#ifdef ZTS
# define ZCG(v) ZEND_TSRMG(accel_globals_id, zend_accel_globals *, v)
extern int accel_globals_id;
# ifdef COMPILE_DL_OPCACHE
ZEND_TSRMLS_CACHE_EXTERN()
# endif
#else
# define ZCG(v) (accel_globals.v)
extern zend_accel_globals accel_globals;
Expand All @@ -314,6 +311,7 @@ extern const char *zps_api_failure_reason;

BEGIN_EXTERN_C()

void start_accel_extension(void);
void accel_shutdown(void);
ZEND_RINIT_FUNCTION(zend_accelerator);
zend_result accel_post_deactivate(void);
Expand Down
Loading