mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-12 03:15:35 +08:00
Refactor opcache JIT handling and version checks in Linux and MacOS builders
This commit is contained in:
@@ -26,25 +26,36 @@ class opcache extends Extension
|
|||||||
|
|
||||||
public function patchBeforeBuildconf(): bool
|
public function patchBeforeBuildconf(): bool
|
||||||
{
|
{
|
||||||
|
$version = $this->builder->getPHPVersion();
|
||||||
if (file_exists(SOURCE_PATH . '/php-src/.opcache_patched')) {
|
if (file_exists(SOURCE_PATH . '/php-src/.opcache_patched')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if 8.2.0 <= PHP_VERSION < 8.2.23, we need to patch from legacy patch file
|
// 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');
|
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
|
// 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');
|
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']);
|
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;
|
return file_put_contents(SOURCE_PATH . '/php-src/.opcache_patched', '1') !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnixConfigureArg(bool $shared = false): string
|
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
|
public function getDistName(): string
|
||||||
|
|||||||
@@ -79,7 +79,13 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$maxExecutionTimers = '';
|
$maxExecutionTimers = '';
|
||||||
$zts = '';
|
$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) ?
|
$config_file_path = $this->getOption('with-config-file-path', false) ?
|
||||||
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
|
('--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 ') .
|
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
|
||||||
$config_file_path .
|
$config_file_path .
|
||||||
$config_file_scan_dir .
|
$config_file_scan_dir .
|
||||||
$disable_jit .
|
$opcache_jit .
|
||||||
$json_74 .
|
$json_74 .
|
||||||
$zts .
|
$zts .
|
||||||
$maxExecutionTimers .
|
$maxExecutionTimers .
|
||||||
|
|||||||
@@ -97,9 +97,17 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
$this->emitPatchPoint('before-php-configure');
|
$this->emitPatchPoint('before-php-configure');
|
||||||
SourcePatcher::patchBeforeConfigure($this);
|
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 ' : '';
|
$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) ?
|
$config_file_path = $this->getOption('with-config-file-path', false) ?
|
||||||
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
|
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
|
||||||
$config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ?
|
$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 ') .
|
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
||||||
$config_file_path .
|
$config_file_path .
|
||||||
$config_file_scan_dir .
|
$config_file_scan_dir .
|
||||||
|
$opcache_jit .
|
||||||
$json_74 .
|
$json_74 .
|
||||||
$zts .
|
$zts .
|
||||||
$this->makeStaticExtensionArgs() . ' ' .
|
$this->makeStaticExtensionArgs() . ' ' .
|
||||||
|
|||||||
Reference in New Issue
Block a user