diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9cf38d81..a360e54a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -202,6 +202,6 @@ jobs: if: ${{ !startsWith(matrix.os, 'windows-') }} run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }} - - name: Setup tmate session - if: ${{ failure() }} - uses: mxschmitt/action-tmate@v3 +# - name: Setup tmate session +# if: ${{ failure() }} +# uses: mxschmitt/action-tmate@v3 diff --git a/config/ext.json b/config/ext.json index 2cf81b18..817c744a 100644 --- a/config/ext.json +++ b/config/ext.json @@ -488,6 +488,7 @@ "opcache": { "type": "builtin", "arg-type-unix": "custom", + "arg-type-windows": "enable", "zend-extension": true }, "openssl": { diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 6e203779..b73dbbd6 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -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 diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 28edeb22..0f139b4e 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -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 . diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index ce3b7cfb..20a09970 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -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 . diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index fb49a013..ac29ae3a 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -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 . '"' diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index aa12127c..b8f133c4 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -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 FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/build/php.m4', 'PKG_CHECK_MODULES(', 'PKG_CHECK_MODULES_STATIC('); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 22e19c46..76e91529 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -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.2', - '8.3', + // '8.1', + // '8.2', + // '8.3', '8.4', '8.5', 'git', @@ -31,7 +31,7 @@ $test_os = [ // 'ubuntu-24.04', // bin/spc for x86_64 // 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 'ubuntu-24.04-arm', // bin/spc for arm64 - // 'windows-latest', // .\bin\spc.ps1 + 'windows-latest', // .\bin\spc.ps1 ]; // whether enable thread safe