mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Fix opcache jit option parsing in builder
This commit is contained in:
parent
17ff5f63bf
commit
22a8191b97
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@ -202,6 +202,6 @@ jobs:
|
|||||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||||
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
|
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
|
||||||
|
|
||||||
- name: Setup tmate session
|
# - name: Setup tmate session
|
||||||
if: ${{ failure() }}
|
# if: ${{ failure() }}
|
||||||
uses: mxschmitt/action-tmate@v3
|
# uses: mxschmitt/action-tmate@v3
|
||||||
|
|||||||
@ -488,6 +488,7 @@
|
|||||||
"opcache": {
|
"opcache": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"arg-type-unix": "custom",
|
"arg-type-unix": "custom",
|
||||||
|
"arg-type-windows": "enable",
|
||||||
"zend-extension": true
|
"zend-extension": true
|
||||||
},
|
},
|
||||||
"openssl": {
|
"openssl": {
|
||||||
|
|||||||
@ -51,13 +51,7 @@ class opcache extends Extension
|
|||||||
|
|
||||||
public function getUnixConfigureArg(bool $shared = false): string
|
public function getUnixConfigureArg(bool $shared = false): string
|
||||||
{
|
{
|
||||||
$version = $this->builder->getPHPVersion();
|
return '--enable-opcache';
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDistName(): string
|
public function getDistName(): string
|
||||||
|
|||||||
@ -66,6 +66,17 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$phpVersionID = $this->getPHPVersionID();
|
$phpVersionID = $this->getPHPVersionID();
|
||||||
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
|
$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)) {
|
if ($this->getOption('enable-zts', false)) {
|
||||||
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
|
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
|
||||||
$zts = '--enable-zts --disable-zend-signals ';
|
$zts = '--enable-zts --disable-zend-signals ';
|
||||||
@ -73,10 +84,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$maxExecutionTimers = '';
|
$maxExecutionTimers = '';
|
||||||
$zts = '';
|
$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) ?
|
$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) ?
|
||||||
@ -114,7 +122,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_arg .
|
||||||
$json_74 .
|
$json_74 .
|
||||||
$zts .
|
$zts .
|
||||||
$maxExecutionTimers .
|
$maxExecutionTimers .
|
||||||
|
|||||||
@ -102,6 +102,13 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
|
$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);
|
||||||
|
// 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) ?
|
$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) ?
|
||||||
@ -136,6 +143,7 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
|
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
|
||||||
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
||||||
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
||||||
|
$opcache_jit_arg .
|
||||||
$config_file_path .
|
$config_file_path .
|
||||||
$config_file_scan_dir .
|
$config_file_scan_dir .
|
||||||
$json_74 .
|
$json_74 .
|
||||||
|
|||||||
@ -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) {
|
if (($logo = $this->getOption('with-micro-logo')) !== null) {
|
||||||
// realpath
|
// realpath
|
||||||
// $logo = realpath($logo);
|
// $logo = realpath($logo);
|
||||||
@ -115,6 +118,7 @@ class WindowsBuilder extends BuilderBase
|
|||||||
($enableMicro ? ('--enable-micro=yes ' . $micro_logo . $micro_w32) : '--enable-micro=no ') .
|
($enableMicro ? ('--enable-micro=yes ' . $micro_logo . $micro_w32) : '--enable-micro=no ') .
|
||||||
($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') .
|
($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') .
|
||||||
$config_file_scan_dir .
|
$config_file_scan_dir .
|
||||||
|
$opcache_jit_arg .
|
||||||
"{$this->makeStaticExtensionArgs()} " .
|
"{$this->makeStaticExtensionArgs()} " .
|
||||||
$zts .
|
$zts .
|
||||||
'"'
|
'"'
|
||||||
|
|||||||
@ -69,6 +69,23 @@ class SourcePatcher
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix PHP VS version
|
||||||
|
if ($builder instanceof WindowsBuilder) {
|
||||||
|
// get vs version
|
||||||
|
$vc = \SPC\builder\windows\SystemUtil::findVisualStudio();
|
||||||
|
$vc_matches = match ($vc['version']) {
|
||||||
|
'vs17' => ['VS17', 'Visual C++ 2022'],
|
||||||
|
'vs16' => ['VS16', 'Visual C++ 2019'],
|
||||||
|
default => ['unknown', 'unknown'],
|
||||||
|
};
|
||||||
|
// patch php-src/win32/build/confutils.js
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
SOURCE_PATH . '\php-src\win32\build\confutils.js',
|
||||||
|
'var name = "unknown";',
|
||||||
|
"var name = short ? \"{$vc_matches[0]}\" : \"{$vc_matches[1]}\";return name;"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// patch php-src/build/php.m4 PKG_CHECK_MODULES -> PKG_CHECK_MODULES_STATIC
|
// patch php-src/build/php.m4 PKG_CHECK_MODULES -> PKG_CHECK_MODULES_STATIC
|
||||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/build/php.m4', 'PKG_CHECK_MODULES(', 'PKG_CHECK_MODULES_STATIC(');
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/build/php.m4', 'PKG_CHECK_MODULES(', 'PKG_CHECK_MODULES_STATIC(');
|
||||||
|
|
||||||
|
|||||||
@ -13,9 +13,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
||||||
$test_php_version = [
|
$test_php_version = [
|
||||||
'8.1',
|
// '8.1',
|
||||||
'8.2',
|
// '8.2',
|
||||||
'8.3',
|
// '8.3',
|
||||||
'8.4',
|
'8.4',
|
||||||
'8.5',
|
'8.5',
|
||||||
'git',
|
'git',
|
||||||
@ -31,7 +31,7 @@ $test_os = [
|
|||||||
// 'ubuntu-24.04', // bin/spc for x86_64
|
// 'ubuntu-24.04', // bin/spc for x86_64
|
||||||
// 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
// 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
||||||
'ubuntu-24.04-arm', // bin/spc for arm64
|
'ubuntu-24.04-arm', // bin/spc for arm64
|
||||||
// 'windows-latest', // .\bin\spc.ps1
|
'windows-latest', // .\bin\spc.ps1
|
||||||
];
|
];
|
||||||
|
|
||||||
// whether enable thread safe
|
// whether enable thread safe
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user