diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index cb2791fb45ac..6533f00ede6e 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3724,6 +3724,16 @@ int zend_jit_check_support(void) { int i; +#ifdef ZEND_JIT_USE_APPLE_MAP_JIT + if (!pthread_jit_write_protect_supported_np()) { + zend_accel_error(ACCEL_LOG_WARNING, + "Apple Silicon ZTS JIT requires pthread_jit_write_protect_np() support. JIT disabled."); + JIT_G(enabled) = 0; + JIT_G(on) = 0; + return FAILURE; + } +#endif + if (zend_execute_ex != execute_ex) { if (zend_dtrace_enabled) { zend_error(E_WARNING, "JIT is incompatible with DTrace. JIT disabled."); @@ -3792,11 +3802,6 @@ void zend_jit_startup(void *buf, size_t size, bool reattached) "Unable to share JIT buffer across fork using minherit(): %s (%d)", strerror(error), error); } - if (!pthread_jit_write_protect_supported_np()) { - munmap(buf, size); - zend_accel_error_noreturn(ACCEL_LOG_FATAL, - "Apple Silicon ZTS JIT requires pthread_jit_write_protect_np() support"); - } #endif dasm_buf = buf; diff --git a/ext/opcache/tests/bu69838.phpt b/ext/opcache/tests/bu69838.phpt index 0f83635dca6a..5a697cdbd44f 100644 --- a/ext/opcache/tests/bu69838.phpt +++ b/ext/opcache/tests/bu69838.phpt @@ -14,5 +14,5 @@ $x = gethostbyname("localhost"); ?> ===DONE=== ---EXPECT-- -===DONE=== +--EXPECTF-- +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%r===DONE=== diff --git a/ext/opcache/tests/bug70423.phpt b/ext/opcache/tests/bug70423.phpt index 6015a46b46d3..f641fa67e0ea 100644 --- a/ext/opcache/tests/bug70423.phpt +++ b/ext/opcache/tests/bug70423.phpt @@ -54,8 +54,8 @@ $fn2(); // 5 $fn1(); // 1 $fn2(); // 6 ?> ---EXPECT-- -1 +--EXPECTF-- +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%r1 1 1 1 diff --git a/ext/opcache/tests/bug79665.phpt b/ext/opcache/tests/bug79665.phpt index 7e101f5a008b..720a88191d52 100644 --- a/ext/opcache/tests/bug79665.phpt +++ b/ext/opcache/tests/bug79665.phpt @@ -24,7 +24,7 @@ var_dump($config['directives']['opcache.max_accelerated_files']); %s: Warning opcache.max_wasted_percentage must be set between 1 and 50. -string(1) "5" +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%rstring(1) "5" float(0.05) string(3) "128" int(134217728) diff --git a/ext/opcache/tests/gh9259_001.phpt b/ext/opcache/tests/gh9259_001.phpt index d98cbfb891d7..1153af6ff93c 100644 --- a/ext/opcache/tests/gh9259_001.phpt +++ b/ext/opcache/tests/gh9259_001.phpt @@ -17,4 +17,4 @@ echo 'OK'; --EXPECTF-- %sWarning opcache.interned_strings_buffer must be less than or equal to 32767, 131072 given%s -OK +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%rOK diff --git a/ext/opcache/tests/gh9259_002.phpt b/ext/opcache/tests/gh9259_002.phpt index 8b74949b4946..911374fe4728 100644 --- a/ext/opcache/tests/gh9259_002.phpt +++ b/ext/opcache/tests/gh9259_002.phpt @@ -15,4 +15,4 @@ echo 'OK'; --EXPECTF-- %sWarning opcache.interned_strings_buffer must be greater than or equal to 0, -1 given%s -OK +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%rOK diff --git a/ext/opcache/tests/jit/gh14267_001.phpt b/ext/opcache/tests/jit/gh14267_001.phpt index 52be177b9155..cc914222a4d6 100644 --- a/ext/opcache/tests/jit/gh14267_001.phpt +++ b/ext/opcache/tests/jit/gh14267_001.phpt @@ -12,5 +12,6 @@ opcache ini_set('opcache.jit', 'tracing'); ?> ===DONE=== ---EXPECT-- -===DONE=== +--EXPECTREGEX-- +^(?:Warning: Cannot change opcache\.jit setting at run-time \(JIT is disabled\) in .+ on line 2 +)?===DONE===$ diff --git a/ext/opcache/tests/jit/gh16393.phpt b/ext/opcache/tests/jit/gh16393.phpt index c93b06fda8ce..e07808ba0e9c 100644 --- a/ext/opcache/tests/jit/gh16393.phpt +++ b/ext/opcache/tests/jit/gh16393.phpt @@ -15,4 +15,4 @@ $appendProp2 = (function() { $appendProp2(); ?> --EXPECTF-- -Warning: Undefined variable $test in %sgh16393.php on line 6 +%r(?:Warning: Cannot change opcache\.jit setting at run-time \(JIT is disabled\) in .*gh16393\.php on line 2\n\n)?%rWarning: Undefined variable $test in %sgh16393.php on line 6 diff --git a/ext/opcache/tests/preload_user_001.phpt b/ext/opcache/tests/preload_user_001.phpt index 2a7cb2955441..35cb09d5547c 100644 --- a/ext/opcache/tests/preload_user_001.phpt +++ b/ext/opcache/tests/preload_user_001.phpt @@ -22,7 +22,7 @@ var_dump(function_exists("f2")); ?> OK --EXPECTF-- -%sWarning "opcache.preload_user" is ignored because the current user is not "root" +%r(?:.*: Warning Apple Silicon ZTS JIT requires pthread_jit_write_protect_np\(\) support\. JIT disabled\.\n)?%r%sWarning "opcache.preload_user" is ignored because the current user is not "root" bool(true) bool(false) OK