From c6d4934dd6bf1ce367dcf1d0a73f0a367e1118b8 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 13 Mar 2025 14:18:27 +0800 Subject: [PATCH] Fix gmssl and openssl duplicate symbol (#632) * Fix gmssl and openssl duplicate symbol * Add tests --- config/source.json | 1 + src/SPC/store/SourcePatcher.php | 7 +++++++ src/globals/test-extensions.php | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index e42fc0e7..0b7006cf 100644 --- a/config/source.json +++ b/config/source.json @@ -261,6 +261,7 @@ "gmssl": { "type": "ghtar", "repo": "guanzhi/GmSSL", + "provide-pre-built": true, "license": { "type": "file", "path": "LICENSE" diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index bbb07a8f..4501fee6 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -30,6 +30,7 @@ class SourcePatcher FileSystem::addSourceExtractHook('ext-imagick', [SourcePatcher::class, 'patchImagickWith84']); FileSystem::addSourceExtractHook('libaom', [SourcePatcher::class, 'patchLibaomForAlpine']); FileSystem::addSourceExtractHook('attr', [SourcePatcher::class, 'patchAttrForAlpine']); + FileSystem::addSourceExtractHook('gmssl', [SourcePatcher::class, 'patchGMSSL']); } /** @@ -541,4 +542,10 @@ class SourcePatcher rename(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak', SOURCE_PATH . '\php-src\sapi\micro\php_micro.c'); } } + + public static function patchGMSSL(): void + { + FileSystem::replaceFileStr(SOURCE_PATH . '/gmssl/src/hex.c', 'unsigned char *OPENSSL_hexstr2buf(const char *str, size_t *len)', 'unsigned char *GMSSL_hexstr2buf(const char *str, size_t *len)'); + FileSystem::replaceFileStr(SOURCE_PATH . '/gmssl/src/hex.c', 'OPENSSL_hexchar2int', 'GMSSL_hexchar2int'); + } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 6e2890c4..af69ff2f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -28,7 +28,7 @@ $test_os = [ ]; // whether enable thread safe -$zts = true; +$zts = false; $no_strip = false; @@ -40,7 +40,7 @@ $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) { - 'Linux', 'Darwin' => 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,gettext,iconv,igbinary,imagick,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,parallel,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,ssh2,sysvmsg,sysvsem,sysvshm,tidy,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib,yaml,zstd', + 'Linux', 'Darwin' => 'openssl,gmssl', 'Windows' => 'gettext', };