Fix opcache jit option parsing in builder

This commit is contained in:
crazywhalecc
2025-08-02 01:29:20 +08:00
parent 17ff5f63bf
commit 22a8191b97
8 changed files with 51 additions and 19 deletions

View File

@@ -51,13 +51,7 @@ class opcache extends Extension
public function getUnixConfigureArg(bool $shared = false): string
{
$version = $this->builder->getPHPVersion();
$opcache_jit = !$this->builder->getOption('disable-opcache-jit', false);
$opcache_jit = $opcache_jit ? '--enable-opcache-jit' : '--disable-opcache-jit';
if (version_compare($version, '8.5.0-dev', '<')) {
return "--enable-opcache {$opcache_jit}";
}
return $opcache_jit;
return '--enable-opcache';
}
public function getDistName(): string

View File

@@ -66,6 +66,17 @@ class LinuxBuilder extends UnixBuilderBase
$phpVersionID = $this->getPHPVersionID();
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
if ($opcache_jit && ($phpVersionID >= 80500 || $this->getExt('opcache'))) {
// php 8.5 contains opcache extension by default,
// if opcache_jit is enabled for 8.5 or opcache enabled,
// we need to disable undefined behavior sanitizer.
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
} elseif ($opcache_jit) {
$opcache_jit = false;
}
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit' : '--disable-opcache-jit';
if ($this->getOption('enable-zts', false)) {
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
$zts = '--enable-zts --disable-zend-signals ';
@@ -73,10 +84,7 @@ class LinuxBuilder extends UnixBuilderBase
$maxExecutionTimers = '';
$zts = '';
}
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
if (!$disable_jit && $this->getExt('opcache')) {
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
}
$config_file_path = $this->getOption('with-config-file-path', false) ?
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
$config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ?
@@ -114,7 +122,7 @@ class LinuxBuilder extends UnixBuilderBase
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
$config_file_path .
$config_file_scan_dir .
$disable_jit .
$opcache_jit_arg .
$json_74 .
$zts .
$maxExecutionTimers .

View File

@@ -102,6 +102,13 @@ class MacOSBuilder extends UnixBuilderBase
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
$zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : '';
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
// disable opcache jit for PHP < 8.5.0 when opcache is not enabled
if ($opcache_jit && $phpVersionID < 80500 && !$this->getExt('opcache')) {
$opcache_jit = false;
}
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit' : '--disable-opcache-jit';
$config_file_path = $this->getOption('with-config-file-path', false) ?
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
$config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ?
@@ -136,6 +143,7 @@ class MacOSBuilder extends UnixBuilderBase
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
$opcache_jit_arg .
$config_file_path .
$config_file_scan_dir .
$json_74 .

View File

@@ -89,6 +89,9 @@ class WindowsBuilder extends BuilderBase
}
}
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit=yes ' : '--enable-opcache-jit=no ';
if (($logo = $this->getOption('with-micro-logo')) !== null) {
// realpath
// $logo = realpath($logo);
@@ -115,6 +118,7 @@ class WindowsBuilder extends BuilderBase
($enableMicro ? ('--enable-micro=yes ' . $micro_logo . $micro_w32) : '--enable-micro=no ') .
($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') .
$config_file_scan_dir .
$opcache_jit_arg .
"{$this->makeStaticExtensionArgs()} " .
$zts .
'"'