Skip to content

Commit 7b4c14d

Browse files
arnaud-lbTimWolla
andcommitted
Make OPcache non-optional
This removes the --enable-opcache/--disable-opcache configure switch. OPcache is now always builtin. The default value of opcache.enable and opcache.enable_cli is unchanged. RFC: https://wiki.php.net/rfc/make_opcache_required Closes GH-18961. Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
1 parent 6f3bc59 commit 7b4c14d

21 files changed

+239
-264
lines changed

.circleci/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ jobs:
9090
--prefix=/usr \
9191
--enable-phpdbg \
9292
--enable-fpm \
93-
--enable-opcache \
9493
--with-pdo-mysql=mysqlnd \
9594
--with-mysqli=mysqlnd \
9695
--with-pgsql \
@@ -168,7 +167,6 @@ jobs:
168167
no_output_timeout: 30m
169168
command: |
170169
sapi/cli/php run-tests.php \
171-
-d zend_extension=opcache.so \
172170
-d opcache.enable_cli=1 \
173171
-d opcache.jit_buffer_size=64M \
174172
-d opcache.jit=tracing \

.github/actions/freebsd/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ runs:
113113
--offline \
114114
--show-diff \
115115
--show-slow 1000 \
116-
--set-timeout 120 \
117-
-d zend_extension=opcache.so
116+
--set-timeout 120
118117
119118
if test "${{ inputs.runExtraTests }}" = "true"; then
120119
sapi/cli/php run-extra-tests.php

.github/scripts/windows/test_task.bat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ mkdir %PHP_BUILD_DIR%\test_file_cache
128128
rem generate php.ini
129129
echo extension_dir=%PHP_BUILD_DIR% > %PHP_BUILD_DIR%\php.ini
130130
echo opcache.file_cache=%PHP_BUILD_DIR%\test_file_cache >> %PHP_BUILD_DIR%\php.ini
131-
if "%OPCACHE%" equ "1" echo zend_extension=php_opcache.dll >> %PHP_BUILD_DIR%\php.ini
132131
rem work-around for some spawned PHP processes requiring OpenSSL and sockets
133132
echo extension=php_openssl.dll >> %PHP_BUILD_DIR%\php.ini
134133
echo extension=php_sockets.dll >> %PHP_BUILD_DIR%\php.ini

.github/workflows/nightly.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ jobs:
134134
jitType: tracing
135135
runTestsParameters: >-
136136
--asan -x
137-
-d zend_extension=opcache.so
138137
-d opcache.enable_cli=1
139138
- name: Extra tests
140139
uses: ./.github/actions/extra-tests
@@ -250,14 +249,12 @@ jobs:
250249
jitType: tracing
251250
runTestsParameters: >-
252251
${{ matrix.run_tests_parameters }}
253-
-d zend_extension=opcache.so
254252
-d opcache.enable_cli=1
255253
- name: Test OpCache
256254
uses: ./.github/actions/test-linux
257255
with:
258256
runTestsParameters: >-
259257
${{ matrix.run_tests_parameters }}
260-
-d zend_extension=opcache.so
261258
-d opcache.enable_cli=1
262259
- name: Test Function JIT
263260
# ASAN frequently timeouts. Each test run takes ~90 minutes, we can
@@ -268,7 +265,6 @@ jobs:
268265
jitType: function
269266
runTestsParameters: >-
270267
${{ matrix.run_tests_parameters }}
271-
-d zend_extension=opcache.so
272268
-d opcache.enable_cli=1
273269
- name: Extra tests
274270
uses: ./.github/actions/extra-tests
@@ -344,22 +340,19 @@ jobs:
344340
jitType: tracing
345341
runTestsParameters: >-
346342
${{ matrix.run_tests_parameters }}
347-
-d zend_extension=opcache.so
348343
-d opcache.enable_cli=1
349344
- name: Test OpCache
350345
uses: ./.github/actions/test-linux
351346
with:
352347
runTestsParameters: >-
353348
${{ matrix.run_tests_parameters }}
354-
-d zend_extension=opcache.so
355349
-d opcache.enable_cli=1
356350
- name: Test Function JIT
357351
uses: ./.github/actions/test-linux
358352
with:
359353
jitType: function
360354
runTestsParameters: >-
361355
${{ matrix.run_tests_parameters }}
362-
-d zend_extension=opcache.so
363356
-d opcache.enable_cli=1
364357
- name: Extra tests
365358
uses: ./.github/actions/extra-tests
@@ -406,21 +399,18 @@ jobs:
406399
with:
407400
jitType: tracing
408401
runTestsParameters: >-
409-
-d zend_extension=opcache.so
410402
-d opcache.enable_cli=1
411403
- name: Test OpCache
412404
uses: ./.github/actions/test-macos
413405
with:
414406
runTestsParameters: >-
415-
-d zend_extension=opcache.so
416407
-d opcache.enable_cli=1
417408
- name: Test Function JIT
418409
if: matrix.os != '14' || !matrix.zts
419410
uses: ./.github/actions/test-macos
420411
with:
421412
jitType: function
422413
runTestsParameters: >-
423-
-d zend_extension=opcache.so
424414
-d opcache.enable_cli=1
425415
- name: Extra tests
426416
uses: ./.github/actions/extra-tests
@@ -484,7 +474,6 @@ jobs:
484474
with:
485475
jitType: tracing
486476
runTestsParameters: >-
487-
-d zend_extension=opcache.so
488477
-d opcache.enable_cli=1
489478
- uses: codecov/codecov-action@v4
490479
if: ${{ !cancelled() }}
@@ -538,7 +527,6 @@ jobs:
538527
- name: Enable Opcache
539528
run: |
540529
echo memory_limit=-1 >> /etc/php.d/opcache.ini
541-
echo zend_extension=opcache.so > /etc/php.d/opcache.ini
542530
echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
543531
echo opcache.enable=1 >> /etc/php.d/opcache.ini
544532
echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
@@ -729,37 +717,32 @@ jobs:
729717
uses: ./.github/actions/test-linux
730718
with:
731719
runTestsParameters: >-
732-
-d zend_extension=opcache.so
733720
-d opcache.enable_cli=1
734721
--file-cache-prime
735722
- name: Test File Cache (prime shm, use shm)
736723
uses: ./.github/actions/test-linux
737724
with:
738725
runTestsParameters: >-
739-
-d zend_extension=opcache.so
740726
-d opcache.enable_cli=1
741727
--file-cache-use
742728
- name: Test File Cache (prime shm, use file)
743729
uses: ./.github/actions/test-linux
744730
with:
745731
runTestsParameters: >-
746-
-d zend_extension=opcache.so
747732
-d opcache.enable_cli=1
748733
--file-cache-use
749734
-d opcache.file_cache_only=1
750735
- name: Test File Cache Only (prime)
751736
uses: ./.github/actions/test-linux
752737
with:
753738
runTestsParameters: >-
754-
-d zend_extension=opcache.so
755739
-d opcache.enable_cli=1
756740
--file-cache-prime
757741
-d opcache.file_cache_only=1
758742
- name: Test File Cache Only (use)
759743
uses: ./.github/actions/test-linux
760744
with:
761745
runTestsParameters: >-
762-
-d zend_extension=opcache.so
763746
-d opcache.enable_cli=1
764747
--file-cache-use
765748
-d opcache.file_cache_only=1
@@ -853,7 +836,6 @@ jobs:
853836
with:
854837
runTestsParameters: >-
855838
--msan
856-
-d zend_extension=opcache.so
857839
-d opcache.enable_cli=1
858840
- name: Verify generated files are up to date
859841
uses: ./.github/actions/verify-generated-files

.github/workflows/push.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ jobs:
130130
with:
131131
jitType: tracing
132132
runTestsParameters: >-
133-
-d zend_extension=opcache.so
134133
-d opcache.enable_cli=1
135134
${{ matrix.asan && '--asan -x' || '' }}
136135
- name: Verify generated files are up to date
@@ -190,7 +189,6 @@ jobs:
190189
with:
191190
jitType: tracing
192191
runTestsParameters: >-
193-
-d zend_extension=opcache.so
194192
-d opcache.enable_cli=1
195193
MACOS_DEBUG_NTS:
196194
if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
@@ -229,7 +227,6 @@ jobs:
229227
with:
230228
jitType: tracing
231229
runTestsParameters: >-
232-
-d zend_extension=opcache.so
233230
-d opcache.enable_cli=1
234231
- name: Verify generated files are up to date
235232
uses: ./.github/actions/verify-generated-files
@@ -299,7 +296,6 @@ jobs:
299296
./configure \
300297
--disable-debug \
301298
--enable-mbstring \
302-
--enable-opcache \
303299
--enable-option-checking=fatal \
304300
--enable-sockets \
305301
--enable-werror \
@@ -319,7 +315,6 @@ jobs:
319315
sudo mkdir -p /etc/php.d
320316
sudo chmod 777 /etc/php.d
321317
echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
322-
echo zend_extension=opcache.so >> /etc/php.d/opcache.ini
323318
echo opcache.enable=1 >> /etc/php.d/opcache.ini
324319
echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
325320
- name: Setup

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ PHP NEWS
1515
- OPcache:
1616
. Disallow changing opcache.memory_consumption when SHM is already set up.
1717
(timwolla)
18+
. Fixed GH-15074 (Compiling opcache statically into ZTS PHP fails). (Arnaud)
19+
. Make OPcache non-optional (Arnaud, timwolla)
1820

1921
- OpenSSL:
2022
. Add $digest_algo parameter to openssl_public_encrypt() and

UPGRADING

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ PHP 8.5 UPGRADE NOTES
7171
. Calling the mysqli constructor on an already-constructed object
7272
is now no longer possible and throws an Error.
7373

74+
- Opcache:
75+
. The Opcache extension is now always built into the PHP binary and is always
76+
loaded. The INI directives opcache.enable and opcache.enable_cli are still
77+
honored.
78+
The --enable-opcache/--disable-opcache configure flags have been removed,
79+
and the build does not produce opcache.so or php_opcache.dll objects
80+
anymore.
81+
Using zend_extension=opcache.so or zend_extension=php_opcache.dll INI
82+
directives will emit a warning.
83+
7484
- PCNTL:
7585
. pcntl_exec() now throws ValueErrors when entries of the $args parameter
7686
contain null bytes.
@@ -522,6 +532,11 @@ PHP 8.5 UPGRADE NOTES
522532
library that was separated from ext/dom for being reused among other
523533
extensions. The new extension is not directly exposed to userland.
524534

535+
- Opcache:
536+
. The Opcache extension is now always built into the PHP binary and is always
537+
loaded. The INI directives opcache.enable and opcache.enable_cli are still
538+
honored.
539+
525540
- URI:
526541
. An always enabled uri extension is added that can be used for handling
527542
URIs and URLs according to RFC 3986 and WHATWG URL.
@@ -693,6 +708,10 @@ PHP 8.5 UPGRADE NOTES
693708
. The parts of the code that used SSE2 have been adapted to use SIMD
694709
with ARM NEON as well.
695710

711+
- Opcache:
712+
. Improved performance of fetching TLS variables in JIT'ed code in non-Glibc
713+
builds.
714+
696715
- ReflectionProperty:
697716
. Improved performance of the following methods: getValue(), getRawValue(),
698717
isInitialized(), setValue(), setRawValue().

docs/release-process.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ slightly different steps. We'll call attention where the steps differ.
219219
# With ZTS
220220
make distclean || \
221221
./buildconf --force \
222-
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
222+
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache-jit \
223223
&& make -j$(nproc) \
224224
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
225225
|| ./sapi/cli/php -v
226226
227227
# Without ZTS
228228
make distclean || \
229229
./buildconf --force \
230-
&& ./configure --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
230+
&& ./configure --disable-all --enable-debug --enable-opcache-jit \
231231
&& make -j$(nproc) \
232232
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
233233
|| ./sapi/cli/php -v
@@ -571,15 +571,15 @@ slightly different steps. We'll call attention where the steps differ.
571571
# With ZTS
572572
make distclean || \
573573
./buildconf --force \
574-
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
574+
&& ./configure --enable-zts --disable-all --enable-debug --enable-opcache-jit \
575575
&& make -j$(nproc) \
576576
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
577577
|| ./sapi/cli/php -v
578578
579579
# Without ZTS
580580
make distclean || \
581581
./buildconf --force \
582-
&& ./configure --disable-all --enable-debug --enable-opcache --enable-opcache-jit \
582+
&& ./configure --disable-all --enable-debug --enable-opcache-jit \
583583
&& make -j$(nproc) \
584584
&& make test TEST_PHP_ARGS="-q -j$(nproc)" \
585585
|| ./sapi/cli/php -v

ext/opcache/ZendAccelerator.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "zend_extensions.h"
2626
#include "zend_compile.h"
2727
#include "ZendAccelerator.h"
28+
#include "zend_modules.h"
2829
#include "zend_persist.h"
2930
#include "zend_shared_alloc.h"
3031
#include "zend_accelerator_module.h"
@@ -102,15 +103,12 @@ typedef int gid_t;
102103

103104
#include "zend_simd.h"
104105

105-
ZEND_EXTENSION();
106+
static zend_extension opcache_extension_entry;
106107

107108
#ifndef ZTS
108109
zend_accel_globals accel_globals;
109110
#else
110111
int accel_globals_id;
111-
#if defined(COMPILE_DL_OPCACHE)
112-
ZEND_TSRMLS_CACHE_DEFINE()
113-
#endif
114112
#endif
115113

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

29702968
static void accel_globals_ctor(zend_accel_globals *accel_globals)
29712969
{
2972-
#if defined(COMPILE_DL_OPCACHE) && defined(ZTS)
2973-
ZEND_TSRMLS_CACHE_UPDATE();
2974-
#endif
29752970
memset(accel_globals, 0, sizeof(zend_accel_globals));
29762971
accel_globals->key = zend_string_alloc(ZCG_KEY_LEN, true);
29772972
GC_MAKE_PERSISTENT_LOCAL(accel_globals->key);
@@ -3156,6 +3151,11 @@ static void accel_move_code_to_huge_pages(void)
31563151
# endif /* defined(MAP_HUGETLB) || defined(MADV_HUGEPAGE) */
31573152
#endif /* HAVE_HUGE_CODE_PAGES */
31583153

3154+
void start_accel_extension(void)
3155+
{
3156+
zend_register_extension(&opcache_extension_entry, NULL);
3157+
}
3158+
31593159
static int accel_startup(zend_extension *extension)
31603160
{
31613161
#ifdef ZTS
@@ -3174,11 +3174,7 @@ static int accel_startup(zend_extension *extension)
31743174
# endif
31753175
#endif
31763176

3177-
if (start_accel_module() == FAILURE) {
3178-
accel_startup_ok = false;
3179-
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME ": module registration failed!");
3180-
return FAILURE;
3181-
}
3177+
zend_accel_register_ini_entries();
31823178

31833179
#ifdef ZEND_WIN32
31843180
if (UNEXPECTED(accel_gen_uname_id() == FAILURE)) {
@@ -5086,7 +5082,7 @@ static void accel_activate(void) {
50865082
}
50875083
}
50885084

5089-
ZEND_EXT_API zend_extension zend_extension_entry = {
5085+
static zend_extension opcache_extension_entry = {
50905086
ACCELERATOR_PRODUCT_NAME, /* name */
50915087
PHP_VERSION, /* version */
50925088
"Zend Technologies", /* author */

ext/opcache/ZendAccelerator.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@ extern zend_accel_shared_globals *accel_shared_globals;
302302
#ifdef ZTS
303303
# define ZCG(v) ZEND_TSRMG(accel_globals_id, zend_accel_globals *, v)
304304
extern int accel_globals_id;
305-
# ifdef COMPILE_DL_OPCACHE
306-
ZEND_TSRMLS_CACHE_EXTERN()
307-
# endif
308305
#else
309306
# define ZCG(v) (accel_globals.v)
310307
extern zend_accel_globals accel_globals;
@@ -314,6 +311,7 @@ extern const char *zps_api_failure_reason;
314311

315312
BEGIN_EXTERN_C()
316313

314+
void start_accel_extension(void);
317315
void accel_shutdown(void);
318316
ZEND_RINIT_FUNCTION(zend_accelerator);
319317
zend_result accel_post_deactivate(void);

0 commit comments

Comments
 (0)