From 5f2459ae4332fbaa67589525251b764aced880d9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 15 Jul 2025 21:11:38 +0800 Subject: [PATCH 01/72] Avoid useless exception on startup version mismatch --- src/SPC/builder/BuilderBase.php | 11 ++++++++--- src/SPC/command/BuildPHPCommand.php | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 184d88dc5..b2e6bc09d 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -333,16 +333,21 @@ public function getPHPVersionID(): int throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); } - public function getPHPVersion(): string + public function getPHPVersion(bool $exception_on_failure = true): string { if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + if (!$exception_on_failure) { + return 'unknown'; + } throw new WrongUsageException('PHP source files are not available, you need to download them first'); } $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); if (preg_match('/PHP_VERSION "(.*)"/', $file, $match) !== 0) { return $match[1]; } - + if (!$exception_on_failure) { + return 'unknown'; + } throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); } @@ -360,7 +365,7 @@ public function getPHPVersionFromArchive(?string $file = null): false|string } $file = LockFile::getLockFullPath($lock); } - if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) { + if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+|alpha\d+|beta\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) { return $match[1]; } return false; diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 8bfa4aafe..49f6812da 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -159,7 +159,7 @@ public function handle(): int $indent_texts['UPX Pack'] = 'enabled'; } - $ver = $builder->getPHPVersionFromArchive() ?: $builder->getPHPVersion(); + $ver = $builder->getPHPVersionFromArchive() ?: $builder->getPHPVersion(false); $indent_texts['PHP Version'] = $ver; if (!empty($not_included)) { @@ -269,6 +269,7 @@ public function handle(): int } catch (WrongUsageException $e) { // WrongUsageException is not an exception, it's a user error, so we just print the error message logger()->critical($e->getMessage()); + logger()->error($e->getTraceAsString()); return static::FAILURE; } catch (\Throwable $e) { if ($this->getOption('debug')) { From ec959f6239d3ff1ecaa7f4119796a71d37fa67d6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 15 Jul 2025 21:14:02 +0800 Subject: [PATCH 02/72] Add 8.5 patch support for phpmicro --- src/SPC/store/SourcePatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 54f805b60..a1b75d174 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -133,7 +133,7 @@ public static function patchMicro(?array $items = null): bool } $patch_list = $spc_micro_patches; $patches = []; - $serial = ['80', '81', '82', '83', '84']; + $serial = ['80', '81', '82', '83', '84', '85']; foreach ($patch_list as $patchName) { if (file_exists(SOURCE_PATH . "/php-src/sapi/micro/patches/{$patchName}.patch")) { $patches[] = "sapi/micro/patches/{$patchName}.patch"; From b9e096abfaea702919dce269a2e7c69f2e476eaa Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 15 Jul 2025 21:14:15 +0800 Subject: [PATCH 03/72] Download alpha version for 8.5 --- src/SPC/store/source/PhpSource.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 5b4fd0972..d3e9de430 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -19,8 +19,12 @@ class PhpSource extends CustomSourceBase */ public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void { - $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.3'; - Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force); + $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4'; + if ($major === '8.5') { + Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~daniels/php-8.5.0alpha1.tar.xz'], $force); + } else { + Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force); + } } /** From 88cf0184cc7853394da39ac33086ee36c9c7135b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 15 Jul 2025 21:57:06 +0800 Subject: [PATCH 04/72] extension test --- .github/workflows/ext-matrix-tests.yml | 4 ++-- src/globals/test-extensions.php | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index 1c04f5c93..557024b1c 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -82,9 +82,9 @@ jobs: - zlib - zstd php-version: - - "8.4" + - "8.5" operating-system: - - "ubuntu-latest" + - "ubuntu-24.04" #- "macos-13" #- "debian-arm64-self-hosted" - "macos-14" diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 86b53b8dc..31a0515a3 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,18 +13,19 @@ // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - '8.1', - '8.2', - '8.3', - '8.4', + // '8.1', + // '8.2', + // '8.3', + // '8.4', + '8.5', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - // 'macos-13', // bin/spc for x86_64 + 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 'macos-15', // bin/spc for arm64 - 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 + // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 'ubuntu-24.04', // bin/spc for x86_64 // 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 @@ -33,7 +34,7 @@ ]; // whether enable thread safe -$zts = true; +$zts = false; $no_strip = false; @@ -44,7 +45,7 @@ $frankenphp = false; // prefer downloading pre-built packages to speed up the build process -$prefer_pre_built = true; +$prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { @@ -54,7 +55,7 @@ // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'uv', + 'Linux' => '', 'Darwin' => '', 'Windows' => '', }; @@ -72,7 +73,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'common', + 'Linux', 'Darwin' => 'bulk', 'Windows' => 'none', }; From d3f8e94fe919ae3a4ccbecb47d05dfb2310a6702 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 15 Jul 2025 21:57:49 +0800 Subject: [PATCH 05/72] Use new branch of micro, extension test --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index b3c9cd621..32f8d7c6f 100644 --- a/config/source.json +++ b/config/source.json @@ -694,7 +694,7 @@ "micro": { "type": "git", "path": "php-src/sapi/micro", - "rev": "84beta", + "rev": "master", "url": "https://github.com/static-php/phpmicro", "license": { "type": "file", From 1ce3ba0f308c3d3aa9ce485cc7c4a84aa2be39c2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 15 Jul 2025 22:08:10 +0800 Subject: [PATCH 06/72] Update docs and READMEs --- README-zh.md | 21 +++++++++++---------- README.md | 4 +++- docs/.vitepress/components/CliGenerator.vue | 1 + docs/en/guide/index.md | 2 +- docs/en/guide/manual-build.md | 4 ++-- docs/zh/guide/index.md | 2 +- docs/zh/guide/manual-build.md | 4 ++-- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/README-zh.md b/README-zh.md index 0a0c45780..46a66932d 100755 --- a/README-zh.md +++ b/README-zh.md @@ -82,16 +82,17 @@ static-php-cli(简称 `spc`)有许多特性: > > :x: 不支持 -| PHP Version | Status | Comment | -|-------------|--------------------|----------------------------------------------| -| 7.2 | :x: | | -| 7.3 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | -| 7.4 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | -| 8.0 | :warning: | PHP 官方已停止 8.0 的维护,我们不再处理 8.0 相关的 backport 支持 | -| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新 | -| 8.2 | :heavy_check_mark: | | -| 8.3 | :heavy_check_mark: | | -| 8.4 | :heavy_check_mark: | | +| PHP Version | Status | Comment | +|-------------|--------------------|---------------------------------------------------------| +| 7.2 | :x: | | +| 7.3 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | +| 7.4 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | +| 8.0 | :warning: | PHP 官方已停止 8.0 的维护,我们不再处理 8.0 相关的 backport 支持 | +| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新,在 8.5 发布后我们不再处理 8.1 相关的 backport 支持 | +| 8.2 | :heavy_check_mark: | | +| 8.3 | :heavy_check_mark: | | +| 8.4 | :heavy_check_mark: | | +| 8.5 | :heavy_check_mark: | | > 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。 diff --git a/README.md b/README.md index 46200f09f..451146591 100755 --- a/README.md +++ b/README.md @@ -95,10 +95,12 @@ Currently supported PHP versions for compilation: | 7.3 | :x: | phpmicro and some extensions not supported on 7.x | | 7.4 | :x: | phpmicro and some extensions not supported on 7.x | | 8.0 | :warning: | PHP official has stopped maintenance of 8.0, we no longer provide backport support for version 8.0 | -| 8.1 | :heavy_check_mark: | PHP official has security fixes only | +| 8.1 | :heavy_check_mark: | PHP official has security fixes only, we no longer provide backport support when 8.5 released | | 8.2 | :heavy_check_mark: | | | 8.3 | :heavy_check_mark: | | | 8.4 | :heavy_check_mark: | | +| 8.5 (alpha) | :heavy_check_mark: | | + > This table shows the support status for static-php-cli in building the corresponding version, > not the official PHP support status for that version. diff --git a/docs/.vitepress/components/CliGenerator.vue b/docs/.vitepress/components/CliGenerator.vue index ad17783ac..f9f3613d1 100644 --- a/docs/.vitepress/components/CliGenerator.vue +++ b/docs/.vitepress/components/CliGenerator.vue @@ -238,6 +238,7 @@ const availablePhpVersions = [ '8.2', '8.3', '8.4', + '8.5', ]; const I18N = { diff --git a/docs/en/guide/index.md b/docs/en/guide/index.md index 9f9bee4cd..253562b53 100644 --- a/docs/en/guide/index.md +++ b/docs/en/guide/index.md @@ -32,7 +32,7 @@ Windows currently only supports the x86_64 architecture, and does not support 32 ## Supported PHP Version -Currently, static php cli supports PHP versions 8.1 to 8.4, and theoretically supports PHP 8.0 and earlier versions. +Currently, static php cli supports PHP versions 8.1 to 8.5, and theoretically supports PHP 8.0 and earlier versions. Simply select the earlier version when downloading. However, due to some extensions and special components that have stopped supporting earlier versions of PHP, static-php-cli will not explicitly support earlier versions. diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md index e8e4510e4..afaaaf752 100644 --- a/docs/en/guide/manual-build.md +++ b/docs/en/guide/manual-build.md @@ -242,8 +242,8 @@ Also, it is available when downloading with the `--for-extensions` option. ```bash -# Specifying to download a beta version of PHP8.3 -bin/spc download --all -U "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz" +# Specifying to download a alpha version of PHP 8.5 +bin/spc download --all -U "php-src:https://downloads.php.net/~daniels/php-8.5.0alpha1.tar.xz" # Specifying to download an older version of the curl library bin/spc download --all -U "curl:https://curl.se/download/curl-7.88.1.tar.gz" diff --git a/docs/zh/guide/index.md b/docs/zh/guide/index.md index eb0674c3e..7462c155d 100644 --- a/docs/zh/guide/index.md +++ b/docs/zh/guide/index.md @@ -29,6 +29,6 @@ Windows 目前只支持 x86_64 架构,不支持 32 位 x86、不支持 arm64 ## PHP 支持版本 -目前,static-php-cli 对 PHP 8.1 ~ 8.4 版本是支持的,对于 PHP 8.0 及更早版本理论上支持,只需下载时选择早期版本即可。 +目前,static-php-cli 对 PHP 8.1 ~ 8.5 版本是支持的,对于 PHP 8.0 及更早版本理论上支持,只需下载时选择早期版本即可。 但由于部分扩展和特殊组件已对早期版本的 PHP 停止了支持,所以 static-php-cli 不会明确支持早期版本。 我们推荐你编译尽可能新的 PHP 版本,以获得更好的体验。 diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md index 5301fca14..0f7c56896 100644 --- a/docs/zh/guide/manual-build.md +++ b/docs/zh/guide/manual-build.md @@ -209,8 +209,8 @@ bin/spc download --from-zip=/path/to/your/download.zip 让下载器强制使用你指定的链接下载此 source 的包。使用方法为 `{source-name}:{url}` 即可,可同时重写多个库的下载地址。在使用 `--for-extensions` 选项下载时同样可用。 ```bash -# 例如:指定下载测试版的 PHP8.3 -bin/spc download --all -U "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz" +# 例如:指定下载 Alpha 版的 PHP8.5 +bin/spc download --all -U "php-src:https://downloads.php.net/~daniels/php-8.5.0alpha1.tar.xz" # 指定下载旧版本的 curl 库 bin/spc download --all -U "curl:https://curl.se/download/curl-7.88.1.tar.gz" From f0612591be642557eda8fe719eee58f966c6cdb0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 15 Jul 2025 23:31:26 +0800 Subject: [PATCH 07/72] Test bulk (without amqp, swoole) and spc-max --- src/globals/test-extensions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index daec8d490..98ecdea49 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -16,7 +16,7 @@ // '8.1', // '8.2', // '8.3', - // '8.4', + '8.4', '8.5', ]; @@ -25,12 +25,12 @@ 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 'macos-15', // bin/spc for arm64 - // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 - 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 - '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 + 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 + // 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 + // '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 ]; // whether enable thread safe @@ -49,8 +49,8 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'imap,swoole', - 'Windows' => 'intl', + 'Linux', 'Darwin' => 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,opentelemetry,pcntl,pdo,pdo_mysql,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib', + 'Windows' => 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,ds,exif,ffi,fileinfo,filter,ftp,gd,iconv,igbinary,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_sqlite,pdo_sqlsrv,phar,rar,redis,session,shmop,simdjson,simplexml,soap,sockets,sqlite3,sqlsrv,ssh2,sysvshm,tokenizer,xml,xmlreader,xmlwriter,yac,yaml,zip,zlib', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). @@ -73,7 +73,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'bulk', + 'Linux', 'Darwin' => 'none', 'Windows' => 'none', }; From 85e89e4326107765ee847988c2ab80c6f7658479 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 10:17:14 +0800 Subject: [PATCH 08/72] alpha2 --- docs/en/guide/manual-build.md | 2 +- docs/zh/guide/manual-build.md | 2 +- src/SPC/store/source/PhpSource.php | 2 +- src/globals/test-extensions.php | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md index afaaaf752..e9afaa4cc 100644 --- a/docs/en/guide/manual-build.md +++ b/docs/en/guide/manual-build.md @@ -243,7 +243,7 @@ Also, it is available when downloading with the `--for-extensions` option. ```bash # Specifying to download a alpha version of PHP 8.5 -bin/spc download --all -U "php-src:https://downloads.php.net/~daniels/php-8.5.0alpha1.tar.xz" +bin/spc download --all -U "php-src:https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz" # Specifying to download an older version of the curl library bin/spc download --all -U "curl:https://curl.se/download/curl-7.88.1.tar.gz" diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md index 0f7c56896..dcc9d255f 100644 --- a/docs/zh/guide/manual-build.md +++ b/docs/zh/guide/manual-build.md @@ -210,7 +210,7 @@ bin/spc download --from-zip=/path/to/your/download.zip ```bash # 例如:指定下载 Alpha 版的 PHP8.5 -bin/spc download --all -U "php-src:https://downloads.php.net/~daniels/php-8.5.0alpha1.tar.xz" +bin/spc download --all -U "php-src:https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz" # 指定下载旧版本的 curl 库 bin/spc download --all -U "curl:https://curl.se/download/curl-7.88.1.tar.gz" diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index d3e9de430..2a6ae2684 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -21,7 +21,7 @@ public function fetch(bool $force = false, ?array $config = null, int $lock_as = { $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4'; if ($major === '8.5') { - Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~daniels/php-8.5.0alpha1.tar.xz'], $force); + Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz'], $force); } else { Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force); } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 4d1f7d2aa..857c66b30 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -16,7 +16,8 @@ // '8.1', // '8.2', // '8.3', - '8.4', + // '8.4', + '8.5', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) @@ -48,7 +49,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'grpc', + 'Linux', 'Darwin' => 'bcmath', 'Windows' => 'curl', }; @@ -72,7 +73,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'none', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', }; From 973c8f082f4965bbeaa8ea4ee4537082d90a5352 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 15:36:53 +0800 Subject: [PATCH 09/72] Add php-src git version support --- src/SPC/command/DownloadCommand.php | 9 +++------ src/SPC/store/source/PhpSource.php | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index dfa4c9eea..ddcb50ae1 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -108,12 +108,9 @@ public function handle(): int // Define PHP major version $ver = $this->php_major_ver = $this->getOption('with-php'); define('SPC_BUILD_PHP_VERSION', $ver); - // match x.y - preg_match('/^\d+\.\d+$/', $ver, $matches); - if (!$matches) { - // match x.y.z - preg_match('/^\d+\.\d+\.\d+$/', $ver, $matches); - if (!$matches) { + if ($ver !== 'git' && !preg_match('/^\d+\.\d+$/', $ver)) { + // If not git, we need to check the version format + if (!preg_match('/^\d+\.\d+(\.\d+)?$/', $ver)) { logger()->error("bad version arg: {$ver}, x.y or x.y.z required!"); return static::FAILURE; } diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 2a6ae2684..e877169db 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -22,6 +22,8 @@ public function fetch(bool $force = false, ?array $config = null, int $lock_as = $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4'; if ($major === '8.5') { Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz'], $force); + } elseif ($major === 'git') { + Downloader::downloadSource('php-src', ['type' => 'git', 'url' => 'https://github.com/php/php-src.git', 'rev' => 'master'], $force); } else { Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force); } From 0696acb9c55cc13789539510969096e424e4249f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 15:54:55 +0800 Subject: [PATCH 10/72] Add support for re2c in tool checklists and environment setup --- bin/spc-alpine-docker | 1 + src/SPC/doctor/item/LinuxToolCheckList.php | 6 +++--- src/SPC/doctor/item/MacOSToolCheckList.php | 1 + src/SPC/util/GlobalEnvManager.php | 10 ++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index 18e981f81..204273e33 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -104,6 +104,7 @@ RUN apk update; \ m4 \ make \ pkgconfig \ + re2c \ wget \ xz \ gettext-dev \ diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 51e191bfa..3d441bf38 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -16,7 +16,7 @@ class LinuxToolCheckList use UnixSystemUtilTrait; public const TOOLS_ALPINE = [ - 'make', 'bison', 'flex', + 'make', 'bison', 're2c', 'flex', 'git', 'autoconf', 'automake', 'gettext-dev', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', @@ -26,7 +26,7 @@ class LinuxToolCheckList ]; public const TOOLS_DEBIAN = [ - 'make', 'bison', 'flex', + 'make', 'bison', 're2c', 'flex', 'git', 'autoconf', 'automake', 'autopoint', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', @@ -35,7 +35,7 @@ class LinuxToolCheckList ]; public const TOOLS_RHEL = [ - 'perl', 'make', 'bison', 'flex', + 'perl', 'make', 'bison', 're2c', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'gcc', 'bzip2', 'cmake', 'patch', 'which', diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index b4043a1d3..b2dee2b51 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -19,6 +19,7 @@ class MacOSToolCheckList 'curl', 'make', 'bison', + 're2c', 'flex', 'pkg-config', 'git', diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 23ae242dc..c499488c5 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -4,6 +4,7 @@ namespace SPC\util; +use SPC\builder\macos\SystemUtil; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\toolchain\ToolchainManager; @@ -111,6 +112,15 @@ public static function afterInit(): void if (!filter_var(getenv('SPC_SKIP_TOOLCHAIN_CHECK'), FILTER_VALIDATE_BOOL)) { ToolchainManager::afterInitToolchain(); } + // test bison + if (PHP_OS_FAMILY === 'Darwin') { + if ($bison = SystemUtil::findCommand('bison', ['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin'])) { + self::putenv("BISON={$bison}"); + } + if ($yacc = SystemUtil::findCommand('yacc', ['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin'])) { + self::putenv("YACC={$yacc}"); + } + } } /** From 1ae0752933d542cb68fb0d9209e7e9fe38462b55 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 15:58:07 +0800 Subject: [PATCH 11/72] Trigger full extension test --- .github/workflows/ext-matrix-tests.yml | 2 +- src/globals/test-extensions.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index 822b95d7b..df6268edc 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -82,7 +82,7 @@ jobs: - zlib - zstd php-version: - - "8.5" + - "git" operating-system: - "ubuntu-24.04" #- "macos-13" diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 857c66b30..df222fa31 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -17,12 +17,12 @@ // '8.2', // '8.3', // '8.4', - '8.5', + 'git', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - // 'macos-13', // bin/spc for x86_64 + 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 'macos-15', // bin/spc for arm64 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 @@ -30,7 +30,7 @@ // '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 From b9bec5b52660c8f8526afd8775cd7852c69c7640 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 16:00:32 +0800 Subject: [PATCH 12/72] Whoops, extension test --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 7628f6673..85cda2a1b 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -265,7 +265,7 @@ protected function buildEmbed(): void ->exec('sed -i "s|^EXTENSION_DIR = .*|EXTENSION_DIR = /' . basename(BUILD_MODULES_PATH) . '|" Makefile') ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); - $ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'); + $ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: ''; if (preg_match('/-release\s+(\S+)/', $ldflags, $matches)) { $release = $matches[1]; $realLibName = 'libphp-' . $release . '.so'; From 4efb3dfc9a8d31806b08b84c54eefb575285080e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 28 Jul 2025 16:47:04 +0800 Subject: [PATCH 13/72] Add check for Bison version in MacOS tool checklist, trigger extension test --- src/SPC/doctor/item/MacOSToolCheckList.php | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index b2dee2b51..d1a8270a0 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -62,6 +62,30 @@ public function checkCliTools(): ?CheckResult return CheckResult::ok(); } + #[AsCheckItem('if bison version is 3.0 or later', limit_os: 'Darwin')] + public function checkBisonVersion(array $command_path = []): ?CheckResult + { + // if the bison command is /usr/bin/bison, it is the system bison that may be too old + if (($bison = $this->findCommand('bison', $command_path)) === null) { + return CheckResult::fail('bison is not installed or too old', 'build-tools', [['bison']]); + } + // check version: bison (GNU Bison) x.y(.z) + $version = shell()->execWithResult("{$bison} --version", false); + if (preg_match('/bison \(GNU Bison\) (\d+)\.(\d+)(?:\.(\d+))?/', $version[1][0], $matches)) { + $major = (int) $matches[1]; + // major should be 3 or later + if ($major < 3) { + // find homebrew keg-only bison + if ($command_path !== []) { + return CheckResult::fail("Current {$bison} version is too old: " . $matches[0]); + } + return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin']); + } + return CheckResult::ok($matches[0]); + } + return CheckResult::fail('bison version cannot be determined'); + } + #[AsFixItem('brew')] public function fixBrew(): bool { From e9dbeb1e34519995fa93993867d0c32c4c20731c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 29 Jul 2025 10:59:36 +0800 Subject: [PATCH 14/72] Refactor opcache JIT handling and version checks in Linux and MacOS builders --- src/SPC/builder/extension/opcache.php | 19 +++++++++++++++---- src/SPC/builder/linux/LinuxBuilder.php | 10 ++++++++-- src/SPC/builder/macos/MacOSBuilder.php | 11 ++++++++++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 5d9dda0ad..d982978fd 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -26,25 +26,36 @@ public function validate(): void 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 diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 85cda2a1b..6a0766ab2 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -79,7 +79,13 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $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 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . $config_file_path . $config_file_scan_dir . - $disable_jit . + $opcache_jit . $json_74 . $zts . $maxExecutionTimers . diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 9b131b9d6..50353e32c 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -97,9 +97,17 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $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 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $config_file_path . $config_file_scan_dir . + $opcache_jit . $json_74 . $zts . $this->makeStaticExtensionArgs() . ' ' . From ed67393d33cf0ba8cabf8392225f60fb078b4fb2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 29 Jul 2025 11:22:58 +0800 Subject: [PATCH 15/72] Move opcache JIT handling from Linux and MacOS builders to Extension --- src/SPC/builder/extension/opcache.php | 6 ++++-- src/SPC/builder/linux/LinuxBuilder.php | 7 ------- src/SPC/builder/macos/MacOSBuilder.php | 8 -------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index d982978fd..6e2037792 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -52,10 +52,12 @@ public function patchBeforeBuildconf(): bool 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'; + return "--enable-opcache {$opcache_jit}"; } - return ''; + return $opcache_jit; } public function getDistName(): string diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 6a0766ab2..db2510711 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -80,13 +80,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $zts = ''; } - $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) ? diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 50353e32c..44b0d0c33 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -101,13 +101,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $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) ? @@ -146,7 +139,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $config_file_path . $config_file_scan_dir . - $opcache_jit . $json_74 . $zts . $this->makeStaticExtensionArgs() . ' ' . From 9ed3c8b4987397ea246a2fd63baf5efb83edea3c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 29 Jul 2025 11:25:06 +0800 Subject: [PATCH 16/72] phpstan --- src/SPC/builder/linux/LinuxBuilder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index db2510711..b3bd27851 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -119,7 +119,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . $config_file_path . $config_file_scan_dir . - $opcache_jit . $json_74 . $zts . $maxExecutionTimers . From 5f5d934d58860f39e597c0c457a9382ea83cc247 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 30 Jul 2025 23:02:28 +0800 Subject: [PATCH 17/72] Add openssl argon2 password hash support for PHP 8.5 --- src/SPC/builder/extension/openssl.php | 10 +++++++++- src/SPC/builder/linux/library/openssl.php | 4 ++-- src/SPC/builder/macos/library/openssl.php | 2 ++ src/SPC/builder/unix/library/openssl.php | 21 +++++++++++++++++++++ src/globals/ext-tests/openssl.php | 3 +++ 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/SPC/builder/unix/library/openssl.php diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index fc4831f30..08df47f7f 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -26,6 +26,14 @@ public function patchBeforeMake(): bool public function getUnixConfigureArg(bool $shared = false): string { $openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH; - return '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; + $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; + if ( + $this->builder->getPHPVersionID() >= 80500 && + ($ver = $this->builder->getLib('openssl')->getLibVersion()) && + version_compare($ver, '3.2.0', '>=') + ) { + $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"'; + } + return $args; } } diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 51633ac23..401bb3d75 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -29,6 +29,8 @@ class openssl extends LinuxLibraryBase { + use \SPC\builder\unix\library\openssl; + public const NAME = 'openssl'; /** @@ -38,8 +40,6 @@ class openssl extends LinuxLibraryBase */ public function build(): void { - [,,$destdir] = SEPARATED_PATH; - $extra = ''; $ex_lib = '-ldl -pthread'; $arch = getenv('SPC_ARCH'); diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index c1826b5c5..3edc15e7a 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -28,6 +28,8 @@ class openssl extends MacOSLibraryBase { + use \SPC\builder\unix\library\openssl; + public const NAME = 'openssl'; /** diff --git a/src/SPC/builder/unix/library/openssl.php b/src/SPC/builder/unix/library/openssl.php new file mode 100644 index 000000000..4acef78c1 --- /dev/null +++ b/src/SPC/builder/unix/library/openssl.php @@ -0,0 +1,21 @@ +source_dir}/VERSION.dat")) { + // parse as INI + $version = parse_ini_file("{$this->source_dir}/VERSION.dat"); + if ($version !== false) { + return "{$version['MAJOR']}.{$version['MINOR']}.{$version['PATCH']}"; + } + } + return null; + } +} diff --git a/src/globals/ext-tests/openssl.php b/src/globals/ext-tests/openssl.php index 0453101a6..79c863235 100644 --- a/src/globals/ext-tests/openssl.php +++ b/src/globals/ext-tests/openssl.php @@ -7,3 +7,6 @@ if (file_exists('/etc/ssl/openssl.cnf')) { assert(file_get_contents('https://captive.apple.com/') !== false); } +if (PHP_VERSION_ID >= 80500 && defined('OPENSSL_VERSION_NUMBER') && OPENSSL_VERSION_NUMBER >= 0x30200000) { + assert(function_exists('openssl_password_hash')); +} From af10cacdffbcd7518c4ae1e44db4163adaee8746 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 30 Jul 2025 23:23:12 +0800 Subject: [PATCH 18/72] Add openssl version getter for Windows, test openssl --- src/SPC/builder/extension/openssl.php | 13 ++++++++ src/SPC/builder/linux/library/openssl.php | 2 +- src/SPC/builder/macos/library/openssl.php | 2 +- src/SPC/builder/traits/openssl.php | 38 +++++++++++++++++++++++ src/SPC/builder/unix/library/openssl.php | 21 ------------- src/SPC/util/PkgConfigUtil.php | 15 +++++++++ src/globals/test-extensions.php | 8 ++--- 7 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 src/SPC/builder/traits/openssl.php delete mode 100644 src/SPC/builder/unix/library/openssl.php diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index 08df47f7f..e95298fa8 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -36,4 +36,17 @@ public function getUnixConfigureArg(bool $shared = false): string } return $args; } + + public function getWindowsConfigureArg(bool $shared = false): string + { + $args = '--with-openssl'; + if ( + $this->builder->getPHPVersionID() >= 80500 && + ($ver = $this->builder->getLib('openssl')->getLibVersion()) && + version_compare($ver, '3.2.0', '>=') + ) { + $args .= ' --with-openssl-argon2'; + } + return $args; + } } diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 401bb3d75..2a3ed9be8 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -29,7 +29,7 @@ class openssl extends LinuxLibraryBase { - use \SPC\builder\unix\library\openssl; + use \SPC\builder\traits\openssl; public const NAME = 'openssl'; diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 3edc15e7a..df0f4a526 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -28,7 +28,7 @@ class openssl extends MacOSLibraryBase { - use \SPC\builder\unix\library\openssl; + use \SPC\builder\traits\openssl; public const NAME = 'openssl'; diff --git a/src/SPC/builder/traits/openssl.php b/src/SPC/builder/traits/openssl.php new file mode 100644 index 000000000..47becc99e --- /dev/null +++ b/src/SPC/builder/traits/openssl.php @@ -0,0 +1,38 @@ +source_dir}/VERSION.dat")) { + // parse as INI + $version = parse_ini_file("{$this->source_dir}/VERSION.dat"); + if ($version !== false) { + return "{$version['MAJOR']}.{$version['MINOR']}.{$version['PATCH']}"; + } + } + // get openssl version from pkg-config + if (PHP_OS_FAMILY !== 'Windows') { + try { + return PkgConfigUtil::getModuleVersion('openssl'); + } catch (RuntimeException) { + } + } + // get openssl version from header openssl/opensslv.h + if (file_exists(BUILD_INCLUDE_PATH . '/openssl/opensslv.h')) { + if (preg_match('/OPENSSL_VERSION_STR "(.*)"/', FileSystem::readFile(BUILD_INCLUDE_PATH . '/openssl/opensslv.h'), $match)) { + return $match[1]; + } + } + return null; + } +} diff --git a/src/SPC/builder/unix/library/openssl.php b/src/SPC/builder/unix/library/openssl.php deleted file mode 100644 index 4acef78c1..000000000 --- a/src/SPC/builder/unix/library/openssl.php +++ /dev/null @@ -1,21 +0,0 @@ -source_dir}/VERSION.dat")) { - // parse as INI - $version = parse_ini_file("{$this->source_dir}/VERSION.dat"); - if ($version !== false) { - return "{$version['MAJOR']}.{$version['MINOR']}.{$version['PATCH']}"; - } - } - return null; - } -} diff --git a/src/SPC/util/PkgConfigUtil.php b/src/SPC/util/PkgConfigUtil.php index 87075b498..94aaf6c2e 100644 --- a/src/SPC/util/PkgConfigUtil.php +++ b/src/SPC/util/PkgConfigUtil.php @@ -8,6 +8,21 @@ class PkgConfigUtil { + /** + * Returns the version of a module. + * This method uses `pkg-config --modversion` to get the version of the specified module. + * If the module is not found, it will throw a RuntimeException. + * + * @param string $pkg_config_str .pc file str, accepts multiple files + * @return string version string, e.g. "1.2.3" + * @throws RuntimeException + */ + public static function getModuleVersion(string $pkg_config_str): string + { + $result = self::execWithResult("pkg-config --modversion {$pkg_config_str}"); + return trim($result); + } + /** * Returns --cflags-only-other output. * The reason we return the string is we cannot use array_unique() on cflags, diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index df222fa31..a5b3a9d7b 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -16,7 +16,7 @@ // '8.1', // '8.2', // '8.3', - // '8.4', + '8.4', 'git', ]; @@ -49,8 +49,8 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'bcmath', - 'Windows' => 'curl', + 'Linux', 'Darwin' => 'openssl', + 'Windows' => 'openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). @@ -73,7 +73,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'common', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; From 0dfa6e63bdfcbcf0d2ac6c0b253153380e006b5d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 30 Jul 2025 23:23:27 +0800 Subject: [PATCH 19/72] Fix dev:lib-version command with dependencies --- src/SPC/command/dev/LibVerCommand.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/command/dev/LibVerCommand.php b/src/SPC/command/dev/LibVerCommand.php index 717fd155f..246618e46 100644 --- a/src/SPC/command/dev/LibVerCommand.php +++ b/src/SPC/command/dev/LibVerCommand.php @@ -8,6 +8,7 @@ use SPC\command\BaseCommand; use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -41,7 +42,10 @@ public function handle(): int return static::FAILURE; } - $builder->proveLibs([$this->getArgument('library')]); + // parse the dependencies + [, $libs] = DependencyUtil::getExtsAndLibs([], [$this->getArgument('library')]); + + $builder->proveLibs($libs); // Check whether lib is extracted if (!is_dir(SOURCE_PATH . '/' . $this->getArgument('library'))) { @@ -51,7 +55,7 @@ public function handle(): int $version = $builder->getLib($this->getArgument('library'))->getLibVersion(); if ($version === null) { - $this->output->writeln("Failed to get version of library {$this->getArgument('library')}"); + $this->output->writeln("Failed to get version of library {$this->getArgument('library')}. The version getter for [{$this->getArgument('library')}] is not implemented."); return static::FAILURE; } $this->output->writeln("{$version}"); From 5f33a07f4cad8037446d5d0e194116b33eb73d15 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 30 Jul 2025 23:57:52 +0800 Subject: [PATCH 20/72] Fix windows builds when unix configure does not exist --- src/SPC/builder/extension/bz2.php | 3 +++ src/SPC/store/SourcePatcher.php | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/bz2.php b/src/SPC/builder/extension/bz2.php index 88f22e568..c5e6fc674 100644 --- a/src/SPC/builder/extension/bz2.php +++ b/src/SPC/builder/extension/bz2.php @@ -20,6 +20,9 @@ class bz2 extends Extension */ public function patchBeforeConfigure(): bool { + if (!is_unix()) { + return false; + } $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lbz2/', $this->getLibFilesString() . $frameworks); return true; diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index a1b75d174..c3af408cb 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -98,7 +98,9 @@ public static function patchBeforeConfigure(BuilderBase $builder): void } } // patch capstone - FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); + if (is_unix()) { + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); + } } /** From fcdb029b10887974f3234d0f7b891cde397c6654 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 00:07:23 +0800 Subject: [PATCH 21/72] Install re2c manually in gnu docker --- bin/spc-gnu-docker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index 1a9e7e032..0dbe44e86 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -3,7 +3,7 @@ set -e # This file is using docker to run commands -SPC_DOCKER_VERSION=v4 +SPC_DOCKER_VERSION=v5 # Detect docker can run if ! which docker >/dev/null; then @@ -128,6 +128,9 @@ RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.ta make && \ make install && \ ln -sf /usr/local/bin/automake /usr/bin/automake + +RUN curl -o re2c.rpm https://archives.fedoraproject.org/pub/archive/epel/7/$SPC_USE_ARCH/Packages/r/re2c-0.14.3-2.el7.$SPC_USE_ARCH.rpm && \ + rpm -Uvh re2c.rpm EOF fi From cb0ea67a2857f07527cb28a23dfd2163d3625119 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 00:09:13 +0800 Subject: [PATCH 22/72] Fix x86_64 macOS bison finder path --- src/SPC/doctor/item/MacOSToolCheckList.php | 2 +- src/SPC/util/GlobalEnvManager.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index d1a8270a0..249b618e6 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -79,7 +79,7 @@ public function checkBisonVersion(array $command_path = []): ?CheckResult if ($command_path !== []) { return CheckResult::fail("Current {$bison} version is too old: " . $matches[0]); } - return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin']); + return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin']); } return CheckResult::ok($matches[0]); } diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index c499488c5..c6b4f6669 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -114,10 +114,10 @@ public static function afterInit(): void } // test bison if (PHP_OS_FAMILY === 'Darwin') { - if ($bison = SystemUtil::findCommand('bison', ['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin'])) { + if ($bison = SystemUtil::findCommand('bison', ['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin'])) { self::putenv("BISON={$bison}"); } - if ($yacc = SystemUtil::findCommand('yacc', ['/opt/homebrew/opt/bison/bin', '/usr/local/homebrew/opt/bison/bin'])) { + if ($yacc = SystemUtil::findCommand('yacc', ['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin'])) { self::putenv("YACC={$yacc}"); } } From 6984c29a3ae3abcb42de0a3983e9804111145893 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 00:11:49 +0800 Subject: [PATCH 23/72] suggestion --- src/SPC/builder/extension/openssl.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index e95298fa8..99101e031 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -27,11 +27,7 @@ public function getUnixConfigureArg(bool $shared = false): string { $openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH; $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; - if ( - $this->builder->getPHPVersionID() >= 80500 && - ($ver = $this->builder->getLib('openssl')->getLibVersion()) && - version_compare($ver, '3.2.0', '>=') - ) { + if ($this->builder->getPHPVersionID() >= 80500) { $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"'; } return $args; @@ -40,11 +36,7 @@ public function getUnixConfigureArg(bool $shared = false): string public function getWindowsConfigureArg(bool $shared = false): string { $args = '--with-openssl'; - if ( - $this->builder->getPHPVersionID() >= 80500 && - ($ver = $this->builder->getLib('openssl')->getLibVersion()) && - version_compare($ver, '3.2.0', '>=') - ) { + if ($this->builder->getPHPVersionID() >= 80500) { $args .= ' --with-openssl-argon2'; } return $args; From 3c972ac905d552f77885d5c5a66e4111d93ac45f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 00:55:25 +0800 Subject: [PATCH 24/72] Add re2c build --- bin/spc-gnu-docker | 4 ++-- config/lib.json | 6 ++++++ config/source.json | 10 ++++++++++ src/SPC/builder/linux/library/re2c.php | 15 +++++++++++++++ src/SPC/builder/macos/library/re2c.php | 12 ++++++++++++ src/SPC/builder/unix/library/re2c.php | 15 +++++++++++++++ 6 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/linux/library/re2c.php create mode 100644 src/SPC/builder/macos/library/re2c.php create mode 100644 src/SPC/builder/unix/library/re2c.php diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index 0dbe44e86..36b5c9512 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -129,8 +129,8 @@ RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.ta make install && \ ln -sf /usr/local/bin/automake /usr/bin/automake -RUN curl -o re2c.rpm https://archives.fedoraproject.org/pub/archive/epel/7/$SPC_USE_ARCH/Packages/r/re2c-0.14.3-2.el7.$SPC_USE_ARCH.rpm && \ - rpm -Uvh re2c.rpm +RUN bin/spc download re2c && \ + bin/spc build:libs re2c EOF fi diff --git a/config/lib.json b/config/lib.json index 13f886ca5..6995f5399 100644 --- a/config/lib.json +++ b/config/lib.json @@ -555,6 +555,12 @@ "libuv.a" ] }, + "re2c": { + "source": "re2c", + "bin-unix": [ + "re2c" + ] + }, "libwebp": { "source": "libwebp", "pkg-configs": [ diff --git a/config/source.json b/config/source.json index e49ef0f3f..f1aed51d5 100644 --- a/config/source.json +++ b/config/source.json @@ -1117,6 +1117,16 @@ "text": "(C) 1995-2022 Jean-loup Gailly and Mark Adler\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n claim that you wrote the original software. If you use this software\n in a product, an acknowledgment in the product documentation would be\n appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be\n misrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n\nJean-loup Gailly Mark Adler\njloup@gzip.org madler@alumni.caltech.edu" } }, + "re2c": { + "type": "ghrel", + "repo": "skvadrik/re2c", + "match": "re2c.+\\.tar\\.xz", + "prefer-stable": true, + "license": { + "type": "file", + "path": "LICENSE" + } + }, "zstd": { "type": "ghrel", "repo": "facebook/zstd", diff --git a/src/SPC/builder/linux/library/re2c.php b/src/SPC/builder/linux/library/re2c.php new file mode 100644 index 000000000..91c6ad50b --- /dev/null +++ b/src/SPC/builder/linux/library/re2c.php @@ -0,0 +1,15 @@ +build(); + } +} From 601444d0a586defbeffa1057b2c8f542e955310d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 01:44:44 +0800 Subject: [PATCH 25/72] Add re2c build for spc-gnu-docker --- bin/spc-gnu-docker | 10 +++--- src/SPC/builder/unix/library/re2c.php | 19 +++++++++- src/SPC/doctor/AsCheckItem.php | 2 +- src/SPC/doctor/item/Re2cVersionCheck.php | 44 ++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 src/SPC/doctor/item/Re2cVersionCheck.php diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index 36b5c9512..2c4e92437 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -101,17 +101,20 @@ RUN curl -o cmake.tgz -#fSL https://github.com/Kitware/CMake/releases/download/v tar -xzf cmake.tgz -C /cmake --strip-components 1 WORKDIR /app -ADD ./src /app/src COPY ./composer.* /app/ ADD ./bin/setup-runtime /app/bin/setup-runtime ADD ./bin/spc /app/bin/spc RUN /app/bin/setup-runtime +ADD ./src /app/src RUN /app/bin/php /app/bin/composer install --no-dev ENV SPC_LIBC=glibc ENV PATH="/app/bin:/cmake/bin:/opt/rh/devtoolset-10/root/usr/bin:\$PATH" -ADD ./config/env.ini /app/config/env.ini +ADD ./config /app/config RUN CC=gcc bin/spc doctor --auto-fix --debug +RUN if [ -f /app/buildroot/bin/re2c ]; then \ + cp /app/buildroot/bin/re2c /usr/local/bin/re2c ;\ + fi RUN curl -o make.tgz -fsSL https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && \ tar -zxvf make.tgz && \ @@ -128,9 +131,6 @@ RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.ta make && \ make install && \ ln -sf /usr/local/bin/automake /usr/bin/automake - -RUN bin/spc download re2c && \ - bin/spc build:libs re2c EOF fi diff --git a/src/SPC/builder/unix/library/re2c.php b/src/SPC/builder/unix/library/re2c.php index 94c03a55f..cd6a562ad 100644 --- a/src/SPC/builder/unix/library/re2c.php +++ b/src/SPC/builder/unix/library/re2c.php @@ -10,6 +10,23 @@ trait re2c { protected function build(): void { - UnixCMakeExecutor::create($this)->build(); + UnixCMakeExecutor::create($this) + ->addConfigureArgs( + '-DRE2C_BUILD_TESTS=OFF', + '-DRE2C_BUILD_EXAMPLES=OFF', + '-DRE2C_BUILD_DOCS=OFF', + '-DRE2C_BUILD_RE2D=OFF', + '-DRE2C_BUILD_RE2GO=OFF', + '-DRE2C_BUILD_RE2HS=OFF', + '-DRE2C_BUILD_RE2JAVA=OFF', + '-DRE2C_BUILD_RE2JS=OFF', + '-DRE2C_BUILD_RE2OCAML=OFF', + '-DRE2C_BUILD_RE2PY=OFF', + '-DRE2C_BUILD_RE2RUST=OFF', + '-DRE2C_BUILD_RE2SWIFT=OFF', + '-DRE2C_BUILD_RE2V=OFF', + '-DRE2C_BUILD_RE2ZIG=OFF', + ) + ->build(); } } diff --git a/src/SPC/doctor/AsCheckItem.php b/src/SPC/doctor/AsCheckItem.php index f64d914be..0fa7466fd 100644 --- a/src/SPC/doctor/AsCheckItem.php +++ b/src/SPC/doctor/AsCheckItem.php @@ -4,7 +4,7 @@ namespace SPC\doctor; -#[\Attribute(\Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class AsCheckItem { public mixed $callback = null; diff --git a/src/SPC/doctor/item/Re2cVersionCheck.php b/src/SPC/doctor/item/Re2cVersionCheck.php new file mode 100644 index 000000000..8a10cad55 --- /dev/null +++ b/src/SPC/doctor/item/Re2cVersionCheck.php @@ -0,0 +1,44 @@ += 1.0.3', limit_os: 'Linux', level: 20)] + #[AsCheckItem('if re2c version >= 1.0.3', limit_os: 'Darwin', level: 20)] + public function checkRe2cVersion(): ?CheckResult + { + $ver = shell()->execWithResult('re2c --version', false); + // match version: re2c X.X(.X) + if ($ver[0] !== 0 || !preg_match('/re2c\s+(\d+\.\d+(\.\d+)?)/', $ver[1][0], $matches)) { + return CheckResult::fail('Failed to get re2c version', 'build-re2c'); + } + $version_string = $matches[1]; + if (version_compare($version_string, '1.0.3') < 0) { + return CheckResult::fail('re2c version is too low (' . $version_string . ')', 'build-re2c'); + } + return CheckResult::ok($version_string); + } + + #[AsFixItem('build-re2c')] + public function buildRe2c(): bool + { + Downloader::downloadSource('re2c'); + $builder = BuilderProvider::makeBuilderByInput(new ArgvInput([])); + $builder->proveLibs(['re2c']); + $builder->setupLibs(); + return true; + } +} From be857913cd248b2b65a3fcfc437a29a5177b086d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 01:54:28 +0800 Subject: [PATCH 26/72] Add alt for re2c --- config/source.json | 4 ++++ src/SPC/doctor/item/Re2cVersionCheck.php | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index f1aed51d5..3b04add90 100644 --- a/config/source.json +++ b/config/source.json @@ -1122,6 +1122,10 @@ "repo": "skvadrik/re2c", "match": "re2c.+\\.tar\\.xz", "prefer-stable": true, + "alt": { + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz" + }, "license": { "type": "file", "path": "LICENSE" diff --git a/src/SPC/doctor/item/Re2cVersionCheck.php b/src/SPC/doctor/item/Re2cVersionCheck.php index 8a10cad55..bb3ddf7f0 100644 --- a/src/SPC/doctor/item/Re2cVersionCheck.php +++ b/src/SPC/doctor/item/Re2cVersionCheck.php @@ -9,6 +9,8 @@ use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; use SPC\doctor\CheckResult; +use SPC\exception\DownloaderException; +use SPC\store\Config; use SPC\store\Downloader; use Symfony\Component\Console\Input\ArgvInput; @@ -35,7 +37,14 @@ public function checkRe2cVersion(): ?CheckResult #[AsFixItem('build-re2c')] public function buildRe2c(): bool { - Downloader::downloadSource('re2c'); + try { + Downloader::downloadSource('re2c'); + } catch (DownloaderException) { + logger()->warning('Failed to download re2c version, trying alternative'); + $alt = Config::getSource('re2c'); + $alt = [...$alt, ...$alt['alt'] ?? []]; + Downloader::downloadSource('re2c', $alt); + } $builder = BuilderProvider::makeBuilderByInput(new ArgvInput([])); $builder->proveLibs(['re2c']); $builder->setupLibs(); From 96a7aabda0b8f226c35768200edb6c82c449ea5d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 21:31:48 +0800 Subject: [PATCH 27/72] Don't show shell log --- src/SPC/doctor/item/Re2cVersionCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/Re2cVersionCheck.php b/src/SPC/doctor/item/Re2cVersionCheck.php index bb3ddf7f0..1c130379c 100644 --- a/src/SPC/doctor/item/Re2cVersionCheck.php +++ b/src/SPC/doctor/item/Re2cVersionCheck.php @@ -22,7 +22,7 @@ class Re2cVersionCheck #[AsCheckItem('if re2c version >= 1.0.3', limit_os: 'Darwin', level: 20)] public function checkRe2cVersion(): ?CheckResult { - $ver = shell()->execWithResult('re2c --version', false); + $ver = shell(false)->execWithResult('re2c --version', false); // match version: re2c X.X(.X) if ($ver[0] !== 0 || !preg_match('/re2c\s+(\d+\.\d+(\.\d+)?)/', $ver[1][0], $matches)) { return CheckResult::fail('Failed to get re2c version', 'build-re2c'); From 0496af47dffb13582048ad5fcb855a7aec8b1f23 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 23:43:44 +0800 Subject: [PATCH 28/72] Fix windows PHP 8.5 build --- config/source.json | 2 +- src/globals/test-extensions.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/source.json b/config/source.json index 3b04add90..e78350422 100644 --- a/config/source.json +++ b/config/source.json @@ -733,7 +733,7 @@ "micro": { "type": "git", "path": "php-src/sapi/micro", - "rev": "master", + "rev": "php-85-win", "url": "https://github.com/static-php/phpmicro", "license": { "type": "file", diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index a5b3a9d7b..3214a3c21 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,23 +13,23 @@ // 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', 'git', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - 'macos-13', // bin/spc for x86_64 + // 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 - 'macos-15', // bin/spc for arm64 - 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 + // 'macos-15', // bin/spc for arm64 + // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 // '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 + // 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 + // 'ubuntu-24.04-arm', // bin/spc for arm64 'windows-latest', // .\bin\spc.ps1 ]; @@ -50,7 +50,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'openssl', - 'Windows' => 'openssl', + 'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). From 4c54d996213d30cf3048ae6b35b72f72ad2a97c4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Jul 2025 23:49:53 +0800 Subject: [PATCH 29/72] Remove pcntl --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 1a82be772..4a2e94339 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -50,7 +50,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'openssl', - 'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', + 'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). From 5f9fe2948c9c2a793f658453c07de47ce5d967ed Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 00:09:05 +0800 Subject: [PATCH 30/72] Fix missing SPC_EXTRA_LIBS with type error bug --- src/SPC/builder/extension/curl.php | 2 +- src/SPC/builder/extension/imap.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php index a9079830d..17db61d3a 100644 --- a/src/SPC/builder/extension/curl.php +++ b/src/SPC/builder/extension/curl.php @@ -61,7 +61,7 @@ public function patchBeforeConfigure(): bool public function patchBeforeMake(): bool { $patched = parent::patchBeforeMake(); - $extra_libs = getenv('SPC_EXTRA_LIBS'); + $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; if ($this->builder instanceof WindowsBuilder && !str_contains($extra_libs, 'secur32.lib')) { $extra_libs .= ' secur32.lib'; putenv('SPC_EXTRA_LIBS=' . trim($extra_libs)); diff --git a/src/SPC/builder/extension/imap.php b/src/SPC/builder/extension/imap.php index 81bb31648..d220bc9b0 100644 --- a/src/SPC/builder/extension/imap.php +++ b/src/SPC/builder/extension/imap.php @@ -49,7 +49,7 @@ public function patchBeforeMake(): bool if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::isMuslDist()) { return $patched; } - $extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lcrypt'); + $extra_libs = trim((getenv('SPC_EXTRA_LIBS') ?: '') . ' -lcrypt'); f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); return true; } From d3e8af23bcc6128bb5df5057a0d7cf8225c74930 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 00:50:51 +0800 Subject: [PATCH 31/72] Whoops --- .github/workflows/ext-matrix-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index df6268edc..2396718c1 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -84,7 +84,7 @@ jobs: php-version: - "git" operating-system: - - "ubuntu-24.04" + - "ubuntu-latest" #- "macos-13" #- "debian-arm64-self-hosted" - "macos-14" From e1c92406986942c6b59ccfea63b6058700bd8d29 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 00:51:04 +0800 Subject: [PATCH 32/72] README update --- README-zh.md | 4 ++-- README.md | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README-zh.md b/README-zh.md index 46a66932d..402fd6356 100755 --- a/README-zh.md +++ b/README-zh.md @@ -76,7 +76,7 @@ static-php-cli(简称 `spc`)有许多特性: 当前支持编译的 PHP 版本: -> :warning: 支持,但 static-php-cli 作者可能不再提供补丁修复 +> :warning: 部分支持,对于新的测试版和旧版本可能存在问题。 > > :heavy_check_mark: 支持 > @@ -92,7 +92,7 @@ static-php-cli(简称 `spc`)有许多特性: | 8.2 | :heavy_check_mark: | | | 8.3 | :heavy_check_mark: | | | 8.4 | :heavy_check_mark: | | -| 8.5 | :heavy_check_mark: | | +| 8.5 (alpha) | :warning: | PHP 8.5 目前处于 alpha 阶段 | > 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。 diff --git a/README.md b/README.md index 451146591..22eda03fc 100755 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Here is the supported OS and arch, where :octocat: represents support for GitHub Currently supported PHP versions for compilation: -> :warning: supported but not maintained by static-php-cli authors +> :warning: Partial support, there may be issues with newer test versions or older versions. > > :heavy_check_mark: supported > @@ -95,12 +95,11 @@ Currently supported PHP versions for compilation: | 7.3 | :x: | phpmicro and some extensions not supported on 7.x | | 7.4 | :x: | phpmicro and some extensions not supported on 7.x | | 8.0 | :warning: | PHP official has stopped maintenance of 8.0, we no longer provide backport support for version 8.0 | -| 8.1 | :heavy_check_mark: | PHP official has security fixes only, we no longer provide backport support when 8.5 released | +| 8.1 | :heavy_check_mark: | PHP official has security fixes only, we no longer provide backport support when 8.5 released | | 8.2 | :heavy_check_mark: | | | 8.3 | :heavy_check_mark: | | | 8.4 | :heavy_check_mark: | | -| 8.5 (alpha) | :heavy_check_mark: | | - +| 8.5 (alpha) | :warning: | PHP 8.5 is in alpha | > This table shows the support status for static-php-cli in building the corresponding version, > not the official PHP support status for that version. From 07d66ade8581caf12c040ce86479cb3594b6a6f8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 01:28:56 +0800 Subject: [PATCH 33/72] Add separated patchedBeforeWindowsConfigure --- src/SPC/builder/Extension.php | 8 ++++++++ src/SPC/builder/LibraryBase.php | 10 ++++++++++ src/SPC/builder/extension/bz2.php | 3 --- src/SPC/builder/extension/sqlsrv.php | 2 +- src/SPC/store/SourcePatcher.php | 4 +++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 90f2e27e0..435582c06 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -183,6 +183,14 @@ public function patchBeforeConfigure(): bool return false; } + /** + * Patch code before ./configure.bat for Windows + */ + public function patchBeforeWindowsConfigure(): bool + { + return false; + } + /** * Patch code before make * If you need to patch some code, overwrite this diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 5f03d72cb..e1a3b03a5 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -288,6 +288,16 @@ public function patchBeforeConfigure(): bool return false; } + /** + * Patch code before windows configure.bat + * If you need to patch some code, overwrite this + * return true if you patched something, false if not + */ + public function patchBeforeWindowsConfigure(): bool + { + return false; + } + /** * Patch code before make * If you need to patch some code, overwrite this diff --git a/src/SPC/builder/extension/bz2.php b/src/SPC/builder/extension/bz2.php index c5e6fc674..88f22e568 100644 --- a/src/SPC/builder/extension/bz2.php +++ b/src/SPC/builder/extension/bz2.php @@ -20,9 +20,6 @@ class bz2 extends Extension */ public function patchBeforeConfigure(): bool { - if (!is_unix()) { - return false; - } $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lbz2/', $this->getLibFilesString() . $frameworks); return true; diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php index edf5d919b..04bd52261 100644 --- a/src/SPC/builder/extension/sqlsrv.php +++ b/src/SPC/builder/extension/sqlsrv.php @@ -24,7 +24,7 @@ public function patchBeforeBuildconf(): bool return false; } - public function patchBeforeConfigure(): bool + public function patchBeforeWindowsConfigure(): bool { if ($this->pdo_sqlsrv_patched) { // revert pdo_sqlsrv patch diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 5de826660..02d7d38ae 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -7,6 +7,7 @@ use SPC\builder\BuilderBase; use SPC\builder\linux\SystemUtil; use SPC\builder\unix\UnixBuilderBase; +use SPC\builder\windows\WindowsBuilder; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; @@ -87,7 +88,8 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void public static function patchBeforeConfigure(BuilderBase $builder): void { foreach ($builder->getExts() as $ext) { - if ($ext->patchBeforeConfigure() === true) { + $patch = $builder instanceof WindowsBuilder ? $ext->patchBeforeWindowsConfigure() : $ext->patchBeforeConfigure(); + if ($patch === true) { logger()->info("Extension [{$ext->getName()}] patched before configure"); } } From 6b381238fef3c5f13b120f6e06e4876f86dd3b97 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 01:29:35 +0800 Subject: [PATCH 34/72] Remove collision, it's useless at all --- composer.json | 1 - composer.lock | 437 ++++++------------------- src/SPC/exception/ExceptionHandler.php | 23 +- 3 files changed, 108 insertions(+), 353 deletions(-) diff --git a/composer.json b/composer.json index a3226d692..f3a290576 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "captainhook/hook-installer": "^1.0", "friendsofphp/php-cs-fixer": "^3.60", "humbug/box": "^4.5.0 || ^4.6.0", - "nunomaduro/collision": "^7.8", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^10.3 || ^9.5" }, diff --git a/composer.lock b/composer.lock index a05a1e0d7..5beddd6a7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d705cec8270679a463d9e04310208967", + "content-hash": "dbefe1ee5c584f6f0cc64c26fb83451c", "packages": [ { "name": "illuminate/collections", @@ -416,47 +416,47 @@ }, { "name": "symfony/console", - "version": "v6.4.23", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "9056771b8eca08d026cd3280deeec3cfd99c4d93" + "reference": "5f360ebc65c55265a74d23d7fe27f957870158a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/9056771b8eca08d026cd3280deeec3cfd99c4d93", - "reference": "9056771b8eca08d026cd3280deeec3cfd99c4d93", + "url": "https://api.github.com/repos/symfony/console/zipball/5f360ebc65c55265a74d23d7fe27f957870158a1", + "reference": "5f360ebc65c55265a74d23d7fe27f957870158a1", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^5.4|^6.0|^7.0" + "symfony/string": "^7.2" }, "conflict": { - "symfony/dependency-injection": "<5.4", - "symfony/dotenv": "<5.4", - "symfony/event-dispatcher": "<5.4", - "symfony/lock": "<5.4", - "symfony/process": "<5.4" + "symfony/dependency-injection": "<6.4", + "symfony/dotenv": "<6.4", + "symfony/event-dispatcher": "<6.4", + "symfony/lock": "<6.4", + "symfony/process": "<6.4" }, "provide": { "psr/log-implementation": "1.0|2.0|3.0" }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0|^7.0", - "symfony/dependency-injection": "^5.4|^6.0|^7.0", - "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", "symfony/http-foundation": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", - "symfony/lock": "^5.4|^6.0|^7.0", - "symfony/messenger": "^5.4|^6.0|^7.0", - "symfony/process": "^5.4|^6.0|^7.0", - "symfony/stopwatch": "^5.4|^6.0|^7.0", - "symfony/var-dumper": "^5.4|^6.0|^7.0" + "symfony/lock": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/stopwatch": "^6.4|^7.0", + "symfony/var-dumper": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -490,7 +490,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.23" + "source": "https://github.com/symfony/console/tree/v7.3.2" }, "funding": [ { @@ -501,12 +501,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-06-27T19:37:22+00:00" + "time": "2025-07-30T17:13:41+00:00" }, { "name": "symfony/deprecation-contracts", @@ -1040,16 +1044,16 @@ }, { "name": "symfony/string", - "version": "v7.3.0", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "f3570b8c61ca887a9e2938e85cb6458515d2b125" + "reference": "42f505aff654e62ac7ac2ce21033818297ca89ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/f3570b8c61ca887a9e2938e85cb6458515d2b125", - "reference": "f3570b8c61ca887a9e2938e85cb6458515d2b125", + "url": "https://api.github.com/repos/symfony/string/zipball/42f505aff654e62ac7ac2ce21033818297ca89ca", + "reference": "42f505aff654e62ac7ac2ce21033818297ca89ca", "shasum": "" }, "require": { @@ -1107,7 +1111,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.3.0" + "source": "https://github.com/symfony/string/tree/v7.3.2" }, "funding": [ { @@ -1118,25 +1122,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-04-20T20:19:01+00:00" + "time": "2025-07-10T08:47:49+00:00" }, { "name": "symfony/yaml", - "version": "v7.3.1", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "0c3555045a46ab3cd4cc5a69d161225195230edb" + "reference": "b8d7d868da9eb0919e99c8830431ea087d6aae30" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0c3555045a46ab3cd4cc5a69d161225195230edb", - "reference": "0c3555045a46ab3cd4cc5a69d161225195230edb", + "url": "https://api.github.com/repos/symfony/yaml/zipball/b8d7d868da9eb0919e99c8830431ea087d6aae30", + "reference": "b8d7d868da9eb0919e99c8830431ea087d6aae30", "shasum": "" }, "require": { @@ -1179,7 +1187,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.3.1" + "source": "https://github.com/symfony/yaml/tree/v7.3.2" }, "funding": [ { @@ -1190,12 +1198,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-06-03T06:57:57+00:00" + "time": "2025-07-10T08:47:49+00:00" }, { "name": "zhamao/logger", @@ -2078,7 +2090,7 @@ }, { "name": "captainhook/captainhook-phar", - "version": "5.25.6", + "version": "5.25.10", "source": { "type": "git", "url": "https://github.com/captainhook-git/captainhook-phar.git", @@ -2132,7 +2144,7 @@ ], "support": { "issues": "https://github.com/captainhook-git/captainhook/issues", - "source": "https://github.com/captainhook-git/captainhook-phar/tree/5.25.6" + "source": "https://github.com/captainhook-git/captainhook-phar/tree/5.25.10" }, "funding": [ { @@ -2831,93 +2843,22 @@ ], "time": "2025-02-13T23:05:19+00:00" }, - { - "name": "filp/whoops", - "version": "2.18.3", - "source": { - "type": "git", - "url": "https://github.com/filp/whoops.git", - "reference": "59a123a3d459c5a23055802237cb317f609867e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/59a123a3d459c5a23055802237cb317f609867e5", - "reference": "59a123a3d459c5a23055802237cb317f609867e5", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", - "symfony/var-dumper": "^4.0 || ^5.0" - }, - "suggest": { - "symfony/var-dumper": "Pretty print complex values better with var-dumper available", - "whoops/soap": "Formats errors as SOAP responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Whoops\\": "src/Whoops/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Filipe Dobreira", - "homepage": "https://github.com/filp", - "role": "Developer" - } - ], - "description": "php error handling for cool kids", - "homepage": "https://filp.github.io/whoops/", - "keywords": [ - "error", - "exception", - "handling", - "library", - "throwable", - "whoops" - ], - "support": { - "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.18.3" - }, - "funding": [ - { - "url": "https://github.com/denis-sokolov", - "type": "github" - } - ], - "time": "2025-06-16T00:02:10+00:00" - }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.84.0", + "version": "v3.85.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "38dad0767bf2a9b516b976852200ae722fe984ca" + "reference": "2fb6d7f6c3398dca5786a1635b27405d73a417ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/38dad0767bf2a9b516b976852200ae722fe984ca", - "reference": "38dad0767bf2a9b516b976852200ae722fe984ca", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2fb6d7f6c3398dca5786a1635b27405d73a417ba", + "reference": "2fb6d7f6c3398dca5786a1635b27405d73a417ba", "shasum": "" }, "require": { - "clue/ndjson-react": "^1.0", + "clue/ndjson-react": "^1.3", "composer/semver": "^3.4", "composer/xdebug-handler": "^3.0.5", "ext-filter": "*", @@ -2927,12 +2868,12 @@ "fidry/cpu-core-counter": "^1.2", "php": "^7.4 || ^8.0", "react/child-process": "^0.6.6", - "react/event-loop": "^1.0", - "react/promise": "^2.11 || ^3.0", - "react/socket": "^1.0", - "react/stream": "^1.0", + "react/event-loop": "^1.5", + "react/promise": "^3.2", + "react/socket": "^1.16", + "react/stream": "^1.4", "sebastian/diff": "^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0", - "symfony/console": "^5.4.45 || ^6.4.13 || ^7.0", + "symfony/console": "^5.4.47 || ^6.4.13 || ^7.0", "symfony/event-dispatcher": "^5.4.45 || ^6.4.13 || ^7.0", "symfony/filesystem": "^5.4.45 || ^6.4.13 || ^7.0", "symfony/finder": "^5.4.45 || ^6.4.17 || ^7.0", @@ -2997,7 +2938,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.84.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.85.1" }, "funding": [ { @@ -3005,7 +2946,7 @@ "type": "github" } ], - "time": "2025-07-15T18:21:57+00:00" + "time": "2025-07-29T22:22:50+00:00" }, { "name": "humbug/box", @@ -3660,16 +3601,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.5.0", + "version": "v5.6.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "ae59794362fe85e051a58ad36b289443f57be7a9" + "reference": "221b0d0fdf1369c71047ad1d18bb5880017bbc56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ae59794362fe85e051a58ad36b289443f57be7a9", - "reference": "ae59794362fe85e051a58ad36b289443f57be7a9", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/221b0d0fdf1369c71047ad1d18bb5880017bbc56", + "reference": "221b0d0fdf1369c71047ad1d18bb5880017bbc56", "shasum": "" }, "require": { @@ -3712,190 +3653,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.5.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.0" }, - "time": "2025-05-31T08:24:38+00:00" - }, - { - "name": "nunomaduro/collision", - "version": "v7.12.0", - "source": { - "type": "git", - "url": "https://github.com/nunomaduro/collision.git", - "reference": "995245421d3d7593a6960822063bdba4f5d7cf1a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/995245421d3d7593a6960822063bdba4f5d7cf1a", - "reference": "995245421d3d7593a6960822063bdba4f5d7cf1a", - "shasum": "" - }, - "require": { - "filp/whoops": "^2.17.0", - "nunomaduro/termwind": "^1.17.0", - "php": "^8.1.0", - "symfony/console": "^6.4.17" - }, - "conflict": { - "laravel/framework": ">=11.0.0" - }, - "require-dev": { - "brianium/paratest": "^7.4.8", - "laravel/framework": "^10.48.29", - "laravel/pint": "^1.21.2", - "laravel/sail": "^1.41.0", - "laravel/sanctum": "^3.3.3", - "laravel/tinker": "^2.10.1", - "nunomaduro/larastan": "^2.10.0", - "orchestra/testbench-core": "^8.35.0", - "pestphp/pest": "^2.36.0", - "phpunit/phpunit": "^10.5.36", - "sebastian/environment": "^6.1.0", - "spatie/laravel-ignition": "^2.9.1" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" - ] - } - }, - "autoload": { - "files": [ - "./src/Adapters/Phpunit/Autoload.php" - ], - "psr-4": { - "NunoMaduro\\Collision\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "Cli error handling for console/command-line PHP applications.", - "keywords": [ - "artisan", - "cli", - "command-line", - "console", - "error", - "handling", - "laravel", - "laravel-zero", - "php", - "symfony" - ], - "support": { - "issues": "https://github.com/nunomaduro/collision/issues", - "source": "https://github.com/nunomaduro/collision" - }, - "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://www.patreon.com/nunomaduro", - "type": "patreon" - } - ], - "time": "2025-03-14T22:35:49+00:00" - }, - { - "name": "nunomaduro/termwind", - "version": "v1.17.0", - "source": { - "type": "git", - "url": "https://github.com/nunomaduro/termwind.git", - "reference": "5369ef84d8142c1d87e4ec278711d4ece3cbf301" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/5369ef84d8142c1d87e4ec278711d4ece3cbf301", - "reference": "5369ef84d8142c1d87e4ec278711d4ece3cbf301", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": "^8.1", - "symfony/console": "^6.4.15" - }, - "require-dev": { - "illuminate/console": "^10.48.24", - "illuminate/support": "^10.48.24", - "laravel/pint": "^1.18.2", - "pestphp/pest": "^2.36.0", - "pestphp/pest-plugin-mock": "2.0.0", - "phpstan/phpstan": "^1.12.11", - "phpstan/phpstan-strict-rules": "^1.6.1", - "symfony/var-dumper": "^6.4.15", - "thecodingmachine/phpstan-strict-rules": "^1.0.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Termwind\\Laravel\\TermwindServiceProvider" - ] - } - }, - "autoload": { - "files": [ - "src/Functions.php" - ], - "psr-4": { - "Termwind\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "Its like Tailwind CSS, but for the console.", - "keywords": [ - "cli", - "console", - "css", - "package", - "php", - "style" - ], - "support": { - "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v1.17.0" - }, - "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://github.com/xiCO2k", - "type": "github" - } - ], - "time": "2024-11-21T10:36:35+00:00" + "time": "2025-07-27T20:03:57+00:00" }, { "name": "phar-io/composer-distributor", @@ -6881,16 +6641,16 @@ }, { "name": "symfony/filesystem", - "version": "v7.3.0", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb" + "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/b8dce482de9d7c9fe2891155035a7248ab5c7fdb", - "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edcbb768a186b5c3f25d0643159a787d3e63b7fd", + "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd", "shasum": "" }, "require": { @@ -6927,7 +6687,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.3.0" + "source": "https://github.com/symfony/filesystem/tree/v7.3.2" }, "funding": [ { @@ -6938,25 +6698,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-10-25T15:15:23+00:00" + "time": "2025-07-07T08:17:47+00:00" }, { "name": "symfony/finder", - "version": "v7.3.0", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ec2344cf77a48253bbca6939aa3d2477773ea63d" + "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ec2344cf77a48253bbca6939aa3d2477773ea63d", - "reference": "ec2344cf77a48253bbca6939aa3d2477773ea63d", + "url": "https://api.github.com/repos/symfony/finder/zipball/2a6614966ba1074fa93dae0bc804227422df4dfe", + "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe", "shasum": "" }, "require": { @@ -6991,7 +6755,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.3.0" + "source": "https://github.com/symfony/finder/tree/v7.3.2" }, "funding": [ { @@ -7002,25 +6766,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-12-30T19:00:26+00:00" + "time": "2025-07-15T13:41:35+00:00" }, { "name": "symfony/options-resolver", - "version": "v7.3.0", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "afb9a8038025e5dbc657378bfab9198d75f10fca" + "reference": "119bcf13e67dbd188e5dbc74228b1686f66acd37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/afb9a8038025e5dbc657378bfab9198d75f10fca", - "reference": "afb9a8038025e5dbc657378bfab9198d75f10fca", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/119bcf13e67dbd188e5dbc74228b1686f66acd37", + "reference": "119bcf13e67dbd188e5dbc74228b1686f66acd37", "shasum": "" }, "require": { @@ -7058,7 +6826,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.3.0" + "source": "https://github.com/symfony/options-resolver/tree/v7.3.2" }, "funding": [ { @@ -7069,12 +6837,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-04-04T13:12:05+00:00" + "time": "2025-07-15T11:36:08+00:00" }, { "name": "symfony/polyfill-iconv", @@ -7296,16 +7068,16 @@ }, { "name": "symfony/var-dumper", - "version": "v7.3.1", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "6e209fbe5f5a7b6043baba46fe5735a4b85d0d42" + "reference": "53205bea27450dc5c65377518b3275e126d45e75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/6e209fbe5f5a7b6043baba46fe5735a4b85d0d42", - "reference": "6e209fbe5f5a7b6043baba46fe5735a4b85d0d42", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/53205bea27450dc5c65377518b3275e126d45e75", + "reference": "53205bea27450dc5c65377518b3275e126d45e75", "shasum": "" }, "require": { @@ -7317,7 +7089,6 @@ "symfony/console": "<6.4" }, "require-dev": { - "ext-iconv": "*", "symfony/console": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", "symfony/process": "^6.4|^7.0", @@ -7360,7 +7131,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.3.1" + "source": "https://github.com/symfony/var-dumper/tree/v7.3.2" }, "funding": [ { @@ -7371,12 +7142,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-06-27T19:55:54+00:00" + "time": "2025-07-29T20:02:46+00:00" }, { "name": "thecodingmachine/safe", diff --git a/src/SPC/exception/ExceptionHandler.php b/src/SPC/exception/ExceptionHandler.php index 544575dc9..d103b9574 100644 --- a/src/SPC/exception/ExceptionHandler.php +++ b/src/SPC/exception/ExceptionHandler.php @@ -10,20 +10,6 @@ class ExceptionHandler private static ?ExceptionHandler $obj = null; - private function __construct() - { - $whoops_class = 'Whoops\Run'; - $collision_class = 'NunoMaduro\Collision\Handler'; - if (class_exists($collision_class) && class_exists($whoops_class)) { - /* @phpstan-ignore-next-line */ - $this->whoops = new $whoops_class(); - $this->whoops->allowQuit(false); - $this->whoops->writeToOutput(false); - $this->whoops->pushHandler(new $collision_class()); - $this->whoops->register(); - } - } - public static function getInstance(): ExceptionHandler { if (self::$obj === null) { @@ -34,13 +20,8 @@ public static function getInstance(): ExceptionHandler public function handle(\Throwable $e): void { - if (is_null($this->whoops)) { - logger()->error('Uncaught ' . get_class($e) . ': ' . $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')'); - logger()->error($e->getTraceAsString()); - return; - } - $this->whoops->handleException($e); - + logger()->error('Uncaught ' . get_class($e) . ': ' . $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')'); + logger()->error($e->getTraceAsString()); logger()->critical('You can report this exception to static-php-cli GitHub repo.'); } } From 33d587ee9ebf4ffef9fa9059f73ede33d7f31643 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 01:32:37 +0800 Subject: [PATCH 35/72] Remove redis test (https://github.com/phpredis/phpredis/pull/2676) --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 4a2e94339..07ce65f0a 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -50,7 +50,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'openssl', - 'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', + 'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). From 451de4a6f6111fe5bb0ba9f445f25193b53a0e31 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 01:50:32 +0800 Subject: [PATCH 36/72] Fix ConfigValidator and sort config --- config/lib.json | 12 ++++---- config/source.json | 28 ++++++++--------- src/SPC/util/ConfigValidator.php | 53 +++++++++++++++++++++++--------- 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/config/lib.json b/config/lib.json index bc02f5737..b8abd577e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -555,12 +555,6 @@ "libuv.a" ] }, - "re2c": { - "source": "re2c", - "bin-unix": [ - "re2c" - ] - }, "libwebp": { "source": "libwebp", "pkg-configs": [ @@ -803,6 +797,12 @@ "depot.h" ] }, + "re2c": { + "source": "re2c", + "bin-unix": [ + "re2c" + ] + }, "readline": { "source": "readline", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index a468d2e09..c89ebe7eb 100644 --- a/config/source.json +++ b/config/source.json @@ -932,6 +932,20 @@ "path": "LICENSE" } }, + "re2c": { + "type": "ghrel", + "repo": "skvadrik/re2c", + "match": "re2c.+\\.tar\\.xz", + "prefer-stable": true, + "alt": { + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz" + }, + "license": { + "type": "file", + "path": "LICENSE" + } + }, "readline": { "type": "filelist", "url": "https://ftp.gnu.org/pub/gnu/readline/", @@ -1112,20 +1126,6 @@ "text": "(C) 1995-2022 Jean-loup Gailly and Mark Adler\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n claim that you wrote the original software. If you use this software\n in a product, an acknowledgment in the product documentation would be\n appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be\n misrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n\nJean-loup Gailly Mark Adler\njloup@gzip.org madler@alumni.caltech.edu" } }, - "re2c": { - "type": "ghrel", - "repo": "skvadrik/re2c", - "match": "re2c.+\\.tar\\.xz", - "prefer-stable": true, - "alt": { - "type": "url", - "url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz" - }, - "license": { - "type": "file", - "path": "LICENSE" - } - }, "zstd": { "type": "ghrel", "repo": "facebook/zstd", diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index cfb9c2c2c..3415b25f4 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -47,25 +47,50 @@ public static function validateSource(array $data): void // check if license is valid if (isset($src['license'])) { - if (!is_assoc_array($src['license'])) { - throw new ValidationException("source {$name} license must be object"); - } - if (!isset($src['license']['type'])) { - throw new ValidationException("source {$name} license must have type"); - } - if (!in_array($src['license']['type'], ['file', 'text'])) { - throw new ValidationException("source {$name} license type is invalid"); - } - if ($src['license']['type'] === 'file' && !isset($src['license']['path'])) { - throw new ValidationException("source {$name} license file must have path"); - } - if ($src['license']['type'] === 'text' && !isset($src['license']['text'])) { - throw new ValidationException("source {$name} license text must have text"); + if (!is_array($src['license'])) { + throw new ValidationException("source {$name} license must be an object or array"); + } + if (is_assoc_array($src['license'])) { + self::checkSingleLicense($src['license'], $name); + } elseif (is_list_array($src['license'])) { + foreach ($src['license'] as $license) { + if (!is_assoc_array($license)) { + throw new ValidationException("source {$name} license must be an object or array"); + } + self::checkSingleLicense($license, $name); + } + } else { + throw new ValidationException("source {$name} license must be an object or array"); } } } } + /** + * @throws ValidationException + */ + private static function checkSingleLicense(array $license, string $name): void + { + if (!is_assoc_array($license)) { + throw new ValidationException("source {$name} license must be an object"); + } + if (!isset($license['type'])) { + throw new ValidationException("source {$name} license must have type"); + } + if (!in_array($license['type'], ['file', 'text'])) { + throw new ValidationException("source {$name} license type is invalid"); + } + if (!in_array($license['type'], ['file', 'text'])) { + throw new ValidationException("source {$name} license type is invalid"); + } + if ($license['type'] === 'file' && !isset($license['path'])) { + throw new ValidationException("source {$name} license file must have path"); + } + if ($license['type'] === 'text' && !isset($license['text'])) { + throw new ValidationException("source {$name} license text must have text"); + } + } + /** * @throws ValidationException */ From 6b23f4b34ac066d254a86b65da918bb2b8f45b3d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 01:53:38 +0800 Subject: [PATCH 37/72] Fix PHPUnit test on Windows, ignore calling linux system util for other OS --- src/SPC/util/SPCTarget.php | 7 +++++-- tests/SPC/util/PkgConfigUtilTest.php | 4 ++++ tests/SPC/util/SPCConfigUtilTest.php | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/SPC/util/SPCTarget.php b/src/SPC/util/SPCTarget.php index d4164ceb6..c6519a9a4 100644 --- a/src/SPC/util/SPCTarget.php +++ b/src/SPC/util/SPCTarget.php @@ -99,8 +99,11 @@ public static function getRuntimeLibs(): string */ public static function getLibcVersion(): ?string { - $libc = self::getLibc(); - return SystemUtil::getLibcVersionIfExists($libc); + if (PHP_OS_FAMILY === 'Linux') { + $libc = self::getLibc(); + return SystemUtil::getLibcVersionIfExists($libc); + } + return null; } /** diff --git a/tests/SPC/util/PkgConfigUtilTest.php b/tests/SPC/util/PkgConfigUtilTest.php index 6d8988fd4..64882a547 100644 --- a/tests/SPC/util/PkgConfigUtilTest.php +++ b/tests/SPC/util/PkgConfigUtilTest.php @@ -19,6 +19,10 @@ final class PkgConfigUtilTest extends TestCase public static function setUpBeforeClass(): void { + if (PHP_OS_FAMILY === 'Windows') { + // Skip tests on Windows as pkg-config is not typically available + self::markTestSkipped('PkgConfigUtil tests are not applicable on Windows.'); + } parent::setUpBeforeClass(); // Save original PATH diff --git a/tests/SPC/util/SPCConfigUtilTest.php b/tests/SPC/util/SPCConfigUtilTest.php index 7b8baa6c5..0c0fbc7ec 100644 --- a/tests/SPC/util/SPCConfigUtilTest.php +++ b/tests/SPC/util/SPCConfigUtilTest.php @@ -21,6 +21,10 @@ class SPCConfigUtilTest extends TestCase */ public static function setUpBeforeClass(): void { + if (PHP_OS_FAMILY === 'Windows') { + // Skip tests on Windows as SPCConfigUtil is not applicable + self::markTestSkipped('SPCConfigUtil tests are not applicable on Windows.'); + } $testdir = WORKING_DIR . '/.configtest'; FileSystem::createDir($testdir); FileSystem::writeFile($testdir . '/lib.json', file_get_contents(ROOT_DIR . '/config/lib.json')); From 7d0577460f999f077e1a0b3a2439d16a4f2e439c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 02:05:46 +0800 Subject: [PATCH 38/72] cs-fix --- src/SPC/util/ConfigValidator.php | 50 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index 3415b25f4..baa42b598 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -66,31 +66,6 @@ public static function validateSource(array $data): void } } - /** - * @throws ValidationException - */ - private static function checkSingleLicense(array $license, string $name): void - { - if (!is_assoc_array($license)) { - throw new ValidationException("source {$name} license must be an object"); - } - if (!isset($license['type'])) { - throw new ValidationException("source {$name} license must have type"); - } - if (!in_array($license['type'], ['file', 'text'])) { - throw new ValidationException("source {$name} license type is invalid"); - } - if (!in_array($license['type'], ['file', 'text'])) { - throw new ValidationException("source {$name} license type is invalid"); - } - if ($license['type'] === 'file' && !isset($license['path'])) { - throw new ValidationException("source {$name} license file must have path"); - } - if ($license['type'] === 'text' && !isset($license['text'])) { - throw new ValidationException("source {$name} license text must have text"); - } - } - /** * @throws ValidationException */ @@ -440,6 +415,31 @@ public static function validateAndParseCraftFile(mixed $craft_file, Command $com return $craft; } + /** + * @throws ValidationException + */ + private static function checkSingleLicense(array $license, string $name): void + { + if (!is_assoc_array($license)) { + throw new ValidationException("source {$name} license must be an object"); + } + if (!isset($license['type'])) { + throw new ValidationException("source {$name} license must have type"); + } + if (!in_array($license['type'], ['file', 'text'])) { + throw new ValidationException("source {$name} license type is invalid"); + } + if (!in_array($license['type'], ['file', 'text'])) { + throw new ValidationException("source {$name} license type is invalid"); + } + if ($license['type'] === 'file' && !isset($license['path'])) { + throw new ValidationException("source {$name} license file must have path"); + } + if ($license['type'] === 'text' && !isset($license['text'])) { + throw new ValidationException("source {$name} license text must have text"); + } + } + /** * Validate source type configuration (shared between source.json and pkg.json) * From 948705179698bd40cfd5673a3f71a666d94b2c79 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 02:25:12 +0800 Subject: [PATCH 39/72] Add PHP_BUILD_PROVIDER for PHP >= 8.4 --- src/SPC/store/SourcePatcher.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 02d7d38ae..be2a41e88 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -588,13 +588,18 @@ public static function patchGDWin32(): bool */ public static function patchSPCVersionToPHP(string $version = 'unknown'): void { - // detect patch + // detect patch (remove this when 8.3 deprecated) $file = FileSystem::readFile(SOURCE_PATH . '/php-src/main/main.c'); if (!str_contains($file, 'static-php-cli.version')) { logger()->debug('Inserting static-php-cli.version to php-src'); $file = str_replace('PHP_INI_BEGIN()', "PHP_INI_BEGIN()\n\tPHP_INI_ENTRY(\"static-php-cli.version\",\t\"{$version}\",\tPHP_INI_ALL,\tNULL)", $file); FileSystem::writeFile(SOURCE_PATH . '/php-src/main/main.c', $file); } + + // add PHP_BUILD_PROVIDER + if (getenv('PHP_BUILD_PROVIDER') === false) { + putenv("PHP_BUILD_PROVIDER=static-php-cli {$version}"); + } } /** From 34edb6e329fb8f9403e599c794e02d5f7a2db78a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 10:58:31 +0800 Subject: [PATCH 40/72] Add PHP_BUILD_PROVIDER to env.ini --- config/env.ini | 3 +++ src/SPC/store/SourcePatcher.php | 5 ----- src/globals/internal-env.php | 4 ++++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/env.ini b/config/env.ini index 465f72d5b..040583059 100644 --- a/config/env.ini +++ b/config/env.ini @@ -10,6 +10,7 @@ ; ; Here's a list of env vars, these value cannot be changed anywhere: ; +; SPC_VERSION: the version of static-php-cli. ; WORKING_DIR: the working directory of the build process. (default: `$(pwd)`) ; ROOT_DIR: the root directory of static-php-cli. (default: `/path/to/static-php-cli`, when running in phar or micro mode: `phar://path/to/spc.phar`) ; BUILD_ROOT_PATH: the root path of the build process. (default: `$(pwd)/buildroot`) @@ -43,6 +44,8 @@ SPC_SKIP_PHP_VERSION_CHECK="no" SPC_SKIP_DOCTOR_CHECK_ITEMS="" ; extra modules that xcaddy will include in the FrankenPHP build SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" +; The display message for php version output (PHP >= 8.4 available) +PHP_BUILD_PROVIDER="static-php-cli ${SPC_VERSION}" ; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them ; only useful for builds targeting not pure-static linking diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index be2a41e88..aa12127cc 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -595,11 +595,6 @@ public static function patchSPCVersionToPHP(string $version = 'unknown'): void $file = str_replace('PHP_INI_BEGIN()', "PHP_INI_BEGIN()\n\tPHP_INI_ENTRY(\"static-php-cli.version\",\t\"{$version}\",\tPHP_INI_ALL,\tNULL)", $file); FileSystem::writeFile(SOURCE_PATH . '/php-src/main/main.c', $file); } - - // add PHP_BUILD_PROVIDER - if (getenv('PHP_BUILD_PROVIDER') === false) { - putenv("PHP_BUILD_PROVIDER=static-php-cli {$version}"); - } } /** diff --git a/src/globals/internal-env.php b/src/globals/internal-env.php index 1046848e0..22918fdf3 100644 --- a/src/globals/internal-env.php +++ b/src/globals/internal-env.php @@ -6,9 +6,12 @@ use SPC\builder\linux\SystemUtil as LinuxSystemUtil; use SPC\builder\macos\SystemUtil as MacOSSystemUtil; use SPC\builder\windows\SystemUtil as WindowsSystemUtil; +use SPC\ConsoleApplication; use SPC\store\FileSystem; use SPC\util\GlobalEnvManager; +// static-php-cli version string +const SPC_VERSION = ConsoleApplication::VERSION; // output path for everything, other paths are defined relative to this by default define('BUILD_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot'))); // output path for header files for development @@ -44,6 +47,7 @@ ]); // add these to env vars with same name +GlobalEnvManager::putenv('SPC_VERSION=' . SPC_VERSION); GlobalEnvManager::putenv('BUILD_ROOT_PATH=' . BUILD_ROOT_PATH); GlobalEnvManager::putenv('BUILD_INCLUDE_PATH=' . BUILD_INCLUDE_PATH); GlobalEnvManager::putenv('BUILD_LIB_PATH=' . BUILD_LIB_PATH); From 8b9b72958e1c5cf289bd2a5cc1ab9469d44f7987 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 12:48:48 +0800 Subject: [PATCH 41/72] Add PHP_BUILD_COMPILER for different toolchain --- src/SPC/toolchain/ClangNativeToolchain.php | 14 +++++++++++++- src/SPC/toolchain/GccNativeToolchain.php | 11 +++++++++++ src/SPC/toolchain/MSVCToolchain.php | 5 +++++ src/SPC/toolchain/MuslToolchain.php | 11 +++++++++++ src/SPC/toolchain/ToolchainInterface.php | 8 ++++++++ src/SPC/toolchain/ToolchainManager.php | 6 +++++- src/SPC/toolchain/ZigToolchain.php | 6 ++++++ 7 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/SPC/toolchain/ClangNativeToolchain.php b/src/SPC/toolchain/ClangNativeToolchain.php index aef844d7d..6cccb4afc 100644 --- a/src/SPC/toolchain/ClangNativeToolchain.php +++ b/src/SPC/toolchain/ClangNativeToolchain.php @@ -7,6 +7,7 @@ use SPC\builder\freebsd\SystemUtil as FreeBSDSystemUtil; use SPC\builder\linux\SystemUtil as LinuxSystemUtil; use SPC\builder\macos\SystemUtil as MacOSSystemUtil; +use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\util\GlobalEnvManager; @@ -37,8 +38,19 @@ public function afterInit(): void 'Linux' => LinuxSystemUtil::findCommand($command) ?? throw new WrongUsageException("{$command} not found, please install it or set {$env} to a valid path."), 'Darwin' => MacOSSystemUtil::findCommand($command) ?? throw new WrongUsageException("{$command} not found, please install it or set {$env} to a valid path."), 'BSD' => FreeBSDSystemUtil::findCommand($command) ?? throw new WrongUsageException("{$command} not found, please install it or set {$env} to a valid path."), - default => throw new \RuntimeException(__CLASS__ . ' is not supported on ' . PHP_OS_FAMILY . '.'), + default => throw new RuntimeException(__CLASS__ . ' is not supported on ' . PHP_OS_FAMILY . '.'), }; } } + + public function getCompilerInfo(): ?string + { + $compiler = getenv('CC') ?: 'clang'; + $version = shell(false)->execWithResult("{$compiler} --version", false); + $head = pathinfo($compiler, PATHINFO_BASENAME); + if ($version[0] === 0 && preg_match('/clang version (\d+.\d+.\d+)/', $version[1][0], $match)) { + return "{$head} {$match[1]}"; + } + return $head; + } } diff --git a/src/SPC/toolchain/GccNativeToolchain.php b/src/SPC/toolchain/GccNativeToolchain.php index 1ada28b54..05fe026a0 100644 --- a/src/SPC/toolchain/GccNativeToolchain.php +++ b/src/SPC/toolchain/GccNativeToolchain.php @@ -35,4 +35,15 @@ public function afterInit(): void }; } } + + public function getCompilerInfo(): ?string + { + $compiler = getenv('CC') ?: 'gcc'; + $version = shell(false)->execWithResult("{$compiler} --version", false); + $head = pathinfo($compiler, PATHINFO_BASENAME); + if ($version[0] === 0 && preg_match('/gcc.*(\d+.\d+.\d+)/', $version[1][0], $match)) { + return "{$head} {$match[1]}"; + } + return $head; + } } diff --git a/src/SPC/toolchain/MSVCToolchain.php b/src/SPC/toolchain/MSVCToolchain.php index 567cff38d..55559e8a1 100644 --- a/src/SPC/toolchain/MSVCToolchain.php +++ b/src/SPC/toolchain/MSVCToolchain.php @@ -9,4 +9,9 @@ class MSVCToolchain implements ToolchainInterface public function initEnv(): void {} public function afterInit(): void {} + + public function getCompilerInfo(): ?string + { + return null; + } } diff --git a/src/SPC/toolchain/MuslToolchain.php b/src/SPC/toolchain/MuslToolchain.php index e996ef1fa..684473c6d 100644 --- a/src/SPC/toolchain/MuslToolchain.php +++ b/src/SPC/toolchain/MuslToolchain.php @@ -36,4 +36,15 @@ public function afterInit(): void throw new WrongUsageException('You are building with musl-libc target in glibc distro, but musl-toolchain is not installed, please install musl-toolchain first. (You can use `doctor` command to install it)'); } } + + public function getCompilerInfo(): ?string + { + $compiler = getenv('CC') ?: getenv('SPC_LINUX_DEFAULT_CC'); + $version = shell(false)->execWithResult("{$compiler} --version", false); + $head = pathinfo($compiler, PATHINFO_BASENAME); + if ($version[0] === 0 && preg_match('/linux-musl-cc.*(\d+.\d+.\d+)/', $version[1][0], $match)) { + return "{$head} {$match[1]}"; + } + return $head; + } } diff --git a/src/SPC/toolchain/ToolchainInterface.php b/src/SPC/toolchain/ToolchainInterface.php index 62cf2b2d2..a08fb8691 100644 --- a/src/SPC/toolchain/ToolchainInterface.php +++ b/src/SPC/toolchain/ToolchainInterface.php @@ -27,4 +27,12 @@ public function initEnv(): void; * post-initialization setup or validation. */ public function afterInit(): void; + + /** + * Returns the compiler name and version for toolchains. + * + * If the toolchain does not support compiler information, + * this method can return null. + */ + public function getCompilerInfo(): ?string; } diff --git a/src/SPC/toolchain/ToolchainManager.php b/src/SPC/toolchain/ToolchainManager.php index 0c92c58a9..9672977d7 100644 --- a/src/SPC/toolchain/ToolchainManager.php +++ b/src/SPC/toolchain/ToolchainManager.php @@ -61,6 +61,10 @@ public static function afterInitToolchain(): void } $toolchain = getenv('SPC_TOOLCHAIN'); /* @var ToolchainInterface $toolchain */ - (new $toolchain())->afterInit(); + $instance = new $toolchain(); + $instance->afterInit(); + if (getenv('PHP_BUILD_COMPILER') === false && ($compiler_info = $instance->getCompilerInfo())) { + GlobalEnvManager::putenv("PHP_BUILD_COMPILER={$compiler_info}"); + } } } diff --git a/src/SPC/toolchain/ZigToolchain.php b/src/SPC/toolchain/ZigToolchain.php index 613c0f979..93d004a5e 100644 --- a/src/SPC/toolchain/ZigToolchain.php +++ b/src/SPC/toolchain/ZigToolchain.php @@ -68,4 +68,10 @@ public function afterInit(): void GlobalEnvManager::putenv("SPC_EXTRA_LIBS={$extra_libs}"); } } + + public function getCompilerInfo(): ?string + { + $version = shell(false)->execWithResult('zig version', false)[1][0] ?? ''; + return trim("zig {$version}"); + } } From d6081ee10fcd2854fb04bfbf5258f9c466e54c49 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 13:00:12 +0800 Subject: [PATCH 42/72] Support alpha4 --- src/SPC/store/source/PhpSource.php | 2 +- src/globals/test-extensions.php | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 2ce693722..72a16849a 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -23,7 +23,7 @@ public function fetch(bool $force = false, ?array $config = null, int $lock_as = { $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4'; if ($major === '8.5') { - Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz'], $force); + Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~daniels/php-8.5.0alpha4.tar.xz'], $force); } elseif ($major === 'git') { Downloader::downloadSource('php-src', ['type' => 'git', 'url' => 'https://github.com/php/php-src.git', 'rev' => 'master'], $force); } else { diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 07ce65f0a..fcc0da8ef 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,28 +13,28 @@ // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - '8.1', - '8.2', - '8.3', - '8.4', - 'git', + // '8.1', + // '8.2', + // '8.3', + // '8.4', + '8.5', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - // 'macos-13', // bin/spc for x86_64 + 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 - // 'macos-15', // bin/spc for arm64 - // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 + 'macos-15', // bin/spc for arm64 + 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 // '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 + 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 + 'ubuntu-24.04-arm', // bin/spc for arm64 'windows-latest', // .\bin\spc.ps1 ]; // whether enable thread safe -$zts = false; +$zts = true; $no_strip = false; @@ -73,7 +73,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'none', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', }; From ac2eb3adae14b71a7c286dc6a71e093c3e0a760b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 14:21:38 +0800 Subject: [PATCH 43/72] Remove redis test --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index fcc0da8ef..5b53cb239 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -49,7 +49,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'openssl', + 'Linux', 'Darwin' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', 'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', }; From 1c9fbdb032524d868987bf33f27e6c6e6bf5e1d5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 15:01:55 +0800 Subject: [PATCH 44/72] Use none base combination --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 5b53cb239..c5e4cde20 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -73,7 +73,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'common', + 'Linux', 'Darwin' => 'none', 'Windows' => 'none', }; From efa47af347f91489e37e2682ac381e7597004e5c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 15:17:13 +0800 Subject: [PATCH 45/72] Add git source test --- src/globals/test-extensions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index c5e4cde20..8ccbf5b4f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -18,6 +18,7 @@ // '8.3', // '8.4', '8.5', + 'git', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) From cace504a6305effb7c501f7591520fe80ef53c79 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 15:42:34 +0800 Subject: [PATCH 46/72] Workaround for windows openssl temporarily --- src/SPC/builder/extension/openssl.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index ec481b6cc..40f3cb3bc 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -5,11 +5,22 @@ namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('openssl')] class openssl extends Extension { + public function patchBeforeBuildconf(): bool + { + // Fix php 8.5 alpha1~4 zts openssl build bug + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/openssl/config.m4', + 'WARNING("OpenSSL argon2 hashing not supported in ZTS mode for now");', + 'AC_DEFINE("HAVE_OPENSSL_ARGON2", 1, "Define to 1 to enable OpenSSL argon2 password hashing.");' + ); + return true; + } + public function patchBeforeMake(): bool { $patched = parent::patchBeforeMake(); From 2c5cf07e9c27b1e9c7be2d4d0ecafb27d0d9b9b3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 15:45:33 +0800 Subject: [PATCH 47/72] cs fix, fix file name --- src/SPC/builder/extension/openssl.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index 40f3cb3bc..a4e95b24b 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -14,7 +14,8 @@ class openssl extends Extension public function patchBeforeBuildconf(): bool { // Fix php 8.5 alpha1~4 zts openssl build bug - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/openssl/config.m4', + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/openssl/config.w32', 'WARNING("OpenSSL argon2 hashing not supported in ZTS mode for now");', 'AC_DEFINE("HAVE_OPENSSL_ARGON2", 1, "Define to 1 to enable OpenSSL argon2 password hashing.");' ); From 48a7d814f83e2a1dfa32c44fce6cea789c9bfec3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 17:00:35 +0800 Subject: [PATCH 48/72] Test jit --- src/globals/test-extensions.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 8ccbf5b4f..22e19c46b 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,25 +13,25 @@ // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - // '8.1', - // '8.2', - // '8.3', - // '8.4', + '8.1', + '8.2', + '8.3', + '8.4', '8.5', 'git', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - 'macos-13', // bin/spc for x86_64 + // 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 - 'macos-15', // bin/spc for arm64 - 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 + // 'macos-15', // bin/spc for arm64 + // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-22.04', // bin/spc-gnu-docker 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 - 'windows-latest', // .\bin\spc.ps1 + // 'windows-latest', // .\bin\spc.ps1 ]; // whether enable thread safe From 17ff5f63bf26a5fe15c6ea203b05fc1c9d20ac8f Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 2 Aug 2025 00:58:36 +0800 Subject: [PATCH 49/72] Update tests.yml --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a360e54a8..9cf38d81c 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 From 22a8191b9787669e4d528ea1d386885c2a695314 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 2 Aug 2025 01:29:20 +0800 Subject: [PATCH 50/72] Fix opcache jit option parsing in builder --- .github/workflows/tests.yml | 6 +++--- config/ext.json | 1 + src/SPC/builder/extension/opcache.php | 8 +------- src/SPC/builder/linux/LinuxBuilder.php | 18 +++++++++++++----- src/SPC/builder/macos/MacOSBuilder.php | 8 ++++++++ src/SPC/builder/windows/WindowsBuilder.php | 4 ++++ src/SPC/store/SourcePatcher.php | 17 +++++++++++++++++ src/globals/test-extensions.php | 8 ++++---- 8 files changed, 51 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9cf38d81c..a360e54a8 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 2cf81b180..817c744a0 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 6e2037792..b73dbbd67 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -51,13 +51,7 @@ public function patchBeforeBuildconf(): bool 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 28edeb223..0f139b4e9 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -66,6 +66,17 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $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 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $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 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($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 ce3b7cfb8..20a09970a 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -102,6 +102,13 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $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 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($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 fb49a0131..ac29ae3a2 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -89,6 +89,9 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void } } + $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 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void ($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 aa12127cc..b8f133c41 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -69,6 +69,23 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void ); } + // 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 22e19c46b..76e91529a 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,9 +13,9 @@ // 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 @@ // '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 From af62e55da8780ebe71b06309b27451e57b415f08 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 2 Aug 2025 01:38:32 +0800 Subject: [PATCH 51/72] Add missing space --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- src/SPC/builder/macos/MacOSBuilder.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 0f139b4e9..b3435146c 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -75,7 +75,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void } elseif ($opcache_jit) { $opcache_jit = false; } - $opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit' : '--disable-opcache-jit'; + $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 ' : ''; diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 20a09970a..768567c80 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -107,7 +107,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void if ($opcache_jit && $phpVersionID < 80500 && !$this->getExt('opcache')) { $opcache_jit = false; } - $opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit' : '--disable-opcache-jit'; + $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') . ' ') : ''; From f6eba32be5fb292fbb952d18c724a308339c139e Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 2 Aug 2025 02:38:24 +0800 Subject: [PATCH 52/72] Update tests.yml --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a360e54a8..9cf38d81c 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 From 65f74044d83a5cb80b2205baccf7ee4eaaa61025 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 2 Aug 2025 03:03:20 +0800 Subject: [PATCH 53/72] Update tests.yml --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9cf38d81c..a360e54a8 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 From e14301d9915d8babcfad2d07483880ffe59ce932 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 2 Aug 2025 18:07:32 +0800 Subject: [PATCH 54/72] Symbol workaround for cross toolchain --- src/SPC/builder/linux/LinuxBuilder.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b3435146c..a7758587d 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -97,9 +97,10 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP; // prepare build php envs + $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__'; $php_configure_env = SystemUtil::makeEnvVarString([ 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'), - 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, + 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH . $musl_flag, 'LDFLAGS' => '-L' . BUILD_LIB_PATH, // 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions! ]); @@ -343,12 +344,22 @@ protected function buildEmbed(): void $this->patchPhpScripts(); } + /** + * Return extra variables for php make command. + * + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + * @throws \ReflectionException + * @throws \Throwable + */ private function getMakeExtraVars(): array { $config = (new SPCConfigUtil($this, ['libs_only_deps' => true, 'absolute_libs' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs')); $static = SPCTarget::isStatic() ? '-all-static' : ''; $lib = BUILD_LIB_PATH; return [ + 'CPPFLAGS' => SPCTarget::getLibc() === 'musl' ? '-D__MUSL__' : '-U__MUSL__', 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'EXTRA_LIBS' => $config['libs'], 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), From 3960a21e05e7d7c94adc4e96a16ad9855fab25df Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 2 Aug 2025 18:40:55 +0800 Subject: [PATCH 55/72] Use full domain test list --- src/globals/ext-tests/curl.php | 28 +++++++++++++++++++++------- src/globals/ext-tests/openssl.php | 15 ++++++++++++++- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/globals/ext-tests/curl.php b/src/globals/ext-tests/curl.php index 7c3eecf79..16b31e6e9 100644 --- a/src/globals/ext-tests/curl.php +++ b/src/globals/ext-tests/curl.php @@ -6,13 +6,27 @@ assert(function_exists('curl_setopt')); assert(function_exists('curl_exec')); assert(function_exists('curl_close')); +assert(function_exists('curl_version')); $curl_version = curl_version(); if (stripos($curl_version['ssl_version'], 'schannel') !== false) { - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, 'https://captive.apple.com/'); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_HEADER, 0); - $data = curl_exec($curl); - curl_close($curl); - assert($data !== false); + $domain_list = [ + 'https://captive.apple.com/', + 'https://detectportal.firefox.com/', + 'https://static-php.dev/', + 'https://www.example.com/', + ]; + $valid = false; + foreach ($domain_list as $domain) { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $domain); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_HEADER, 0); + $data = curl_exec($curl); + curl_close($curl); + if ($data !== false) { + $valid = true; + break; + } + } + assert($valid); } diff --git a/src/globals/ext-tests/openssl.php b/src/globals/ext-tests/openssl.php index 79c863235..189c222e2 100644 --- a/src/globals/ext-tests/openssl.php +++ b/src/globals/ext-tests/openssl.php @@ -5,7 +5,20 @@ assert(function_exists('openssl_digest')); assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e'); if (file_exists('/etc/ssl/openssl.cnf')) { - assert(file_get_contents('https://captive.apple.com/') !== false); + $domain_list = [ + 'https://captive.apple.com/', + 'https://detectportal.firefox.com/', + 'https://static-php.dev/', + 'https://www.example.com/', + ]; + $valid = false; + foreach ($domain_list as $domain) { + if (file_get_contents($domain) !== false) { + $valid = true; + break; + } + } + assert($valid); } if (PHP_VERSION_ID >= 80500 && defined('OPENSSL_VERSION_NUMBER') && OPENSSL_VERSION_NUMBER >= 0x30200000) { assert(function_exists('openssl_password_hash')); From 38725c2bb4d4d5fcfe6de91b4ea6805a56380274 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 2 Aug 2025 22:22:09 +0800 Subject: [PATCH 56/72] Update ca certificates --- .github/workflows/tests.yml | 4 ++++ src/globals/test-extensions.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a360e54a8..f399a043e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -145,6 +145,10 @@ jobs: os: ${{ fromJSON(needs.define-matrix.outputs.os) }} fail-fast: false steps: + - name: "Update runner packages" + if: ${{ startsWith(matrix.os, 'ubuntu-') }} + run: sudo apt-get update && sudo apt-get install -y ca-certificates + - name: "Checkout" uses: actions/checkout@v4 diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 76e91529a..381099853 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -28,7 +28,7 @@ // 'macos-15', // bin/spc for arm64 // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 - // '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-24.04-arm', // bin/spc for arm64 'windows-latest', // .\bin\spc.ps1 From d0053534abd4aaca3b4eab78386cf89560cdb795 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 2 Aug 2025 23:06:16 +0800 Subject: [PATCH 57/72] tmate --- .github/workflows/tests.yml | 6 +++--- src/globals/test-extensions.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f399a043e..19e2afd99 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -206,6 +206,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/src/globals/test-extensions.php b/src/globals/test-extensions.php index 381099853..905fe46a6 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -16,8 +16,8 @@ // '8.1', // '8.2', // '8.3', - '8.4', - '8.5', + // '8.4', + // '8.5', 'git', ]; @@ -28,10 +28,10 @@ // 'macos-15', // bin/spc for arm64 // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 - '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-24.04-arm', // bin/spc for arm64 - 'windows-latest', // .\bin\spc.ps1 + // 'windows-latest', // .\bin\spc.ps1 ]; // whether enable thread safe From c3e9a2816bfbc11f57e49eab08c5dfc5963a23e5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 00:29:13 +0800 Subject: [PATCH 58/72] Test --- .github/workflows/tests.yml | 6 +++--- src/globals/test-extensions.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 19e2afd99..f399a043e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -206,6 +206,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/src/globals/test-extensions.php b/src/globals/test-extensions.php index 905fe46a6..2f9a6c752 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -16,9 +16,9 @@ // '8.1', // '8.2', // '8.3', - // '8.4', + '8.4', // '8.5', - 'git', + // 'git', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) @@ -26,10 +26,10 @@ // 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 // 'macos-15', // bin/spc for arm64 - // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 + 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-22.04', // bin/spc-gnu-docker 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 // 'windows-latest', // .\bin\spc.ps1 ]; From e6cf05ddffa3a7a0a9846b786468e11464641467 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 01:12:28 +0800 Subject: [PATCH 59/72] Test --- src/SPC/builder/linux/LinuxBuilder.php | 6 +++--- src/SPC/store/SourcePatcher.php | 10 ++++++++++ src/globals/test-extensions.php | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index a7758587d..b0f1efe74 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -97,10 +97,10 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP; // prepare build php envs - $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__'; + // $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__'; $php_configure_env = SystemUtil::makeEnvVarString([ 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'), - 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH . $musl_flag, + 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . $musl_flag, 'LDFLAGS' => '-L' . BUILD_LIB_PATH, // 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions! ]); @@ -359,7 +359,7 @@ private function getMakeExtraVars(): array $static = SPCTarget::isStatic() ? '-all-static' : ''; $lib = BUILD_LIB_PATH; return [ - 'CPPFLAGS' => SPCTarget::getLibc() === 'musl' ? '-D__MUSL__' : '-U__MUSL__', + // 'CPPFLAGS' => SPCTarget::getLibc() === 'musl' ? '-D__MUSL__' : '-U__MUSL__', 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'EXTRA_LIBS' => $config['libs'], 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index b8f133c41..1eed55953 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -86,6 +86,16 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void ); } + // patch configure.ac + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/configure.ac', + 'if command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1', + 'if [ "$SPC_LIBC" = "musl" ];' + ); + if (getenv('SPC_LIBC') === false && ($libc = SPCTarget::getLibc()) !== null) { + putenv("SPC_LIBC={$libc}"); + } + // 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 2f9a6c752..d311962db 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -18,7 +18,7 @@ // '8.3', '8.4', // '8.5', - // 'git', + 'git', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) @@ -28,7 +28,7 @@ // 'macos-15', // bin/spc for arm64 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 - // '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-24.04-arm', // bin/spc for arm64 // 'windows-latest', // .\bin\spc.ps1 From e7fe91faef6e8e3761a07ddfafad73d360489926 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 01:23:47 +0800 Subject: [PATCH 60/72] Fix patch, use pure socket client directly --- src/SPC/store/SourcePatcher.php | 3 ++- src/globals/ext-tests/openssl.php | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 1eed55953..1f00db688 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -87,10 +87,11 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void } // patch configure.ac + $musl = SPCTarget::getLibc() === 'musl'; FileSystem::replaceFileStr( SOURCE_PATH . '/php-src/configure.ac', 'if command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1', - 'if [ "$SPC_LIBC" = "musl" ];' + 'if ' . ($musl ? 'true' : 'false') ); if (getenv('SPC_LIBC') === false && ($libc = SPCTarget::getLibc()) !== null) { putenv("SPC_LIBC={$libc}"); diff --git a/src/globals/ext-tests/openssl.php b/src/globals/ext-tests/openssl.php index 189c222e2..c687d0fc7 100644 --- a/src/globals/ext-tests/openssl.php +++ b/src/globals/ext-tests/openssl.php @@ -6,14 +6,25 @@ assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e'); if (file_exists('/etc/ssl/openssl.cnf')) { $domain_list = [ - 'https://captive.apple.com/', - 'https://detectportal.firefox.com/', - 'https://static-php.dev/', - 'https://www.example.com/', + 'captive.apple.com', + 'detectportal.firefox.com', + 'static-php.dev', + 'www.example.com', ]; $valid = false; foreach ($domain_list as $domain) { - if (file_get_contents($domain) !== false) { + $ssloptions = [ + 'capture_peer_cert' => true, + 'capture_peer_cert_chain' => true, + 'allow_self_signed' => false, + 'CN_match' => $domain, + 'verify_peer' => true, + 'SNI_enabled' => true, + 'SNI_server_name' => $domain, + ]; + $context = stream_context_create(['ssl' => $ssloptions]); + $result = stream_socket_client("ssl://{$domain}:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); + if ($result !== false) { $valid = true; break; } From 9a5a59d8764d481ed5e527d987abdbbd7aa3eb92 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 01:49:15 +0800 Subject: [PATCH 61/72] Test --- src/SPC/builder/linux/LinuxBuilder.php | 4 ++-- src/SPC/store/SourcePatcher.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b0f1efe74..cb3d7c6f5 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -100,7 +100,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void // $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__'; $php_configure_env = SystemUtil::makeEnvVarString([ 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'), - 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . $musl_flag, + 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH . ' -Dsomethinghere', // . $musl_flag, 'LDFLAGS' => '-L' . BUILD_LIB_PATH, // 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions! ]); @@ -359,7 +359,7 @@ private function getMakeExtraVars(): array $static = SPCTarget::isStatic() ? '-all-static' : ''; $lib = BUILD_LIB_PATH; return [ - // 'CPPFLAGS' => SPCTarget::getLibc() === 'musl' ? '-D__MUSL__' : '-U__MUSL__', + 'CPPFLAGS' => '-Dsomethinghere', 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'EXTRA_LIBS' => $config['libs'], 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 1f00db688..6d15face2 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -87,6 +87,7 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void } // patch configure.ac + /* $musl = SPCTarget::getLibc() === 'musl'; FileSystem::replaceFileStr( SOURCE_PATH . '/php-src/configure.ac', @@ -96,6 +97,7 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void if (getenv('SPC_LIBC') === false && ($libc = SPCTarget::getLibc()) !== null) { putenv("SPC_LIBC={$libc}"); } + */ // 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('); From 643926886c12031a7baeaba91476f108b52e886f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 02:00:19 +0800 Subject: [PATCH 62/72] Test original --- src/SPC/builder/linux/LinuxBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index cb3d7c6f5..9ca0acf24 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -100,7 +100,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void // $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__'; $php_configure_env = SystemUtil::makeEnvVarString([ 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'), - 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH . ' -Dsomethinghere', // . $musl_flag, + 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag, 'LDFLAGS' => '-L' . BUILD_LIB_PATH, // 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions! ]); @@ -359,7 +359,7 @@ private function getMakeExtraVars(): array $static = SPCTarget::isStatic() ? '-all-static' : ''; $lib = BUILD_LIB_PATH; return [ - 'CPPFLAGS' => '-Dsomethinghere', + // 'CPPFLAGS' => '-Dsomethinghere', 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'EXTRA_LIBS' => $config['libs'], 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), From f1a9a28ed7439e7c1c6ffca516b2905f8529a7b8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 02:06:08 +0800 Subject: [PATCH 63/72] Use backup file function to avoid multiple build conflict --- src/SPC/store/SourcePatcher.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 6d15face2..85b7ddf10 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -87,8 +87,8 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void } // patch configure.ac - /* $musl = SPCTarget::getLibc() === 'musl'; + FileSystem::backupFile(SOURCE_PATH . '/php-src/configure.ac'); FileSystem::replaceFileStr( SOURCE_PATH . '/php-src/configure.ac', 'if command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1', @@ -97,7 +97,6 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void if (getenv('SPC_LIBC') === false && ($libc = SPCTarget::getLibc()) !== null) { putenv("SPC_LIBC={$libc}"); } - */ // 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('); @@ -132,6 +131,11 @@ public static function patchBeforeConfigure(BuilderBase $builder): void if (is_unix()) { FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); } + + if (file_exists(SOURCE_PATH . '/php-src/configure.ac.bak')) { + // restore configure.ac + FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/configure.ac'); + } } /** From b644da821017e72af315099a3e3dd99a1436eaa2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 22:45:24 +0800 Subject: [PATCH 64/72] Remove redundant patches for openssl --- src/SPC/builder/extension/openssl.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index a4e95b24b..ec481b6cc 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -5,23 +5,11 @@ namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('openssl')] class openssl extends Extension { - public function patchBeforeBuildconf(): bool - { - // Fix php 8.5 alpha1~4 zts openssl build bug - FileSystem::replaceFileStr( - SOURCE_PATH . '/php-src/ext/openssl/config.w32', - 'WARNING("OpenSSL argon2 hashing not supported in ZTS mode for now");', - 'AC_DEFINE("HAVE_OPENSSL_ARGON2", 1, "Define to 1 to enable OpenSSL argon2 password hashing.");' - ); - return true; - } - public function patchBeforeMake(): bool { $patched = parent::patchBeforeMake(); From 2d6d25cadf2f6d5f09ada0541da045366c5bd4f1 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 3 Aug 2025 22:46:47 +0800 Subject: [PATCH 65/72] Update src/SPC/builder/linux/LinuxBuilder.php Co-authored-by: Marc --- src/SPC/builder/linux/LinuxBuilder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 9ca0acf24..38990403b 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -359,7 +359,6 @@ private function getMakeExtraVars(): array $static = SPCTarget::isStatic() ? '-all-static' : ''; $lib = BUILD_LIB_PATH; return [ - // 'CPPFLAGS' => '-Dsomethinghere', 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'EXTRA_LIBS' => $config['libs'], 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), From 93001dce88fff209141124df37cd187332db9f67 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 3 Aug 2025 22:47:02 +0800 Subject: [PATCH 66/72] Update src/SPC/builder/macos/MacOSBuilder.php Co-authored-by: Marc --- src/SPC/builder/macos/MacOSBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 768567c80..feef96297 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -99,7 +99,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void SourcePatcher::patchBeforeConfigure($this); $phpVersionID = $this->getPHPVersionID(); - $json_74 = $phpVersionID < 80000 ? '--enable-json ' : ''; + $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; $opcache_jit = !$this->getOption('disable-opcache-jit', false); From 430f436b79672dba7155f93ff39608cef463b882 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 3 Aug 2025 22:48:09 +0800 Subject: [PATCH 67/72] Update src/SPC/builder/macos/MacOSBuilder.php Co-authored-by: Marc --- src/SPC/builder/macos/MacOSBuilder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index feef96297..aa40f1880 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -98,7 +98,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $this->emitPatchPoint('before-php-configure'); SourcePatcher::patchBeforeConfigure($this); - $phpVersionID = $this->getPHPVersionID(); $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; From ea4905cd0d57558bd5c6569f8a2ab4520572f623 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 22:59:40 +0800 Subject: [PATCH 68/72] Add argon2 support for PHP-NTS < 8.5 --- src/SPC/builder/extension/openssl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index ec481b6cc..c3c50a4f7 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -28,7 +28,7 @@ public function getUnixConfigureArg(bool $shared = false): string { $openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH; $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; - if ($this->builder->getPHPVersionID() >= 80500) { + if ($this->builder->getPHPVersionID() >= 80500 || !$this->builder->getOption('enable-zts')) { $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"'; } return $args; From 4cbe4ea82d9f0162b1d49866da2bf31b3d0b5f42 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 23:01:09 +0800 Subject: [PATCH 69/72] Revert corrupted revert --- src/SPC/builder/macos/MacOSBuilder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index aa40f1880..768567c80 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -98,7 +98,8 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $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); From 81e7a0c554184ae3ea21af0e7ac393cf004f8aed Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 3 Aug 2025 23:01:24 +0800 Subject: [PATCH 70/72] Add without argon2 option --- src/SPC/builder/extension/openssl.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index c3c50a4f7..2aba23444 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -30,6 +30,8 @@ public function getUnixConfigureArg(bool $shared = false): string $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; if ($this->builder->getPHPVersionID() >= 80500 || !$this->builder->getOption('enable-zts')) { $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"'; + } else { + $args .= ' --without-openssl-argon2'; } return $args; } From 4fb4e428968fa4182babc4109e4a0db7dc56efb9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 4 Aug 2025 01:10:08 +0800 Subject: [PATCH 71/72] Revert --- src/SPC/builder/extension/openssl.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index 2aba23444..c3c50a4f7 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -30,8 +30,6 @@ public function getUnixConfigureArg(bool $shared = false): string $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; if ($this->builder->getPHPVersionID() >= 80500 || !$this->builder->getOption('enable-zts')) { $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"'; - } else { - $args .= ' --without-openssl-argon2'; } return $args; } From 3789c7c335aab676bfb7e8c4fd78223b8d1d339b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 4 Aug 2025 10:14:48 +0700 Subject: [PATCH 72/72] only enable one of password-argon2 or openssl-argon2 --- config/ext.json | 5 +++-- src/SPC/builder/extension/openssl.php | 4 ++-- src/SPC/builder/extension/password_argon2.php | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index 817c744a0..14eabf17e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -531,9 +531,10 @@ }, "notes": true, "type": "builtin", - "arg-type": "with-path", + "arg-type": "custom", "lib-depends": [ - "libargon2" + "libargon2", + "openssl" ] }, "pcntl": { diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index c3c50a4f7..bf61fa371 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -28,7 +28,7 @@ public function getUnixConfigureArg(bool $shared = false): string { $openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH; $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; - if ($this->builder->getPHPVersionID() >= 80500 || !$this->builder->getOption('enable-zts')) { + if ($this->builder->getPHPVersionID() >= 80500 || ($this->builder->getPHPVersionID() >= 80400 && !$this->builder->getOption('enable-zts'))) { $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"'; } return $args; @@ -37,7 +37,7 @@ public function getUnixConfigureArg(bool $shared = false): string public function getWindowsConfigureArg(bool $shared = false): string { $args = '--with-openssl'; - if ($this->builder->getPHPVersionID() >= 80500) { + if ($this->builder->getPHPVersionID() >= 80500 || ($this->builder->getPHPVersionID() >= 80400 && !$this->builder->getOption('enable-zts'))) { $args .= ' --with-openssl-argon2'; } return $args; diff --git a/src/SPC/builder/extension/password_argon2.php b/src/SPC/builder/extension/password_argon2.php index 4a7fd9d07..7a3d8e0cf 100644 --- a/src/SPC/builder/extension/password_argon2.php +++ b/src/SPC/builder/extension/password_argon2.php @@ -42,4 +42,14 @@ public function patchBeforeMake(): bool } return $patched; } + + public function getConfigureArg(bool $shared = false): string + { + if ($this->builder->getLib('openssl') !== null) { + if ($this->builder->getPHPVersionID() >= 80500 || ($this->builder->getPHPVersionID() >= 80400 && !$this->builder->getOption('enable-zts'))) { + return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead + } + } + return '--with-password-argon2'; + } }