From b9d4e122c8b29625bdce62d9c59566f3f9928b3b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 16 Jun 2026 16:24:38 +0800 Subject: [PATCH 1/4] Fix gmssl build --- config/pkg/ext/ext-gmssl.yml | 2 ++ src/Package/Extension/gmssl.php | 44 +++++++++++++++++++++++++++++++++ src/Package/Library/gmssl.php | 5 +++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Package/Extension/gmssl.php diff --git a/config/pkg/ext/ext-gmssl.yml b/config/pkg/ext/ext-gmssl.yml index 7ed8981d7..2bf156081 100644 --- a/config/pkg/ext/ext-gmssl.yml +++ b/config/pkg/ext/ext-gmssl.yml @@ -10,3 +10,5 @@ ext-gmssl: license: PHP-3.01 depends: - gmssl + php-extension: + arg-type@unix: with-path diff --git a/src/Package/Extension/gmssl.php b/src/Package/Extension/gmssl.php new file mode 100644 index 000000000..7092b041b --- /dev/null +++ b/src/Package/Extension/gmssl.php @@ -0,0 +1,44 @@ += 3.1.0 where SM2_VERIFY_CTX was removed (unified into SM2_SIGN_CTX)')] + public function patchSm2VerifyCtx(): void + { + // See: https://github.com/crazywhalecc/static-php-cli/issues/1182 + FileSystem::replaceFileStr( + "{$this->getSourceDir()}/gmssl.c", + 'SM2_VERIFY_CTX', + 'SM2_SIGN_CTX' + ); + } + + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')] + #[PatchDescription('Add CHECK_LIB to config.w32 for static Windows builds')] + public function patchBeforeBuildconfWin(): bool + { + $configW32 = "{$this->getSourceDir()}/config.w32"; + if (str_contains(FileSystem::readFile($configW32), 'CHECK_LIB(')) { + return false; + } + FileSystem::replaceFileStr( + $configW32, + 'AC_DEFINE(', + 'CHECK_LIB("gmssl.lib", "gmssl", PHP_GMSSL);' . PHP_EOL . 'AC_DEFINE(' + ); + return true; + } +} diff --git a/src/Package/Library/gmssl.php b/src/Package/Library/gmssl.php index 7785e55a4..8887b64fe 100644 --- a/src/Package/Library/gmssl.php +++ b/src/Package/Library/gmssl.php @@ -18,7 +18,9 @@ class gmssl #[BuildFor('Darwin')] public function build(LibraryPackage $lib): void { - UnixCMakeExecutor::create($lib)->build(); + UnixCMakeExecutor::create($lib) + ->addConfigureArgs('-DENABLE_SM2_PRIVATE_KEY_EXPORT=ON') + ->build(); } #[BuildFor('Windows')] @@ -33,6 +35,7 @@ public function buildWin(LibraryPackage $lib): void '-G "NMake Makefiles"', '-DWIN32=ON', '-DBUILD_SHARED_LIBS=OFF', + '-DENABLE_SM2_PRIVATE_KEY_EXPORT=ON', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"', '-DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"', From 9b9fbe2735a056eb8b70cddf7be13a9ad977b1f7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 16 Jun 2026 16:25:34 +0800 Subject: [PATCH 2/4] Fix version parsing error in file list downloader --- src/StaticPHP/Artifact/Downloader/Type/FileList.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/StaticPHP/Artifact/Downloader/Type/FileList.php b/src/StaticPHP/Artifact/Downloader/Type/FileList.php index b868210de..4c895515d 100644 --- a/src/StaticPHP/Artifact/Downloader/Type/FileList.php +++ b/src/StaticPHP/Artifact/Downloader/Type/FileList.php @@ -45,7 +45,11 @@ protected function fetchFileList(string $name, array $config, ArtifactDownloader throw new DownloaderException("Failed to get {$name} file list from {$config['url']}"); } $versions = []; - logger()->debug('Matched ' . count($matches['version']) . " versions for {$name}"); + $cnt = count($matches['version']); + if ($cnt === 0) { + throw new DownloaderException("Failed to get {$name} file list from {$config['url']}: no version parsed"); + } + logger()->debug("Matched {$cnt} versions for {$name}"); foreach ($matches['version'] as $i => $version) { $lower = strtolower($version); foreach (['alpha', 'beta', 'rc', 'pre', 'nightly', 'snapshot', 'dev'] as $beta) { From e86973f62c86cd7e158cc1b028394d4c26481234 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 16 Jun 2026 18:22:06 +0800 Subject: [PATCH 3/4] Fix argument type specification in ext-gmssl.yml --- config/pkg/ext/ext-gmssl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/pkg/ext/ext-gmssl.yml b/config/pkg/ext/ext-gmssl.yml index 2bf156081..41a32fb9b 100644 --- a/config/pkg/ext/ext-gmssl.yml +++ b/config/pkg/ext/ext-gmssl.yml @@ -11,4 +11,4 @@ ext-gmssl: depends: - gmssl php-extension: - arg-type@unix: with-path + arg-type: with-path From 0e8d4ac271380e69c78d99d248d91d9b0a2ce7da Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 16 Jun 2026 18:30:25 +0800 Subject: [PATCH 4/4] Add windows patch too --- src/Package/Extension/gmssl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Package/Extension/gmssl.php b/src/Package/Extension/gmssl.php index 7092b041b..372e7d7c4 100644 --- a/src/Package/Extension/gmssl.php +++ b/src/Package/Extension/gmssl.php @@ -15,6 +15,7 @@ class gmssl extends PhpExtensionPackage { #[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-gmssl')] + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')] #[PatchDescription('Fix ext-gmssl v1.1.1 compatibility with GmSSL >= 3.1.0 where SM2_VERIFY_CTX was removed (unified into SM2_SIGN_CTX)')] public function patchSm2VerifyCtx(): void {