From 2027cae21c8346b9709b12ce99ba394b81a29c30 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Mon, 29 Sep 2025 09:58:01 +0200 Subject: [PATCH] Enable preloading on Windows --- .../opcache_validator_errors.phpt | 4 --- ext/ffi/tests/bug78761.phpt | 1 - ext/opcache/ZendAccelerator.c | 27 +++++-------------- .../tests/api/opcache_preloading_001.phpt | 4 --- .../tests/api/opcache_preloading_002.phpt | 2 +- ext/opcache/tests/bug78014.phpt | 4 --- ext/opcache/tests/bug78175.phpt | 4 --- ext/opcache/tests/bug78175_2.phpt | 4 --- ext/opcache/tests/bug78376.phpt | 4 --- ext/opcache/tests/bug78937_1.phpt | 4 --- ext/opcache/tests/bug78937_2.phpt | 4 --- ext/opcache/tests/bug78937_3.phpt | 4 --- ext/opcache/tests/bug78937_4.phpt | 4 --- ext/opcache/tests/bug78937_5.phpt | 4 --- ext/opcache/tests/bug78937_6.phpt | 4 --- ext/opcache/tests/gh10405.phpt | 2 +- ext/opcache/tests/gh10914.phpt | 4 --- ext/opcache/tests/gh13433/gh13433.phpt | 4 --- ext/opcache/tests/gh15021.phpt | 4 --- ext/opcache/tests/gh16577.phpt | 4 --- ext/opcache/tests/gh18567.phpt | 4 --- ext/opcache/tests/gh18639.phpt | 4 --- ext/opcache/tests/gh8133.phpt | 4 --- ext/opcache/tests/gh9968.phpt | 4 --- ext/opcache/tests/jit/bug80634.phpt | 4 --- ext/opcache/tests/jit/bug81256.phpt | 4 --- ext/opcache/tests/jit/gh14082.phpt | 4 --- ext/opcache/tests/jit/gh15490.phpt | 4 --- ext/opcache/tests/jit/gh18898_1.phpt | 4 --- ext/opcache/tests/jit/gh18898_2.phpt | 4 --- ext/opcache/tests/jit/gh8461-007.phpt | 4 --- ext/opcache/tests/jit/gh8591-006.phpt | 4 --- ext/opcache/tests/preload_001.phpt | 4 --- ext/opcache/tests/preload_002.phpt | 4 --- ext/opcache/tests/preload_003.phpt | 4 --- ext/opcache/tests/preload_004.phpt | 4 --- ext/opcache/tests/preload_005.phpt | 4 --- ext/opcache/tests/preload_006.phpt | 1 - ext/opcache/tests/preload_007.phpt | 4 --- ext/opcache/tests/preload_008.phpt | 4 --- ext/opcache/tests/preload_009.phpt | 4 --- ext/opcache/tests/preload_010.phpt | 4 --- ext/opcache/tests/preload_011.phpt | 4 --- ext/opcache/tests/preload_012.phpt | 4 --- ext/opcache/tests/preload_013.phpt | 4 --- ext/opcache/tests/preload_bug79114.phpt | 4 --- ext/opcache/tests/preload_class_alias.phpt | 4 --- ext/opcache/tests/preload_class_alias_2.phpt | 4 --- .../tests/preload_dynamic_def_removal.phpt | 4 --- .../tests/preload_dynamic_function.phpt | 4 --- ext/opcache/tests/preload_early_binding.phpt | 4 --- ext/opcache/tests/preload_enum.phpt | 4 --- ext/opcache/tests/preload_enum_observed.phpt | 4 --- ext/opcache/tests/preload_error_handler.phpt | 4 --- ext/opcache/tests/preload_ind.phpt | 4 --- .../tests/preload_loadable_classes_1.phpt | 4 --- .../tests/preload_loadable_classes_2.phpt | 4 --- .../tests/preload_loadable_classes_3.phpt | 4 --- .../tests/preload_method_static_vars.phpt | 4 --- ext/opcache/tests/preload_optimizer.phpt | 4 --- ext/opcache/tests/preload_parse_error.phpt | 1 - .../tests/preload_prop_info_table.phpt | 4 --- .../tests/preload_static_var_inheritance.phpt | 4 --- ext/opcache/tests/preload_trait_alias.phpt | 4 --- .../tests/preload_trait_multiple_fixup.phpt | 4 --- ext/opcache/tests/preload_trait_static.phpt | 4 --- .../tests/preload_unresolved_prop_type.phpt | 4 --- ext/opcache/tests/preload_user_001.phpt | 2 +- ext/opcache/tests/preload_user_002.phpt | 2 +- ext/opcache/tests/preload_user_003.phpt | 2 +- ext/opcache/tests/preload_user_004.phpt | 2 +- ext/opcache/tests/preload_user_005.phpt | 2 +- ext/opcache/tests/preload_windows.phpt | 17 ------------ .../tests/preloading_no_auto_globals_jit.phpt | 4 --- ext/zend_test/tests/observer_preload.phpt | 4 --- 75 files changed, 13 insertions(+), 300 deletions(-) delete mode 100644 ext/opcache/tests/preload_windows.phpt diff --git a/Zend/tests/attributes/delayed_target_validation/opcache_validator_errors.phpt b/Zend/tests/attributes/delayed_target_validation/opcache_validator_errors.phpt index 68d1ae43bd46a..ba6ea7a41ca44 100644 --- a/Zend/tests/attributes/delayed_target_validation/opcache_validator_errors.phpt +++ b/Zend/tests/attributes/delayed_target_validation/opcache_validator_errors.phpt @@ -7,10 +7,6 @@ opcache.preload={PWD}/opcache_validator_errors.inc opcache.file_cache_only=0 --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --INI-- diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index f0d3379534591..7f8a44e911036 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -139,15 +139,9 @@ static zend_result (*orig_post_startup_cb)(void); static zend_result accel_post_startup(void); static zend_result accel_finish_startup(void); -#ifndef ZEND_WIN32 -# define PRELOAD_SUPPORT -#endif - -#ifdef PRELOAD_SUPPORT static void preload_shutdown(void); static void preload_activate(void); static void preload_restart(void); -#endif #ifdef ZEND_WIN32 # define INCREMENT(v) InterlockedIncrement64(&ZCSG(v)) @@ -2731,11 +2725,9 @@ ZEND_RINIT_FUNCTION(zend_accelerator) } zend_shared_alloc_restore_state(); -#ifdef PRELOAD_SUPPORT if (ZCSG(preload_script)) { preload_restart(); } -#endif #ifdef HAVE_JIT zend_jit_restart(); @@ -2777,11 +2769,9 @@ ZEND_RINIT_FUNCTION(zend_accelerator) zend_jit_activate(); #endif -#ifdef PRELOAD_SUPPORT if (ZCSG(preload_script)) { preload_activate(); } -#endif return SUCCESS; } @@ -3482,11 +3472,9 @@ void accel_shutdown(void) return; } -#ifdef PRELOAD_SUPPORT if (ZCSG(preload_script)) { preload_shutdown(); } -#endif _file_cache_only = file_cache_only; @@ -3599,7 +3587,6 @@ void accelerator_shm_read_unlock(void) } /* Preloading */ -#ifdef PRELOAD_SUPPORT static HashTable *preload_scripts = NULL; static zend_op_array *(*preload_orig_compile_file)(zend_file_handle *file_handle, int type); @@ -4972,6 +4959,7 @@ static zend_result accel_finish_startup_preload(bool in_child) return ret; } +#ifndef ZEND_WIN32 static zend_result accel_finish_startup_preload_subprocess(pid_t *pid) { uid_t euid = geteuid(); @@ -5038,7 +5026,7 @@ static zend_result accel_finish_startup_preload_subprocess(pid_t *pid) return SUCCESS; } -#endif /* ZEND_WIN32 */ +#endif /* !ZEND_WIN32 */ static zend_result accel_finish_startup(void) { @@ -5050,11 +5038,6 @@ static zend_result accel_finish_startup(void) return SUCCESS; } -#ifdef ZEND_WIN32 - zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Preloading is not supported on Windows"); - return FAILURE; -#else /* ZEND_WIN32 */ - if (UNEXPECTED(file_cache_only)) { zend_accel_error(ACCEL_LOG_WARNING, "Preloading doesn't work in \"file_cache_only\" mode"); return SUCCESS; @@ -5070,7 +5053,9 @@ static zend_result accel_finish_startup(void) return SUCCESS; } - +#ifdef ZEND_WIN32 + return accel_finish_startup_preload(false); +#else pid_t pid; if (accel_finish_startup_preload_subprocess(&pid) == FAILURE) { zend_shared_alloc_unlock(); @@ -5104,7 +5089,7 @@ static zend_result accel_finish_startup(void) return FAILURE; } } -#endif /* ZEND_WIN32 */ +#endif /* !ZEND_WIN32 */ } static void accel_activate(void) { diff --git a/ext/opcache/tests/api/opcache_preloading_001.phpt b/ext/opcache/tests/api/opcache_preloading_001.phpt index e30cbbd7d159d..9727ae9334d2c 100644 --- a/ext/opcache/tests/api/opcache_preloading_001.phpt +++ b/ext/opcache/tests/api/opcache_preloading_001.phpt @@ -6,10 +6,6 @@ zend_test opcache.enable=1 opcache.enable_cli=1 opcache.preload={PWD}/opcache_preloading.inc ---SKIPIF-- - --FILE-- --FILE-- diff --git a/ext/opcache/tests/bug78014.phpt b/ext/opcache/tests/bug78014.phpt index df497e6894998..b8f263e8709df 100644 --- a/ext/opcache/tests/bug78014.phpt +++ b/ext/opcache/tests/bug78014.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_bug78014.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- OK --EXPECT-- diff --git a/ext/opcache/tests/bug78175_2.phpt b/ext/opcache/tests/bug78175_2.phpt index a994c3568617d..06539cde6e745 100644 --- a/ext/opcache/tests/bug78175_2.phpt +++ b/ext/opcache/tests/bug78175_2.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_bug78175_2.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- diff --git a/ext/opcache/tests/gh10914.phpt b/ext/opcache/tests/gh10914.phpt index 043eb8a8c7d03..45563255d698c 100644 --- a/ext/opcache/tests/gh10914.phpt +++ b/ext/opcache/tests/gh10914.phpt @@ -7,10 +7,6 @@ opcache.protect_memory=1 opcache.preload={PWD}/preload_gh10914.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --INI-- opcache.enable=1 opcache.enable_cli=1 diff --git a/ext/opcache/tests/jit/gh14082.phpt b/ext/opcache/tests/jit/gh14082.phpt index eba67a096b82c..ff17a304fdc15 100644 --- a/ext/opcache/tests/jit/gh14082.phpt +++ b/ext/opcache/tests/jit/gh14082.phpt @@ -8,10 +8,6 @@ opcache.jit_buffer_size=16M opcache.preload={PWD}/preload_gh14082.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- --FILE-- --INI-- opcache.enable=1 opcache.enable_cli=1 diff --git a/ext/opcache/tests/jit/gh8591-006.phpt b/ext/opcache/tests/jit/gh8591-006.phpt index 0b9cd3fded5f7..2c1e4523fb8df 100644 --- a/ext/opcache/tests/jit/gh8591-006.phpt +++ b/ext/opcache/tests/jit/gh8591-006.phpt @@ -10,10 +10,6 @@ opcache.file_update_protection=0 opcache.revalidate_freq=0 opcache.protect_memory=1 opcache.preload={PWD}/gh8591-006.inc ---SKIPIF-- - --FILE-- --FILE-- --FILE-- getPrototype()->class); diff --git a/ext/opcache/tests/preload_003.phpt b/ext/opcache/tests/preload_003.phpt index a2b2870118020..2f4df35cddfe2 100644 --- a/ext/opcache/tests/preload_003.phpt +++ b/ext/opcache/tests/preload_003.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- --FILE-- diff --git a/ext/opcache/tests/preload_007.phpt b/ext/opcache/tests/preload_007.phpt index 71cdfe444f495..416104f029928 100644 --- a/ext/opcache/tests/preload_007.phpt +++ b/ext/opcache/tests/preload_007.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_include.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- --FILE-- prop); diff --git a/ext/opcache/tests/preload_011.phpt b/ext/opcache/tests/preload_011.phpt index 23bceed19b9ba..6d9f1056bb229 100644 --- a/ext/opcache/tests/preload_011.phpt +++ b/ext/opcache/tests/preload_011.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_variance_ind.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- OK --EXPECT-- diff --git a/ext/opcache/tests/preload_enum.phpt b/ext/opcache/tests/preload_enum.phpt index 55ce7afdb35cf..18783746b0b93 100644 --- a/ext/opcache/tests/preload_enum.phpt +++ b/ext/opcache/tests/preload_enum.phpt @@ -7,10 +7,6 @@ opcache.enable=1 opcache.enable_cli=1 opcache.optimization_level=-1 opcache.preload={PWD}/preload_enum.inc ---SKIPIF-- - --FILE-- --FILE-- --FILE-- ===DONE=== --EXPECTF-- diff --git a/ext/opcache/tests/preload_ind.phpt b/ext/opcache/tests/preload_ind.phpt index f1b6b26ead2ca..f90c5be7d1eb6 100644 --- a/ext/opcache/tests/preload_ind.phpt +++ b/ext/opcache/tests/preload_ind.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_ind.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- OK --EXPECT-- diff --git a/ext/opcache/tests/preload_loadable_classes_1.phpt b/ext/opcache/tests/preload_loadable_classes_1.phpt index 4fd463b49c45b..fc3913a6b3009 100644 --- a/ext/opcache/tests/preload_loadable_classes_1.phpt +++ b/ext/opcache/tests/preload_loadable_classes_1.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_loadable_classes_1.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- diff --git a/ext/opcache/tests/preload_prop_info_table.phpt b/ext/opcache/tests/preload_prop_info_table.phpt index 4c93496bf161e..040dfd39522dc 100644 --- a/ext/opcache/tests/preload_prop_info_table.phpt +++ b/ext/opcache/tests/preload_prop_info_table.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- test()); diff --git a/ext/opcache/tests/preload_trait_alias.phpt b/ext/opcache/tests/preload_trait_alias.phpt index a931d838a2476..7efca2fea92f3 100644 --- a/ext/opcache/tests/preload_trait_alias.phpt +++ b/ext/opcache/tests/preload_trait_alias.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- method(); diff --git a/ext/opcache/tests/preload_trait_static.phpt b/ext/opcache/tests/preload_trait_static.phpt index cbf09c57a07d0..59710188e0407 100644 --- a/ext/opcache/tests/preload_trait_static.phpt +++ b/ext/opcache/tests/preload_trait_static.phpt @@ -7,10 +7,6 @@ opcache.optimization_level=-1 opcache.preload={PWD}/preload_trait_static.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --FILE-- --FILE-- diff --git a/ext/opcache/tests/preload_user_002.phpt b/ext/opcache/tests/preload_user_002.phpt index 90b2be8c27640..a6a7fa3144711 100644 --- a/ext/opcache/tests/preload_user_002.phpt +++ b/ext/opcache/tests/preload_user_002.phpt @@ -12,7 +12,7 @@ opcache posix --SKIPIF-- --FILE-- diff --git a/ext/opcache/tests/preload_user_003.phpt b/ext/opcache/tests/preload_user_003.phpt index 56f69644cb587..8410f46a100a4 100644 --- a/ext/opcache/tests/preload_user_003.phpt +++ b/ext/opcache/tests/preload_user_003.phpt @@ -12,7 +12,7 @@ opcache posix --SKIPIF-- diff --git a/ext/opcache/tests/preload_user_004.phpt b/ext/opcache/tests/preload_user_004.phpt index 71cb5e09cf1c2..5778373598cc8 100644 --- a/ext/opcache/tests/preload_user_004.phpt +++ b/ext/opcache/tests/preload_user_004.phpt @@ -7,7 +7,7 @@ posix --SKIPIF-- --FILE-- diff --git a/ext/opcache/tests/preload_user_005.phpt b/ext/opcache/tests/preload_user_005.phpt index 2276b1a5cf268..6af881db40135 100644 --- a/ext/opcache/tests/preload_user_005.phpt +++ b/ext/opcache/tests/preload_user_005.phpt @@ -7,7 +7,7 @@ posix --SKIPIF-- diff --git a/ext/opcache/tests/preload_windows.phpt b/ext/opcache/tests/preload_windows.phpt deleted file mode 100644 index 24e043d7320c9..0000000000000 --- a/ext/opcache/tests/preload_windows.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Preloading is not supported on Windows ---INI-- -opcache.enable=1 -opcache.enable_cli=1 -opcache.optimization_level=-1 -opcache.preload={PWD}/preload.inc ---EXTENSIONS-- -opcache ---SKIPIF-- - ---FILE-- -Unreachable ---EXPECTF-- -%s: Error Preloading is not supported on Windows diff --git a/ext/opcache/tests/preloading_no_auto_globals_jit.phpt b/ext/opcache/tests/preloading_no_auto_globals_jit.phpt index e57a50e27634d..d4820202eae48 100644 --- a/ext/opcache/tests/preloading_no_auto_globals_jit.phpt +++ b/ext/opcache/tests/preloading_no_auto_globals_jit.phpt @@ -7,10 +7,6 @@ opcache.enable_cli=1 opcache.preload={PWD}/preloading_no_auto_globals_jit.inc --EXTENSIONS-- opcache ---SKIPIF-- - --FILE-- --INI-- opcache.enable=1 opcache.enable_cli=1