Refactor opcache JIT handling and version checks in Linux and MacOS builders

This commit is contained in:
crazywhalecc 2025-07-29 10:59:36 +08:00
parent 4efb3dfc9a
commit e9dbeb1e34
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
3 changed files with 33 additions and 7 deletions

View File

@ -26,25 +26,36 @@ class opcache extends Extension
public function patchBeforeBuildconf(): bool
{
$version = $this->builder->getPHPVersion();
if (file_exists(SOURCE_PATH . '/php-src/.opcache_patched')) {
return false;
}
// if 8.2.0 <= PHP_VERSION < 8.2.23, we need to patch from legacy patch file
if (version_compare($this->builder->getPHPVersion(), '8.2.0', '>=') && version_compare($this->builder->getPHPVersion(), '8.2.23', '<')) {
if (version_compare($version, '8.2.0', '>=') && version_compare($version, '8.2.23', '<')) {
SourcePatcher::patchFile('spc_fix_static_opcache_before_80222.patch', SOURCE_PATH . '/php-src');
}
// if 8.3.0 <= PHP_VERSION < 8.3.11, we need to patch from legacy patch file
elseif (version_compare($this->builder->getPHPVersion(), '8.3.0', '>=') && version_compare($this->builder->getPHPVersion(), '8.3.11', '<')) {
elseif (version_compare($version, '8.3.0', '>=') && version_compare($version, '8.3.11', '<')) {
SourcePatcher::patchFile('spc_fix_static_opcache_before_80310.patch', SOURCE_PATH . '/php-src');
} else {
}
// if 8.3.12 <= PHP_VERSION < 8.5.0-dev, we need to patch from legacy patch file
elseif (version_compare($version, '8.5.0-dev', '<')) {
SourcePatcher::patchMicro(items: ['static_opcache']);
}
// PHP 8.5.0-dev and later supports static opcache without patching
else {
return false;
}
return file_put_contents(SOURCE_PATH . '/php-src/.opcache_patched', '1') !== false;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-opcache';
$version = $this->builder->getPHPVersion();
if (version_compare($version, '8.5.0-dev', '<')) {
return '--enable-opcache';
}
return '';
}
public function getDistName(): string

View File

@ -79,7 +79,13 @@ class LinuxBuilder extends UnixBuilderBase
$maxExecutionTimers = '';
$zts = '';
}
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
if ($opcache_jit) {
$opcache_jit = $phpVersionID >= 80500 ? '--enable-opcache-jit ' : '';
} else {
$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') . ' ') : '';
@ -120,7 +126,7 @@ class LinuxBuilder extends UnixBuilderBase
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
$config_file_path .
$config_file_scan_dir .
$disable_jit .
$opcache_jit .
$json_74 .
$zts .
$maxExecutionTimers .

View File

@ -97,9 +97,17 @@ class MacOSBuilder extends UnixBuilderBase
$this->emitPatchPoint('before-php-configure');
SourcePatcher::patchBeforeConfigure($this);
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
$phpVersionID = $this->getPHPVersionID();
$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);
if ($opcache_jit) {
$opcache_jit = $phpVersionID >= 80500 ? '--enable-opcache-jit ' : '';
} else {
$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) ?
@ -138,6 +146,7 @@ class MacOSBuilder extends UnixBuilderBase
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
$config_file_path .
$config_file_scan_dir .
$opcache_jit .
$json_74 .
$zts .
$this->makeStaticExtensionArgs() . ' ' .