From e975e151f9394222fbd942f58e209c9b096dfb18 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 11:09:02 +0700 Subject: [PATCH 01/53] swoole hooks can be compiled if pgsql/sqlite are not compiled in statically --- src/SPC/builder/extension/swoole_hook_mysql.php | 2 +- src/SPC/builder/extension/swoole_hook_pgsql.php | 2 +- src/SPC/builder/extension/swoole_hook_sqlite.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index 273e8ec0..cde73955 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -35,7 +35,7 @@ class swoole_hook_mysql extends Extension throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: 'extension swoole_hook_mysql sanity check'); } if (!str_contains($out, 'mysqlnd')) { - throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook avilability check'); + throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook availability check'); } } } diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 9849de7b..15b2e1d8 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -20,7 +20,7 @@ class swoole_hook_pgsql extends Extension public function validate(): void { // pdo_pgsql need to be disabled - if ($this->builder->getExt('pdo_pgsql') !== null) { + if ($this->builder->getExt('pdo_pgsql')?->isBuildStatic()) { throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.'); } } diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 1a8fff6d..a8903a82 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -20,7 +20,7 @@ class swoole_hook_sqlite extends Extension public function validate(): void { // pdo_pgsql need to be disabled - if ($this->builder->getExt('pdo_sqlite') !== null) { + if ($this->builder->getExt('pdo_sqlite')?->isBuildStatic()) { throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.'); } } From 779a7248750c51518f565e5fefae54e47add0af0 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 11:21:08 +0700 Subject: [PATCH 02/53] go's gcc driver is the dumbest shit to ever exist --- src/SPC/util/SPCConfigUtil.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 86d197c8..dbc29a36 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -8,6 +8,9 @@ use SPC\builder\BuilderBase; use SPC\builder\BuilderProvider; use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\toolchain\ClangNativeToolchain; +use SPC\toolchain\GccNativeToolchain; +use SPC\toolchain\ToolchainManager; use Symfony\Component\Console\Input\ArgvInput; class SPCConfigUtil @@ -78,6 +81,9 @@ class SPCConfigUtil if (SPCTarget::getTargetOS() === 'Darwin') { $libs .= " {$this->getFrameworksString($extensions)}"; } + if (str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') && ToolchainManager::getToolchainClass() === GccNativeToolchain::class) { + $libs .= ' -lgcov'; + } if ($this->builder->hasCpp()) { $libcpp = SPCTarget::getTargetOS() === 'Darwin' ? '-lc++' : '-lstdc++'; $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; From 75f734daa8b0778973853f30dc9a634a261b1d11 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 11:22:35 +0700 Subject: [PATCH 03/53] cs fix --- src/SPC/util/SPCConfigUtil.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index dbc29a36..d0c1cf73 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -8,7 +8,6 @@ use SPC\builder\BuilderBase; use SPC\builder\BuilderProvider; use SPC\exception\WrongUsageException; use SPC\store\Config; -use SPC\toolchain\ClangNativeToolchain; use SPC\toolchain\GccNativeToolchain; use SPC\toolchain\ToolchainManager; use Symfony\Component\Console\Input\ArgvInput; From 8104ff7236cb544c77bf2076cb7195eab901cbae Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:08:53 +0700 Subject: [PATCH 04/53] update checks for shared swoole-hook extensions --- config/ext.json | 9 ++++++--- src/SPC/builder/extension/swoole.php | 4 ++-- src/SPC/builder/extension/swoole_hook_mysql.php | 11 +++++++++++ src/SPC/builder/extension/swoole_hook_pgsql.php | 11 +++++++++++ src/SPC/builder/extension/swoole_hook_sqlite.php | 11 +++++++++++ src/SPC/command/BuildPHPCommand.php | 2 +- 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/config/ext.json b/config/ext.json index 87097c4b..3783d3bf 100644 --- a/config/ext.json +++ b/config/ext.json @@ -863,7 +863,8 @@ "ext-depends": [ "mysqlnd", "pdo", - "pdo_mysql" + "pdo_mysql", + "swoole" ], "ext-suggests": [ "mysqli" @@ -880,7 +881,8 @@ "arg-type": "custom", "ext-depends": [ "pgsql", - "pdo" + "pdo", + "swoole" ] }, "swoole-hook-sqlite": { @@ -893,7 +895,8 @@ "arg-type": "custom", "ext-depends": [ "sqlite3", - "pdo" + "pdo", + "swoole" ] }, "swow": { diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 00085e8b..3ae02ff9 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -61,11 +61,11 @@ class swoole extends Extension // additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc. // so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support) - $arg .= $this->builder->getExt('swoole-hook-pgsql') ? '' : ' --disable-swoole-pgsql'; + $arg .= $this->builder->getExt('swoole-hook-pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql'; // enable this feature , need remove pdo_sqlite // more info : https://wenda.swoole.com/detail/109023 - $arg .= $this->builder->getExt('swoole-hook-sqlite') ? '' : ' --disable-swoole-sqlite'; + $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; // enable this feature , need stop pdo_* // $arg .= $this->builder->getLib('unixodbc') ? ' --with-swoole-odbc=unixODBC,' : ' '; diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index cde73955..ee942142 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -38,4 +38,15 @@ class swoole_hook_mysql extends Extension throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook availability check'); } } + + public function getSharedExtensionLoadString(): string + { + $ret = parent::getSharedExtensionLoadString(); + return str_replace(' -d "extension=' . $this->name . '"', '', $ret); + } + + public function buildShared(): void + { + // nothing to do, it's built into swoole + } } diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 15b2e1d8..15a6dda5 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -53,4 +53,15 @@ class swoole_hook_pgsql extends Extension ); } } + + public function getSharedExtensionLoadString(): string + { + $ret = parent::getSharedExtensionLoadString(); + return str_replace(' -d "extension=' . $this->name . '"', '', $ret); + } + + public function buildShared(): void + { + // nothing to do, it's built into swoole + } } diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index a8903a82..a5fcc3b4 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -47,4 +47,15 @@ class swoole_hook_sqlite extends Extension throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check'); } } + + public function getSharedExtensionLoadString(): string + { + $ret = parent::getSharedExtensionLoadString(); + return str_replace(' -d "extension=' . $this->name . '"', '', $ret); + } + + public function buildShared(): void + { + // nothing to do, it's built into swoole + } } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index aaf902ba..4f07d5ea 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -252,7 +252,7 @@ class BuildPHPCommand extends BuildCommand $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); if (file_exists(BUILD_MODULES_PATH . "/{$ext}.so")) { logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); - } else { + } elseif (!str_contains($ext, 'swoole-hook')) { logger()->warning("Shared extension [{$ext}] not found, please check!"); } } From 7e0e9091be72cc5b71f28e497e4bc85dd102482f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:11:56 +0700 Subject: [PATCH 05/53] explicitly enable swoole-mysql too --- src/SPC/builder/extension/swoole.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 3ae02ff9..c1419dba 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -63,6 +63,9 @@ class swoole extends Extension // so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support) $arg .= $this->builder->getExt('swoole-hook-pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql'; + // additional feature: swoole-mysql + $arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-swoole-mysql' : ' --disable-swoole-mysql'; + // enable this feature , need remove pdo_sqlite // more info : https://wenda.swoole.com/detail/109023 $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; From 448941f741ea5d5c80bc743f5b49635a9cbb197e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:36:10 +0700 Subject: [PATCH 06/53] don't request configurearg if it's not used (ease debugging) --- config/ext.json | 4 ++++ src/SPC/builder/BuilderBase.php | 5 +++-- src/SPC/builder/extension/swoole.php | 15 ++++++++++----- src/SPC/builder/extension/swoole_hook_pgsql.php | 3 +-- src/SPC/builder/extension/swoole_hook_sqlite.php | 3 +-- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/config/ext.json b/config/ext.json index 3783d3bf..d1c8878e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -842,11 +842,15 @@ "nghttp2", "zlib" ], + "lib-suggests": [ + "zstd" + ], "ext-depends": [ "openssl", "curl" ], "ext-suggests": [ + "sockets", "swoole-hook-pgsql", "swoole-hook-mysql", "swoole-hook-sqlite" diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 693c4dfd..3bd0b538 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -268,11 +268,11 @@ abstract class BuilderBase { $ret = []; foreach ($this->getExts() as $ext) { - $arg = $ext->getConfigureArg(); + $arg = null; if ($ext->isBuildShared() && !$ext->isBuildStatic()) { if ( (Config::getExt($ext->getName(), 'type') === 'builtin' && - !file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) || + !file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) || Config::getExt($ext->getName(), 'build-with-php') === true ) { $arg = $ext->getConfigureArg(true); @@ -280,6 +280,7 @@ abstract class BuilderBase continue; } } + $arg ??= $ext->getConfigureArg(); logger()->info($ext->getName() . ' is using ' . $arg); $ret[] = trim($arg); } diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index c1419dba..1f4db48a 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -43,14 +43,16 @@ class swoole extends Extension public function getUnixConfigureArg(bool $shared = false): string { // enable swoole - $arg = '--enable-swoole'; + $arg = '--enable-swoole' . ($shared ? '=shared' : ''); - // commonly-used feature: coroutine-time, disable-thread-context - $arg .= ' --enable-swoole-coro-time --disable-thread-context'; + // commonly-used feature: coroutine-time + $arg .= ' --enable-swoole-coro-time --with-pic'; + + $arg .= $this->builder->getOption('enable-zts') ? ' --enable-thread-context' : ' --disable-thread-context'; // required feature: curl, openssl (but curl hook is buggy for php 8.0) $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; - $arg .= ' --enable-openssl'; + $arg .= ' --enable-openssl'; // we depend on openssl so it's always enabled // additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature) $arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : ''; @@ -58,13 +60,16 @@ class swoole extends Extension $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; } $arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : ''; + $arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : ''; + $arg .= $this->builder->getLib('iouring') ? ' --enable-iouring' : ''; + $arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : ''; // additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc. // so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support) $arg .= $this->builder->getExt('swoole-hook-pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql'; // additional feature: swoole-mysql - $arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-swoole-mysql' : ' --disable-swoole-mysql'; + $arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd'; // enable this feature , need remove pdo_sqlite // more info : https://wenda.swoole.com/detail/109023 diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 15a6dda5..18f85fac 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -27,8 +27,7 @@ class swoole_hook_pgsql extends Extension public function getUnixConfigureArg(bool $shared = false): string { - // enable swoole pgsql hook - return '--enable-swoole-pgsql'; + return ''; // enabled in swoole.php } public function runCliCheckUnix(): void diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index a5fcc3b4..4360c946 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -27,8 +27,7 @@ class swoole_hook_sqlite extends Extension public function getUnixConfigureArg(bool $shared = false): string { - // enable swoole pgsql hook - return '--enable-swoole-sqlite'; + return ''; // enabled in swoole.php } public function runCliCheckUnix(): void From b6d4af218be91b61d9a40b447769d89f2cb7c02e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:42:36 +0700 Subject: [PATCH 07/53] zts -> --enable-swoole-thread --- src/SPC/builder/extension/swoole.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 1f4db48a..654ee6a6 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -48,7 +48,7 @@ class swoole extends Extension // commonly-used feature: coroutine-time $arg .= ' --enable-swoole-coro-time --with-pic'; - $arg .= $this->builder->getOption('enable-zts') ? ' --enable-thread-context' : ' --disable-thread-context'; + $arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context'; // required feature: curl, openssl (but curl hook is buggy for php 8.0) $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; @@ -76,7 +76,7 @@ class swoole extends Extension $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; // enable this feature , need stop pdo_* - // $arg .= $this->builder->getLib('unixodbc') ? ' --with-swoole-odbc=unixODBC,' : ' '; + $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pgo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' : ' '; return $arg; } } From 93223a9d447945890bcb938996134fceb5c0e64c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:43:21 +0700 Subject: [PATCH 08/53] too much pgo, too little pdo --- src/SPC/builder/extension/swoole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 654ee6a6..bf739fb7 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -76,7 +76,7 @@ class swoole extends Extension $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; // enable this feature , need stop pdo_* - $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pgo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' : ' '; + $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pdo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' : ' '; return $arg; } } From 1c7fa0132d58f64b872edfacbdeba440ed061bc5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:44:34 +0700 Subject: [PATCH 09/53] remove space --- src/SPC/builder/extension/swoole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index bf739fb7..d3559814 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -76,7 +76,7 @@ class swoole extends Extension $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; // enable this feature , need stop pdo_* - $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pdo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' : ' '; + $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pdo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH : ''; return $arg; } } From 324ba0d3dc07ca9259bc3874f8cb128d8fd1a076 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:57:49 +0700 Subject: [PATCH 10/53] use type=addon and arg-type=none --- config/ext.json | 9 +++++---- src/SPC/builder/Extension.php | 6 ++++++ .../builder/extension/swoole_hook_mysql.php | 20 +------------------ .../builder/extension/swoole_hook_pgsql.php | 16 --------------- .../builder/extension/swoole_hook_sqlite.php | 16 --------------- 5 files changed, 12 insertions(+), 55 deletions(-) diff --git a/config/ext.json b/config/ext.json index d1c8878e..852d1da3 100644 --- a/config/ext.json +++ b/config/ext.json @@ -843,7 +843,8 @@ "zlib" ], "lib-suggests": [ - "zstd" + "zstd", + "unixodbc" ], "ext-depends": [ "openssl", @@ -863,7 +864,7 @@ }, "notes": true, "type": "addon", - "arg-type": "custom", + "arg-type": "none", "ext-depends": [ "mysqlnd", "pdo", @@ -882,7 +883,7 @@ }, "notes": true, "type": "addon", - "arg-type": "custom", + "arg-type": "none", "ext-depends": [ "pgsql", "pdo", @@ -896,7 +897,7 @@ }, "notes": true, "type": "addon", - "arg-type": "custom", + "arg-type": "none", "ext-depends": [ "sqlite3", "pdo", diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 75a008c1..faae465c 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -269,6 +269,9 @@ class Extension $ret = ''; foreach ($order as $ext) { if ($ext instanceof self && $ext->isBuildShared()) { + if (Config::getExt($ext->getName(), 'type', false) === 'addon') { + continue; + } if (Config::getExt($ext->getName(), 'zend-extension', false) === true) { $ret .= " -d \"zend_extension={$ext->getName()}\""; } else { @@ -352,6 +355,9 @@ class Extension */ public function buildShared(): void { + if (Config::getExt($this->getName(), 'type') === 'addon') { + return; + } try { if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) { if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index ee942142..0c005aee 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -16,20 +16,13 @@ class swoole_hook_mysql extends Extension return 'swoole'; } - public function getUnixConfigureArg(bool $shared = false): string - { - // pdo_mysql doesn't need to be disabled - // enable swoole-hook-mysql will enable mysqli, pdo, pdo_mysql, we don't need to add any additional options - return ''; - } - public function runCliCheckUnix(): void { // skip if not enable swoole if ($this->builder->getExt('swoole') === null) { return; } - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"'); $out = implode('', $out); if ($ret !== 0) { throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: 'extension swoole_hook_mysql sanity check'); @@ -38,15 +31,4 @@ class swoole_hook_mysql extends Extension throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook availability check'); } } - - public function getSharedExtensionLoadString(): string - { - $ret = parent::getSharedExtensionLoadString(); - return str_replace(' -d "extension=' . $this->name . '"', '', $ret); - } - - public function buildShared(): void - { - // nothing to do, it's built into swoole - } } diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 18f85fac..7bbc1a1f 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -25,11 +25,6 @@ class swoole_hook_pgsql extends Extension } } - public function getUnixConfigureArg(bool $shared = false): string - { - return ''; // enabled in swoole.php - } - public function runCliCheckUnix(): void { // skip if not enable swoole @@ -52,15 +47,4 @@ class swoole_hook_pgsql extends Extension ); } } - - public function getSharedExtensionLoadString(): string - { - $ret = parent::getSharedExtensionLoadString(); - return str_replace(' -d "extension=' . $this->name . '"', '', $ret); - } - - public function buildShared(): void - { - // nothing to do, it's built into swoole - } } diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 4360c946..4985bd5c 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -25,11 +25,6 @@ class swoole_hook_sqlite extends Extension } } - public function getUnixConfigureArg(bool $shared = false): string - { - return ''; // enabled in swoole.php - } - public function runCliCheckUnix(): void { // skip if not enable swoole @@ -46,15 +41,4 @@ class swoole_hook_sqlite extends Extension throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check'); } } - - public function getSharedExtensionLoadString(): string - { - $ret = parent::getSharedExtensionLoadString(); - return str_replace(' -d "extension=' . $this->name . '"', '', $ret); - } - - public function buildShared(): void - { - // nothing to do, it's built into swoole - } } From a46ad7b81e142d556ceb615f626449d6229ef959 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 12:58:12 +0700 Subject: [PATCH 11/53] cs fix --- src/SPC/builder/extension/swoole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index d3559814..b4f23a2f 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -76,7 +76,7 @@ class swoole extends Extension $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; // enable this feature , need stop pdo_* - $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pdo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH : ''; + $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pdo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH : ''; return $arg; } } From d13e369994c6bdb3b5d7b15a3eab48a2c4a8e998 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 13:11:40 +0700 Subject: [PATCH 12/53] test swoole --- src/globals/test-extensions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index d311962d..e065c971 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -23,9 +23,9 @@ $test_php_version = [ // 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 + '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 @@ -50,7 +50,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' => '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', + 'Linux', 'Darwin' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite', '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', }; @@ -62,7 +62,7 @@ $shared_extensions = match (PHP_OS_FAMILY) { }; // If you want to test lib-suggests for all extensions and libraries, set it to true. -$with_suggested_libs = false; +$with_suggested_libs = true; // If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true. $with_libs = match (PHP_OS_FAMILY) { From 9fe322375f1e023fb7bd08b57cc343eecddd7697 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 14:55:30 +0700 Subject: [PATCH 13/53] use 8.4 for tests only --- src/SPC/builder/Extension.php | 5 ++++- src/SPC/builder/extension/swoole.php | 4 +++- src/SPC/util/SPCConfigUtil.php | 9 +++++++++ src/globals/test-extensions.php | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index faae465c..6000d1e1 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -252,12 +252,15 @@ class Extension $order = []; $resolve = function ($extension) use (&$resolve, &$loaded, &$order) { + if (!$extension instanceof Extension) { + return; + } if (isset($loaded[$extension->getName()])) { return; } $loaded[$extension->getName()] = true; - foreach ($this->dependencies as $dependency) { + foreach ($extension->dependencies as $dependency) { $resolve($dependency); } diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index b4f23a2f..6646f128 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -8,6 +8,7 @@ use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCTarget; #[CustomExt('swoole')] class swoole extends Extension @@ -48,7 +49,8 @@ class swoole extends Extension // commonly-used feature: coroutine-time $arg .= ' --enable-swoole-coro-time --with-pic'; - $arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context'; + $arg .= $this->builder->getOption('enable-zts') && SPCTarget::getTargetOS() !== 'Darwin' ? ' --enable-swoole-thread' : ' --disable-swoole-thread'; + $arg .= $this->builder->getOption('enable-zts') || SPCTarget::getTargetOS() === 'Darwin' ? ' --disable-thread-context' : ' --enable-thread-context'; // required feature: curl, openssl (but curl hook is buggy for php 8.0) $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index d0c1cf73..6d3e7729 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -54,6 +54,15 @@ class SPCConfigUtil */ public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array { + $extra_exts = []; + foreach ($extensions as $ext) { + $extra_exts = array_merge($extra_exts, Config::getExt($ext, 'ext-suggests', [])); + } + foreach ($extra_exts as $ext) { + if ($this->builder?->getExt($ext) && !in_array($ext, $extensions)) { + $extensions[] = $ext; + } + } [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); ob_start(); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index e065c971..cd2ca5fb 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -18,7 +18,7 @@ $test_php_version = [ // '8.3', '8.4', // '8.5', - 'git', + // 'git', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) From 99ccbf8a402871bde19d08eb11c48d4cf12faec5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 15:28:53 +0700 Subject: [PATCH 14/53] @crazywhalecc please look what's wrong with macos --- src/SPC/builder/extension/swoole.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 6646f128..728fe575 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -49,8 +49,7 @@ class swoole extends Extension // commonly-used feature: coroutine-time $arg .= ' --enable-swoole-coro-time --with-pic'; - $arg .= $this->builder->getOption('enable-zts') && SPCTarget::getTargetOS() !== 'Darwin' ? ' --enable-swoole-thread' : ' --disable-swoole-thread'; - $arg .= $this->builder->getOption('enable-zts') || SPCTarget::getTargetOS() === 'Darwin' ? ' --disable-thread-context' : ' --enable-thread-context'; + $arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context'; // required feature: curl, openssl (but curl hook is buggy for php 8.0) $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; From 2b57bca55cb0d9eb786ef729eb7e5055652a5888 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 15:30:04 +0700 Subject: [PATCH 15/53] remove useless import --- src/SPC/builder/extension/swoole.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 728fe575..b4f23a2f 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -8,7 +8,6 @@ use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; use SPC\store\FileSystem; use SPC\util\CustomExt; -use SPC\util\SPCTarget; #[CustomExt('swoole')] class swoole extends Extension From efdfbf437af990d3a3bb7f50ca20c40c0f50f88d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 18:23:04 +0700 Subject: [PATCH 16/53] use format string --- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 9693db8d..49a0369d 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -282,7 +282,7 @@ abstract class UnixBuilderBase extends BuilderBase $config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list); $env = [ 'CGO_ENABLED' => '1', - 'CGO_CFLAGS' => $this->arch_c_flags . ' ' . $config['cflags'], + 'CGO_CFLAGS' => clean_spaces("{$this->arch_c_flags} {$config['cflags']} " . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS')), 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$config['libs']} {$lrt}", 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags . From 868f6d408b8815dfa8dd28a6676cd0c5ac1a3315 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 18:44:03 +0700 Subject: [PATCH 17/53] only feed -lgcov to the go driver --- src/SPC/builder/unix/UnixBuilderBase.php | 11 ++++++++++- src/SPC/util/SPCConfigUtil.php | 5 ----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 49a0369d..b31dcee2 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -13,6 +13,8 @@ use SPC\store\CurlHook; use SPC\store\Downloader; use SPC\store\FileSystem; use SPC\store\pkg\GoXcaddy; +use SPC\toolchain\GccNativeToolchain; +use SPC\toolchain\ToolchainManager; use SPC\util\DependencyUtil; use SPC\util\GlobalEnvManager; use SPC\util\SPCConfigUtil; @@ -280,10 +282,17 @@ abstract class UnixBuilderBase extends BuilderBase } $config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list); + $libs = $config['libs']; + + if ((str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') || + str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), '-fprofile')) && + ToolchainManager::getToolchainClass() === GccNativeToolchain::class) { + $libs .= ' -lgcov'; + } $env = [ 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => clean_spaces("{$this->arch_c_flags} {$config['cflags']} " . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS')), - 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$config['libs']} {$lrt}", + 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs} {$lrt}", 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 6d3e7729..d19cc858 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -8,8 +8,6 @@ use SPC\builder\BuilderBase; use SPC\builder\BuilderProvider; use SPC\exception\WrongUsageException; use SPC\store\Config; -use SPC\toolchain\GccNativeToolchain; -use SPC\toolchain\ToolchainManager; use Symfony\Component\Console\Input\ArgvInput; class SPCConfigUtil @@ -89,9 +87,6 @@ class SPCConfigUtil if (SPCTarget::getTargetOS() === 'Darwin') { $libs .= " {$this->getFrameworksString($extensions)}"; } - if (str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') && ToolchainManager::getToolchainClass() === GccNativeToolchain::class) { - $libs .= ' -lgcov'; - } if ($this->builder->hasCpp()) { $libcpp = SPCTarget::getTargetOS() === 'Darwin' ? '-lc++' : '-lstdc++'; $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; From 65ee7479ac5e5b95b4958d8c7e85268f96cfd04e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 19:29:10 +0700 Subject: [PATCH 18/53] suggestion and clean up frankenphp build --- src/SPC/builder/extension/swoole.php | 2 +- src/SPC/builder/unix/UnixBuilderBase.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index b4f23a2f..487158e5 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -52,7 +52,7 @@ class swoole extends Extension // required feature: curl, openssl (but curl hook is buggy for php 8.0) $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; - $arg .= ' --enable-openssl'; // we depend on openssl so it's always enabled + $arg .= ' --enable-openssl'; // additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature) $arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : ''; diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index b31dcee2..1ff17f87 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -282,16 +282,18 @@ abstract class UnixBuilderBase extends BuilderBase } $config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list); + $cflags = "{$this->arch_c_flags} {$config['cflags']} " . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'); $libs = $config['libs']; if ((str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') || str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), '-fprofile')) && ToolchainManager::getToolchainClass() === GccNativeToolchain::class) { + $cflags .= ' -Wno-error=missing-profile'; $libs .= ' -lgcov'; } $env = [ 'CGO_ENABLED' => '1', - 'CGO_CFLAGS' => clean_spaces("{$this->arch_c_flags} {$config['cflags']} " . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS')), + 'CGO_CFLAGS' => clean_spaces($cflags), 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs} {$lrt}", 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags . From f80aee51339dd2a5da0fd56c63a45e06e2fbd61e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 19:31:15 +0700 Subject: [PATCH 19/53] get rid of $rt --- src/SPC/builder/unix/UnixBuilderBase.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 1ff17f87..5f4f8223 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -261,7 +261,6 @@ abstract class UnixBuilderBase extends BuilderBase logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.'); $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); } - $lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : ''; $releaseInfo = json_decode(Downloader::curlExec( 'https://api.github.com/repos/php/frankenphp/releases/latest', hooks: [[CurlHook::class, 'setupGithubToken']], @@ -284,7 +283,7 @@ abstract class UnixBuilderBase extends BuilderBase $config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list); $cflags = "{$this->arch_c_flags} {$config['cflags']} " . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'); $libs = $config['libs']; - + $libs .= PHP_OS_FAMILY === 'Linux' ? ' -lrt' : ''; if ((str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') || str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), '-fprofile')) && ToolchainManager::getToolchainClass() === GccNativeToolchain::class) { @@ -294,7 +293,7 @@ abstract class UnixBuilderBase extends BuilderBase $env = [ 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => clean_spaces($cflags), - 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs} {$lrt}", + 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}", 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . From 37e0f1d3f3148679786c06690b360ff49f190b19 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 25 Aug 2025 19:50:41 +0700 Subject: [PATCH 20/53] Update src/SPC/command/BuildPHPCommand.php --- src/SPC/command/BuildPHPCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 4f07d5ea..aaf902ba 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -252,7 +252,7 @@ class BuildPHPCommand extends BuildCommand $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); if (file_exists(BUILD_MODULES_PATH . "/{$ext}.so")) { logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); - } elseif (!str_contains($ext, 'swoole-hook')) { + } else { logger()->warning("Shared extension [{$ext}] not found, please check!"); } } From 2694dd9e21dfae66f16af08cba10010ec5c29274 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 25 Aug 2025 22:57:04 +0700 Subject: [PATCH 21/53] add liburing for swoole --- config/ext.json | 5 ++++ config/lib.json | 15 ++++++++++ config/source.json | 9 ++++++ src/SPC/builder/extension/swoole.php | 2 +- src/SPC/builder/linux/library/liburing.php | 32 ++++++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/SPC/builder/linux/library/liburing.php diff --git a/config/ext.json b/config/ext.json index 852d1da3..d8394913 100644 --- a/config/ext.json +++ b/config/ext.json @@ -846,6 +846,11 @@ "zstd", "unixodbc" ], + "lib-suggests-linux": [ + "zstd", + "unixodbc", + "liburing" + ], "ext-depends": [ "openssl", "curl" diff --git a/config/lib.json b/config/lib.json index 1c366743..079ebc1e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -925,5 +925,20 @@ "zstd.h", "zstd_errors.h" ] + }, + "liburing": { + "source": "liburing", + "pkg-configs": [ + "liburing", + "liburing-ffi" + ], + "static-libs-linux": [ + "liburing.a", + "liburing-ffi.a" + ], + "headers-linux": [ + "liburing/", + "liburing.h" + ] } } diff --git a/config/source.json b/config/source.json index 79e4b153..4a0e0fdb 100644 --- a/config/source.json +++ b/config/source.json @@ -1136,5 +1136,14 @@ "type": "file", "path": "LICENSE" } + }, + "liburing": { + "type": "ghtar", + "repo": "axboe/liburing", + "prefer-stable": true, + "license": { + "type": "file", + "path": "COPYING" + } } } diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 487158e5..57158dbe 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -61,7 +61,7 @@ class swoole extends Extension } $arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : ''; $arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : ''; - $arg .= $this->builder->getLib('iouring') ? ' --enable-iouring' : ''; + $arg .= $this->builder->getLib('liburing') ? ' --enable-iouring' : ''; $arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : ''; // additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc. diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php new file mode 100644 index 00000000..62e32f88 --- /dev/null +++ b/src/SPC/builder/linux/library/liburing.php @@ -0,0 +1,32 @@ +removeConfigureArgs( + '--disable-shared', + '--enable-static', + '--with-pic', + '--enable-pic', + ) + ->addConfigureArgs( + '--use-libc' + ) + ->configure() + ->make(with_clean: false) + ->exec("rm -rf {$this->getLibDir()}/*.so*"); + + $this->patchPkgconfPrefix(['liburing.pc', 'liburing-ffi.pc']); + } +} From b1da64d46b1b507c26131fb7608d9d416f5896ce Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 00:24:40 +0700 Subject: [PATCH 22/53] add swoole-hook-odbc to work the same way as the other hooks --- config/ext.json | 23 +++++++++-- src/SPC/builder/extension/swoole.php | 4 +- .../builder/extension/swoole_hook_mysql.php | 4 -- .../builder/extension/swoole_hook_odbc.php | 40 +++++++++++++++++++ .../builder/extension/swoole_hook_pgsql.php | 4 -- .../builder/extension/swoole_hook_sqlite.php | 4 -- 6 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 src/SPC/builder/extension/swoole_hook_odbc.php diff --git a/config/ext.json b/config/ext.json index d8394913..8e02b118 100644 --- a/config/ext.json +++ b/config/ext.json @@ -843,12 +843,10 @@ "zlib" ], "lib-suggests": [ - "zstd", - "unixodbc" + "zstd" ], "lib-suggests-linux": [ "zstd", - "unixodbc", "liburing" ], "ext-depends": [ @@ -859,7 +857,8 @@ "sockets", "swoole-hook-pgsql", "swoole-hook-mysql", - "swoole-hook-sqlite" + "swoole-hook-sqlite", + "swoole-hook-odbc" ] }, "swoole-hook-mysql": { @@ -909,6 +908,22 @@ "swoole" ] }, + "swoole-hook-odbc": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, + "type": "addon", + "arg-type": "none", + "ext-depends": [ + "pdo", + "swoole" + ], + "lib-depends": [ + "unixodbc" + ] + }, "swow": { "support": { "BSD": "wip" diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 57158dbe..9d288fe7 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -8,6 +8,7 @@ use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCConfigUtil; #[CustomExt('swoole')] class swoole extends Extension @@ -76,7 +77,8 @@ class swoole extends Extension $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; // enable this feature , need stop pdo_* - $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pdo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH : ''; + $config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']); + $arg .= $this->builder->getExt('swoole-hook-odbc') ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"' : ''; return $arg; } } diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index 0c005aee..24f65911 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -18,10 +18,6 @@ class swoole_hook_mysql extends Extension public function runCliCheckUnix(): void { - // skip if not enable swoole - if ($this->builder->getExt('swoole') === null) { - return; - } [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"'); $out = implode('', $out); if ($ret !== 0) { diff --git a/src/SPC/builder/extension/swoole_hook_odbc.php b/src/SPC/builder/extension/swoole_hook_odbc.php new file mode 100644 index 00000000..93d70c14 --- /dev/null +++ b/src/SPC/builder/extension/swoole_hook_odbc.php @@ -0,0 +1,40 @@ +builder->getExt('pdo_odbc')?->isBuildStatic()) { + throw new WrongUsageException('swoole-hook-odbc provides pdo_odbc, if you enable odbc hook for swoole, you must remove pdo_odbc extension.'); + } + } + + public function runCliCheckUnix(): void + { + $sharedExtensions = $this->getSharedExtensionLoadString(); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); + $out = implode('', $out); + if ($ret !== 0) { + throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check"); + } + if (!str_contains($out, 'coroutine_odbc')) { + throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check'); + } + } +} diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 7bbc1a1f..a653d98d 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -27,10 +27,6 @@ class swoole_hook_pgsql extends Extension public function runCliCheckUnix(): void { - // skip if not enable swoole - if ($this->builder->getExt('swoole') === null) { - return; - } $sharedExtensions = $this->getSharedExtensionLoadString(); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 4985bd5c..81cdfec3 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -27,10 +27,6 @@ class swoole_hook_sqlite extends Extension public function runCliCheckUnix(): void { - // skip if not enable swoole - if ($this->builder->getExt('swoole') === null) { - return; - } $sharedExtensions = $this->getSharedExtensionLoadString(); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); From a1f2126c0083a6813f4d190112849949d1c6268a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 00:38:35 +0700 Subject: [PATCH 23/53] update comments --- src/SPC/builder/extension/swoole.php | 20 ++++++------------- .../builder/extension/swoole_hook_odbc.php | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 9d288fe7..34dd6233 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -46,37 +46,29 @@ class swoole extends Extension // enable swoole $arg = '--enable-swoole' . ($shared ? '=shared' : ''); - // commonly-used feature: coroutine-time + // commonly used feature: coroutine-time $arg .= ' --enable-swoole-coro-time --with-pic'; $arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context'; - // required feature: curl, openssl (but curl hook is buggy for php 8.0) + // required features: curl, openssl (but curl hook is buggy for php 8.0) $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; $arg .= ' --enable-openssl'; - // additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature) + // additional features that only require libraries $arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : ''; - if (!$shared) { - $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; - } + $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; $arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : ''; $arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : ''; $arg .= $this->builder->getLib('liburing') ? ' --enable-iouring' : ''; $arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : ''; - // additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc. - // so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support) + // enable additional features that require the pdo extension, but conflict with pdo_* extensions + // to make sure everything works as it should, this is done in fake addon extensions $arg .= $this->builder->getExt('swoole-hook-pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql'; - - // additional feature: swoole-mysql $arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd'; - - // enable this feature , need remove pdo_sqlite - // more info : https://wenda.swoole.com/detail/109023 $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; - // enable this feature , need stop pdo_* $config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']); $arg .= $this->builder->getExt('swoole-hook-odbc') ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"' : ''; return $arg; diff --git a/src/SPC/builder/extension/swoole_hook_odbc.php b/src/SPC/builder/extension/swoole_hook_odbc.php index 93d70c14..00797a7d 100644 --- a/src/SPC/builder/extension/swoole_hook_odbc.php +++ b/src/SPC/builder/extension/swoole_hook_odbc.php @@ -34,7 +34,7 @@ class swoole_hook_odbc extends Extension throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check"); } if (!str_contains($out, 'coroutine_odbc')) { - throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check'); + throw new ValidationException('swoole odbc hook is not enabled correctly.', validation_module: 'Extension swoole odbc hook availability check'); } } } From ba326973e5a3f3c3f9fb236802be03922316dfe4 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 00:56:57 +0700 Subject: [PATCH 24/53] prevent infinite recursion if ext suggests addons that depend on the extension --- src/SPC/builder/Extension.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 6000d1e1..71bbf9d4 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -356,11 +356,8 @@ class Extension /** * Build shared extension */ - public function buildShared(): void + public function buildShared(array $visited = []): void { - if (Config::getExt($this->getName(), 'type') === 'addon') { - return; - } try { if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) { if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { @@ -375,17 +372,21 @@ class Extension } if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)'); + return; } logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)'); foreach ($this->dependencies as $dependency) { if (!$dependency instanceof Extension) { continue; } - if (!$dependency->isBuildStatic()) { + if (!$dependency->isBuildStatic() && !in_array($dependency->getName(), $visited)) { logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName()); - $dependency->buildShared(); + $dependency->buildShared([...$visited, $this->getName()]); } } + if (Config::getExt($this->getName(), 'type') === 'addon') { + return; + } match (PHP_OS_FAMILY) { 'Darwin', 'Linux' => $this->buildUnixShared(), default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'), From 9803bf6c3f687e71505e66738a268114bb05ca7f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 00:59:54 +0700 Subject: [PATCH 25/53] prevent warning message from addons --- src/SPC/command/BuildPHPCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index aaf902ba..18d582e4 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -252,7 +252,7 @@ class BuildPHPCommand extends BuildCommand $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); if (file_exists(BUILD_MODULES_PATH . "/{$ext}.so")) { logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); - } else { + } elseif (Config::getExt($ext, 'type', 'ext') !== 'addon') { logger()->warning("Shared extension [{$ext}] not found, please check!"); } } From 43352ab986a395b0511e7ee17d4c077be3b57891 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 01:01:45 +0700 Subject: [PATCH 26/53] don't print repeated --ri swoole check --- src/SPC/builder/extension/swoole_hook_mysql.php | 2 +- src/SPC/builder/extension/swoole_hook_odbc.php | 2 +- src/SPC/builder/extension/swoole_hook_pgsql.php | 2 +- src/SPC/builder/extension/swoole_hook_sqlite.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index 24f65911..f60f4f8e 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -18,7 +18,7 @@ class swoole_hook_mysql extends Extension public function runCliCheckUnix(): void { - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"'); + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); $out = implode('', $out); if ($ret !== 0) { throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: 'extension swoole_hook_mysql sanity check'); diff --git a/src/SPC/builder/extension/swoole_hook_odbc.php b/src/SPC/builder/extension/swoole_hook_odbc.php index 00797a7d..8586dc51 100644 --- a/src/SPC/builder/extension/swoole_hook_odbc.php +++ b/src/SPC/builder/extension/swoole_hook_odbc.php @@ -28,7 +28,7 @@ class swoole_hook_odbc extends Extension public function runCliCheckUnix(): void { $sharedExtensions = $this->getSharedExtensionLoadString(); - [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false); $out = implode('', $out); if ($ret !== 0) { throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check"); diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index a653d98d..bb2b4cfd 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -28,7 +28,7 @@ class swoole_hook_pgsql extends Extension public function runCliCheckUnix(): void { $sharedExtensions = $this->getSharedExtensionLoadString(); - [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false); $out = implode('', $out); if ($ret !== 0) { throw new ValidationException( diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 81cdfec3..d87342ba 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -28,7 +28,7 @@ class swoole_hook_sqlite extends Extension public function runCliCheckUnix(): void { $sharedExtensions = $this->getSharedExtensionLoadString(); - [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false); $out = implode('', $out); if ($ret !== 0) { throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check"); From 4eac953c71b19ad85db6ca273bc65c7cef3488d8 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 14:07:49 +0700 Subject: [PATCH 27/53] ensure liburing is only pulled in by suggested libs when glibc >= 2.30 (or musl) --- config/lib.json | 3 ++- src/SPC/builder/extension/swoole.php | 6 ++++-- src/SPC/builder/linux/library/liburing.php | 10 +++++++++- src/SPC/util/DependencyUtil.php | 16 ++++++++++++++++ src/SPC/util/SPCTarget.php | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/config/lib.json b/config/lib.json index 079ebc1e..ffedd938 100644 --- a/config/lib.json +++ b/config/lib.json @@ -939,6 +939,7 @@ "headers-linux": [ "liburing/", "liburing.h" - ] + ], + "glibc-min": "2.30" } } diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 34dd6233..e3f8c105 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -69,8 +69,10 @@ class swoole extends Extension $arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd'; $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; - $config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']); - $arg .= $this->builder->getExt('swoole-hook-odbc') ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"' : ''; + if ($this->builder->getExt('swoole-hook-odbc')) { + $config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']); + $arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"'; + } return $arg; } } diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php index 62e32f88..08d871f4 100644 --- a/src/SPC/builder/linux/library/liburing.php +++ b/src/SPC/builder/linux/library/liburing.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace SPC\builder\linux\library; +use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; +use SPC\util\SPCTarget; class liburing extends LinuxLibraryBase { @@ -12,8 +14,14 @@ class liburing extends LinuxLibraryBase protected function build(): void { - // Build liburing with static linking via autoconf + if (SPCTarget::getLibc() === 'glibc' && SPCTarget::getLibcVersion() < 2.30) { + throw new WrongUsageException('liburing requires glibc >= 2.30'); + } + UnixAutoconfExecutor::create($this) + ->appendEnv([ + 'CFLAGS' => '-D_GNU_SOURCE' + ]) ->removeConfigureArgs( '--disable-shared', '--enable-static', diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index 83123f65..9d1aa0f6 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -76,6 +76,14 @@ class DependencyUtil $del_list = []; foreach ($obj['suggests'] as $id => $suggest) { if (!str_starts_with($suggest, 'ext@')) { + $glibcMin = Config::getLib($suggest, 'glibc-min'); + if ($glibcMin !== null) { + $libc = SPCTarget::getLibc(); + $ver = SPCTarget::getLibcVersion(); + if ($libc === 'glibc' && version_compare($ver, (string) $glibcMin, '<')) { + continue; + } + } $dep_list[$name]['depends'][] = $suggest; $del_list[] = $id; } @@ -134,6 +142,14 @@ class DependencyUtil $del_list = []; foreach ($obj['suggests'] as $id => $suggest) { if (!str_starts_with($suggest, 'ext@')) { + $glibcMin = Config::getLib($suggest, 'glibc-min'); + if ($glibcMin !== null) { + $libc = SPCTarget::getLibc(); + $ver = SPCTarget::getLibcVersion(); + if ($libc === 'glibc' && version_compare($ver, (string) $glibcMin, '<')) { + continue; + } + } $dep_list[$name]['depends'][] = $suggest; $del_list[] = $id; } diff --git a/src/SPC/util/SPCTarget.php b/src/SPC/util/SPCTarget.php index c6519a9a..981f51cd 100644 --- a/src/SPC/util/SPCTarget.php +++ b/src/SPC/util/SPCTarget.php @@ -100,6 +100,10 @@ class SPCTarget public static function getLibcVersion(): ?string { if (PHP_OS_FAMILY === 'Linux') { + $target = getenv('SPC_TARGET'); + if (str_contains($target, '-gnu.2.')) { + return preg_match('/-gnu\.(2\.\d+)/', $target, $matches) ? $matches[1] : null; + } $libc = self::getLibc(); return SystemUtil::getLibcVersionIfExists($libc); } From 00f262571c054ebe7e069a119e9b58d36f0b5e3a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 14:08:09 +0700 Subject: [PATCH 28/53] cs fix --- src/SPC/builder/linux/library/liburing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php index 08d871f4..bfdc482f 100644 --- a/src/SPC/builder/linux/library/liburing.php +++ b/src/SPC/builder/linux/library/liburing.php @@ -20,7 +20,7 @@ class liburing extends LinuxLibraryBase UnixAutoconfExecutor::create($this) ->appendEnv([ - 'CFLAGS' => '-D_GNU_SOURCE' + 'CFLAGS' => '-D_GNU_SOURCE', ]) ->removeConfigureArgs( '--disable-shared', From 2d409db2f9124e2371d8b90b8d6eb90ed4f96fb6 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 14:42:34 +0700 Subject: [PATCH 29/53] we don't need a min glibc version, just don't use --use-libc! --- config/lib.json | 3 +-- src/SPC/builder/linux/library/liburing.php | 26 ++++++++++++++-------- src/SPC/util/DependencyUtil.php | 16 ------------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/config/lib.json b/config/lib.json index ffedd938..079ebc1e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -939,7 +939,6 @@ "headers-linux": [ "liburing/", "liburing.h" - ], - "glibc-min": "2.30" + ] } } diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php index bfdc482f..2961d1e8 100644 --- a/src/SPC/builder/linux/library/liburing.php +++ b/src/SPC/builder/linux/library/liburing.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\SPCTarget; @@ -14,14 +13,23 @@ class liburing extends LinuxLibraryBase protected function build(): void { - if (SPCTarget::getLibc() === 'glibc' && SPCTarget::getLibcVersion() < 2.30) { - throw new WrongUsageException('liburing requires glibc >= 2.30'); + $use_libc = SPCTarget::getLibc() !== 'glibc' || version_compare(SPCTarget::getLibcVersion(), '2.30', '>='); + $make = UnixAutoconfExecutor::create($this); + + if (!$use_libc) { + $make->appendEnv([ + 'CC' => 'gcc', // libc-less version fails to compile with clang or zig + 'CXX' => 'g++', + 'AR' => 'ar', + 'LD' => 'ld', + ]); + } else { + $make->appendEnv([ + 'CFLAGS' => '-D_GNU_SOURCE', + ]); } - UnixAutoconfExecutor::create($this) - ->appendEnv([ - 'CFLAGS' => '-D_GNU_SOURCE', - ]) + $make ->removeConfigureArgs( '--disable-shared', '--enable-static', @@ -29,11 +37,11 @@ class liburing extends LinuxLibraryBase '--enable-pic', ) ->addConfigureArgs( - '--use-libc' + $use_libc ? '--use-libc' : '', ) ->configure() ->make(with_clean: false) - ->exec("rm -rf {$this->getLibDir()}/*.so*"); + ->exec("rm -rf {$this->getLibDir()}/liburing*.so*"); $this->patchPkgconfPrefix(['liburing.pc', 'liburing-ffi.pc']); } diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index 9d1aa0f6..83123f65 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -76,14 +76,6 @@ class DependencyUtil $del_list = []; foreach ($obj['suggests'] as $id => $suggest) { if (!str_starts_with($suggest, 'ext@')) { - $glibcMin = Config::getLib($suggest, 'glibc-min'); - if ($glibcMin !== null) { - $libc = SPCTarget::getLibc(); - $ver = SPCTarget::getLibcVersion(); - if ($libc === 'glibc' && version_compare($ver, (string) $glibcMin, '<')) { - continue; - } - } $dep_list[$name]['depends'][] = $suggest; $del_list[] = $id; } @@ -142,14 +134,6 @@ class DependencyUtil $del_list = []; foreach ($obj['suggests'] as $id => $suggest) { if (!str_starts_with($suggest, 'ext@')) { - $glibcMin = Config::getLib($suggest, 'glibc-min'); - if ($glibcMin !== null) { - $libc = SPCTarget::getLibc(); - $ver = SPCTarget::getLibcVersion(); - if ($libc === 'glibc' && version_compare($ver, (string) $glibcMin, '<')) { - continue; - } - } $dep_list[$name]['depends'][] = $suggest; $del_list[] = $id; } From effefd4844fc3773c8380b051c696782f9c3baff Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 14:51:07 +0700 Subject: [PATCH 30/53] string --- src/SPC/util/SPCTarget.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/util/SPCTarget.php b/src/SPC/util/SPCTarget.php index 981f51cd..b8f5367a 100644 --- a/src/SPC/util/SPCTarget.php +++ b/src/SPC/util/SPCTarget.php @@ -100,7 +100,7 @@ class SPCTarget public static function getLibcVersion(): ?string { if (PHP_OS_FAMILY === 'Linux') { - $target = getenv('SPC_TARGET'); + $target = (string) getenv('SPC_TARGET'); if (str_contains($target, '-gnu.2.')) { return preg_match('/-gnu\.(2\.\d+)/', $target, $matches) ? $matches[1] : null; } From 0d4d4283d1881de691af1fee0f42110c5ac94547 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 18:04:43 +0700 Subject: [PATCH 31/53] only `install library` for liburing --- src/SPC/builder/linux/library/liburing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php index 2961d1e8..9e66d3ed 100644 --- a/src/SPC/builder/linux/library/liburing.php +++ b/src/SPC/builder/linux/library/liburing.php @@ -40,7 +40,7 @@ class liburing extends LinuxLibraryBase $use_libc ? '--use-libc' : '', ) ->configure() - ->make(with_clean: false) + ->make('install library', with_clean: false) ->exec("rm -rf {$this->getLibDir()}/liburing*.so*"); $this->patchPkgconfPrefix(['liburing.pc', 'liburing-ffi.pc']); From d9c2247f991138c720c8b496e498d09ffb1b5a05 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 18:16:44 +0700 Subject: [PATCH 32/53] fix alpine `realpath -s` issue --- src/SPC/builder/linux/library/liburing.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php index 9e66d3ed..802f366f 100644 --- a/src/SPC/builder/linux/library/liburing.php +++ b/src/SPC/builder/linux/library/liburing.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace SPC\builder\linux\library; +use SPC\builder\linux\SystemUtil; +use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\SPCTarget; @@ -11,6 +13,15 @@ class liburing extends LinuxLibraryBase { public const NAME = 'liburing'; + public function patchBeforeBuild(): bool + { + if (!SystemUtil::isMuslDist()) { + return false; + } + FileSystem::replaceFileStr($this->source_dir . '/configure', 'realpath -s', 'realpath'); + return true; + } + protected function build(): void { $use_libc = SPCTarget::getLibc() !== 'glibc' || version_compare(SPCTarget::getLibcVersion(), '2.30', '>='); From 1243fb9678ec4906d372c2d480946f2bfe245176 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 18:55:22 +0700 Subject: [PATCH 33/53] don't test macos as it just fails either way, add odbc test --- src/globals/test-extensions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index cd2ca5fb..15ec3c98 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -23,11 +23,11 @@ $test_php_version = [ // 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 + // '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-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 @@ -50,7 +50,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' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite', + 'Linux', 'Darwin' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,swoole-hook-odbc', '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 c433aed5217eff3900330ad31dab9bba435940da Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 19:35:10 +0700 Subject: [PATCH 34/53] fix macos? --- src/SPC/builder/extension/swoole.php | 6 ++++++ src/SPC/builder/linux/library/liburing.php | 2 +- src/globals/test-extensions.php | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index e3f8c105..a4a531cf 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -9,6 +9,7 @@ use SPC\builder\macos\MacOSBuilder; use SPC\store\FileSystem; use SPC\util\CustomExt; use SPC\util\SPCConfigUtil; +use SPC\util\SPCTarget; #[CustomExt('swoole')] class swoole extends Extension @@ -73,6 +74,11 @@ class swoole extends Extension $config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']); $arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"'; } + + if (SPCTarget::getTargetOS() === 'Darwin') { + $arg .= ' ac_cv_lib_pthread_pthread_barrier_init=no'; + } + return $arg; } } diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php index 802f366f..9ed416a9 100644 --- a/src/SPC/builder/linux/library/liburing.php +++ b/src/SPC/builder/linux/library/liburing.php @@ -51,7 +51,7 @@ class liburing extends LinuxLibraryBase $use_libc ? '--use-libc' : '', ) ->configure() - ->make('install library', with_clean: false) + ->make('library', with_clean: false) ->exec("rm -rf {$this->getLibDir()}/liburing*.so*"); $this->patchPkgconfPrefix(['liburing.pc', 'liburing-ffi.pc']); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 15ec3c98..9a159fbc 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -25,7 +25,7 @@ $test_php_version = [ $test_os = [ // 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 - // 'macos-15', // 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 From 00892c20faa56f0eb42ed4643b81f5e9c38c9d77 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 26 Aug 2025 20:43:18 +0700 Subject: [PATCH 35/53] fix odbc libs when iconv is built too --- src/SPC/store/SourcePatcher.php | 3 + src/globals/patch/swoole_fix_odbclibs.patch | 90 +++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/globals/patch/swoole_fix_odbclibs.patch diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 388ee1e6..7cb416f7 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -269,7 +269,10 @@ class SourcePatcher if ($version === '5.1.3') { self::patchFile('spc_fix_swoole_50513.patch', SOURCE_PATH . '/php-src/ext/swoole'); } + // remove when https://github.com/swoole/swoole-src/pull/5848 is merged self::patchFile('swoole_fix_date_time.patch', SOURCE_PATH . '/php-src/ext/swoole'); + // remove when https://github.com/swoole/swoole-src/pull/5847 is merged + self::patchFile('swoole_fix_odbclibs.patch', SOURCE_PATH . '/php-src/ext/swoole'); return true; } diff --git a/src/globals/patch/swoole_fix_odbclibs.patch b/src/globals/patch/swoole_fix_odbclibs.patch new file mode 100644 index 00000000..161c9420 --- /dev/null +++ b/src/globals/patch/swoole_fix_odbclibs.patch @@ -0,0 +1,90 @@ +From d4942a590a301a2552f8885962640f38d60de27b Mon Sep 17 00:00:00 2001 +From: DubbleClick +Date: Tue, 26 Aug 2025 00:08:32 +0700 +Subject: [PATCH] add SWOOLE_ODBC_LIBC variable if the odbc library needs more + than to link against a single library + +--- + config.m4 | 57 ++++++++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 44 insertions(+), 13 deletions(-) + +diff --git a/config.m4 b/config.m4 +index 1583cb81c8..683d8891af 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -641,31 +641,62 @@ EOF + AC_MSG_ERROR([Cannot find header file(s) for pdo_odbc]) + fi + ++ if test -n "$SWOOLE_ODBC_LIBS"; then ++ ODBC_LIBS="$SWOOLE_ODBC_LIBS" ++ else ++ ODBC_LIBS="-l$pdo_odbc_def_lib" ++ fi ++ + PDO_ODBC_INCLUDE="$pdo_odbc_def_cflags -I$PDO_ODBC_INCDIR -DPDO_ODBC_TYPE=\\\"$pdo_odbc_flavour\\\"" +- PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags -L$PDO_ODBC_LIBDIR -l$pdo_odbc_def_lib" ++ PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags -L$PDO_ODBC_LIBDIR $ODBC_LIBS" + + PHP_EVAL_LIBLINE([$PDO_ODBC_LDFLAGS], [SWOOLE_SHARED_LIBADD]) + + EXTRA_CFLAGS="$EXTRA_CFLAGS -I$pdo_cv_inc_path $PDO_ODBC_INCLUDE" + + dnl Check first for an ODBC 1.0 function to assert that the libraries work +- PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLBindCol, +- [ +- dnl And now check for an ODBC 3.0 function to assert that they are *good* +- dnl libraries. +- PHP_CHECK_LIBRARY($pdo_odbc_def_lib, SQLAllocHandle, +- [], [ +- AC_MSG_ERROR([ ++ save_LIBS="$LIBS" ++ LIBS="$LIBS $PDO_ODBC_LDFLAGS" ++ ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ #include ]], ++ [[ ++ SQLLEN ind = 0; ++ char buf[1]; ++ SQLBindCol((SQLHSTMT)0, (SQLUSMALLINT)1, (SQLSMALLINT)SQL_C_CHAR, ++ (SQLPOINTER)buf, (SQLLEN)sizeof(buf), &ind); ++ return 0; ++ ]])], ++ [ ++ dnl And now check for an ODBC 3.0 function to assert that they are *good* ++ dnl libraries. ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[#include ++ #include ]], ++ [[ ++ SQLHANDLE out = SQL_NULL_HANDLE; ++ SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_ENV, ++ (SQLHANDLE)SQL_NULL_HANDLE, &out); ++ return 0; ++ ]])], ++ [], ++ [AC_MSG_ERROR([ + Your ODBC library does not appear to be ODBC 3 compatible. + You should consider using iODBC or unixODBC instead, and loading your + libraries as a driver in that environment; it will emulate the + functions required for PDO support. +- ])], $PDO_ODBC_LDFLAGS) +- ],[ +- AC_MSG_ERROR([Your ODBC library does not exist or there was an error. Check config.log for more information]) +- ], $PDO_ODBC_LDFLAGS) ++ ])] ++ ) ++ ], ++ [AC_MSG_ERROR([Your ODBC library does not exist or there was an error. Check config.log for more information])] ++ ) ++ ++ LIBS="$save_LIBS" + +- AC_DEFINE(SW_USE_ODBC, 1, [do we enable swoole-odbc coro support]) ++ AC_DEFINE(SW_USE_ODBC, 1, [do we enable swoole-odbc coro support]) + fi + + dnl odbc end \ No newline at end of file From ecdb94b4298b9f21c2a56182c4af7797034b6caa Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 27 Aug 2025 08:31:48 +0700 Subject: [PATCH 36/53] suggestions --- src/SPC/builder/linux/library/liburing.php | 2 +- src/SPC/builder/unix/UnixBuilderBase.php | 1 + src/SPC/command/BuildPHPCommand.php | 2 +- src/SPC/store/SourcePatcher.php | 10 ++++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/linux/library/liburing.php b/src/SPC/builder/linux/library/liburing.php index 9ed416a9..668659ec 100644 --- a/src/SPC/builder/linux/library/liburing.php +++ b/src/SPC/builder/linux/library/liburing.php @@ -54,6 +54,6 @@ class liburing extends LinuxLibraryBase ->make('library', with_clean: false) ->exec("rm -rf {$this->getLibDir()}/liburing*.so*"); - $this->patchPkgconfPrefix(['liburing.pc', 'liburing-ffi.pc']); + $this->patchPkgconfPrefix(); } } diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 5f4f8223..c09a9e1b 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -284,6 +284,7 @@ abstract class UnixBuilderBase extends BuilderBase $cflags = "{$this->arch_c_flags} {$config['cflags']} " . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'); $libs = $config['libs']; $libs .= PHP_OS_FAMILY === 'Linux' ? ' -lrt' : ''; + // Go's gcc driver doesn't automatically link against -lgcov or -lrt. Ugly, but necessary fix. if ((str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') || str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), '-fprofile')) && ToolchainManager::getToolchainClass() === GccNativeToolchain::class) { diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 18d582e4..fb14e47c 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -252,7 +252,7 @@ class BuildPHPCommand extends BuildCommand $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); if (file_exists(BUILD_MODULES_PATH . "/{$ext}.so")) { logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); - } elseif (Config::getExt($ext, 'type', 'ext') !== 'addon') { + } elseif (Config::getExt($ext, 'type') !== 'addon') { logger()->warning("Shared extension [{$ext}] not found, please check!"); } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 7cb416f7..01e16546 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -269,10 +269,12 @@ class SourcePatcher if ($version === '5.1.3') { self::patchFile('spc_fix_swoole_50513.patch', SOURCE_PATH . '/php-src/ext/swoole'); } - // remove when https://github.com/swoole/swoole-src/pull/5848 is merged - self::patchFile('swoole_fix_date_time.patch', SOURCE_PATH . '/php-src/ext/swoole'); - // remove when https://github.com/swoole/swoole-src/pull/5847 is merged - self::patchFile('swoole_fix_odbclibs.patch', SOURCE_PATH . '/php-src/ext/swoole'); + if (version_compare($version, '6.0.0', '>=') && version_compare($version, '6.1.0', '<')) { + // remove when https://github.com/swoole/swoole-src/pull/5848 is merged + self::patchFile('swoole_fix_date_time.patch', SOURCE_PATH . '/php-src/ext/swoole'); + // remove when https://github.com/swoole/swoole-src/pull/5847 is merged + self::patchFile('swoole_fix_odbclibs.patch', SOURCE_PATH . '/php-src/ext/swoole'); + } return true; } From 08ab3c17d6a1dda216c94ce01ddef685336ab433 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 27 Aug 2025 11:40:06 +0700 Subject: [PATCH 37/53] fix perl-IPC-Cmd check so it doesn't try installing it every time --- src/SPC/builder/traits/UnixSystemUtilTrait.php | 3 +++ src/SPC/doctor/item/LinuxToolCheckList.php | 1 + 2 files changed, 4 insertions(+) diff --git a/src/SPC/builder/traits/UnixSystemUtilTrait.php b/src/SPC/builder/traits/UnixSystemUtilTrait.php index 3407a00b..a64c2d94 100644 --- a/src/SPC/builder/traits/UnixSystemUtilTrait.php +++ b/src/SPC/builder/traits/UnixSystemUtilTrait.php @@ -19,6 +19,9 @@ trait UnixSystemUtilTrait if (!$paths) { $paths = explode(PATH_SEPARATOR, getenv('PATH')); } + if (str_starts_with($name, '/')) { + return file_exists($name) ? $name : null; + } foreach ($paths as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . $name)) { return $path . DIRECTORY_SEPARATOR . $name; diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index c07a32da..78a04b57 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -52,6 +52,7 @@ class LinuxToolCheckList 'base-devel' => 'automake', 'gettext-devel' => 'gettextize', 'gettext-dev' => 'gettextize', + 'perl-IPC-Cmd' => '/usr/share/doc/perl-IPC-Cmd' ]; /** @noinspection PhpUnused */ From 3da58d5c24de1ec6eeee21af2b2cef907b9b0f67 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 27 Aug 2025 11:48:59 +0700 Subject: [PATCH 38/53] filter micro patches to not be '' --- 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 01e16546..abd3ab48 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -153,7 +153,7 @@ class SourcePatcher $spc_micro_patches = $items; } else { $spc_micro_patches = getenv('SPC_MICRO_PATCHES'); - $spc_micro_patches = $spc_micro_patches === false ? [] : explode(',', $spc_micro_patches); + $spc_micro_patches = $spc_micro_patches === false ? [] : array_filter(explode(',', $spc_micro_patches)); } $patch_list = $spc_micro_patches; $patches = []; From 25401e59595849e0921eeff74b2cbd94bd9a2e65 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 27 Aug 2025 12:43:48 +0700 Subject: [PATCH 39/53] cs fix --- src/SPC/doctor/item/LinuxToolCheckList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 78a04b57..68682b15 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -52,7 +52,7 @@ class LinuxToolCheckList 'base-devel' => 'automake', 'gettext-devel' => 'gettextize', 'gettext-dev' => 'gettextize', - 'perl-IPC-Cmd' => '/usr/share/doc/perl-IPC-Cmd' + 'perl-IPC-Cmd' => '/usr/share/doc/perl-IPC-Cmd', ]; /** @noinspection PhpUnused */ From 95f1b65bca618d50c67476a430041b9aef3cabf4 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 27 Aug 2025 13:03:57 +0700 Subject: [PATCH 40/53] fix perl installation by checking for FindBin --- src/SPC/doctor/item/LinuxToolCheckList.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 68682b15..c3611dcc 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -40,7 +40,7 @@ class LinuxToolCheckList 'tar', 'unzip', 'gzip', 'gcc', 'bzip2', 'cmake', 'patch', 'which', 'xz', 'libtool', 'gettext-devel', - 'perl', 'patchelf', + 'patchelf', ]; public const TOOLS_ARCH = [ @@ -48,6 +48,7 @@ class LinuxToolCheckList ]; private const PROVIDED_COMMAND = [ + 'perl' => '/usr/share/perl5/FindBin.pm', 'binutils-gold' => 'ld.gold', 'base-devel' => 'automake', 'gettext-devel' => 'gettextize', From 5a4b920ae2ae787594b14fd085c5508996bbe4ec Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 27 Aug 2025 13:04:08 +0700 Subject: [PATCH 41/53] pkg-config patch --- src/SPC/store/SourcePatcher.php | 7 +++++++ src/globals/patch/pkg-config_gcc15.patch | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/globals/patch/pkg-config_gcc15.patch diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index abd3ab48..29c7d1dd 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -30,6 +30,7 @@ class SourcePatcher FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchImapLicense']); FileSystem::addSourceExtractHook('ext-imagick', [__CLASS__, 'patchImagickWith84']); FileSystem::addSourceExtractHook('libaom', [__CLASS__, 'patchLibaomForAlpine']); + FileSystem::addSourceExtractHook('pkg-config', [__CLASS__, 'patchPkgConfigForGcc15']); FileSystem::addSourceExtractHook('attr', [__CLASS__, 'patchAttrForAlpine']); FileSystem::addSourceExtractHook('gmssl', [__CLASS__, 'patchGMSSL']); } @@ -498,6 +499,12 @@ class SourcePatcher return true; } + public static function patchPkgConfigForGcc15(): bool + { + self::patchFile('pkg-config_gcc15.patch', SOURCE_PATH . '/pkg-config'); + return true; + } + public static function patchLibaomForAlpine(): bool { if (PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist()) { diff --git a/src/globals/patch/pkg-config_gcc15.patch b/src/globals/patch/pkg-config_gcc15.patch new file mode 100644 index 00000000..d029b6ba --- /dev/null +++ b/src/globals/patch/pkg-config_gcc15.patch @@ -0,0 +1,22 @@ +diff --git a/glib/glib/goption.c b/glib/glib/goption.c +index 0a22f6f..f439fd4 100644 +--- a/glib/glib/goption.c ++++ b/glib/glib/goption.c +@@ -166,7 +166,7 @@ typedef struct + gpointer arg_data; + union + { +- gboolean bool; ++ gboolean boolean; + gint integer; + gchar *str; + gchar **array; +@@ -1600,7 +1600,7 @@ free_changes_list (GOptionContext *context, + switch (change->arg_type) + { + case G_OPTION_ARG_NONE: +- *(gboolean *)change->arg_data = change->prev.bool; ++ *(gboolean *)change->arg_data = change->prev.boolean; + break; + case G_OPTION_ARG_INT: + *(gint *)change->arg_data = change->prev.integer; \ No newline at end of file From 25fe794acc84fa8f52c56ac7a3311f4fcdeb0aee Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 27 Aug 2025 14:36:05 +0700 Subject: [PATCH 42/53] trim all items --- src/SPC/store/SourcePatcher.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 29c7d1dd..c08204f5 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -154,8 +154,9 @@ class SourcePatcher $spc_micro_patches = $items; } else { $spc_micro_patches = getenv('SPC_MICRO_PATCHES'); - $spc_micro_patches = $spc_micro_patches === false ? [] : array_filter(explode(',', $spc_micro_patches)); + $spc_micro_patches = $spc_micro_patches === false ? [] : explode(',', $spc_micro_patches); } + $spc_micro_patches = array_filter($spc_micro_patches, fn ($item) => trim((string) $item) !== ''); $patch_list = $spc_micro_patches; $patches = []; $serial = ['80', '81', '82', '83', '84', '85']; From 117a54d0770f357fea58ba8cade6c5a6583a7166 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 28 Aug 2025 10:14:47 +0800 Subject: [PATCH 43/53] extension test --- .github/workflows/ext-matrix-tests.yml | 2 +- src/globals/test-extensions.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index 22db8ad6..1f9a1f66 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -65,7 +65,7 @@ jobs: - sqlsrv - ssh2 - swoole - - swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite + - swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite,swoole-hook-odbc - swow - sysvmsg,sysvsem,sysvshm - tidy diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 9a159fbc..ac42f700 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,9 +13,9 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - // '8.1', - // '8.2', - // '8.3', + '8.1', + '8.2', + '8.3', '8.4', // '8.5', // 'git', @@ -23,7 +23,7 @@ $test_php_version = [ // 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 @@ -74,7 +74,7 @@ $with_libs = match (PHP_OS_FAMILY) { // 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' => 'bulk', 'Windows' => 'none', }; From fc7e8ebc53ac635ba31db29f3dcfb51632ff81f6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 28 Aug 2025 10:29:22 +0800 Subject: [PATCH 44/53] extension test --- .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 1f9a1f66..84d3b518 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" + - "8.4" operating-system: - "ubuntu-latest" #- "macos-13" From 1a7bf2d070d5b360a9884d0e509dcf315a670c55 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 28 Aug 2025 10:49:02 +0800 Subject: [PATCH 45/53] 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 ac42f700..dd9e186e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -50,7 +50,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' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,swoole-hook-odbc', + 'Linux', 'Darwin' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,swoole-hook-odbc,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib', '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 20fbbb1dbe7b67e1ca78a7a235f778d792ab1f07 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 28 Aug 2025 11:01:58 +0800 Subject: [PATCH 46/53] 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 dd9e186e..939a25ff 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -74,7 +74,7 @@ $with_libs = match (PHP_OS_FAMILY) { // 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 f18725083a5d6c3d8931892ef510a52e53250d62 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 28 Aug 2025 11:32:33 +0700 Subject: [PATCH 47/53] disable opcache jit automatically on alpine target (only required for php < 8.5) --- src/SPC/builder/extension/mongodb.php | 6 +++--- src/SPC/builder/extension/opcache.php | 13 ++++++++++++- src/SPC/builder/linux/LinuxBuilder.php | 4 ---- src/SPC/builder/macos/MacOSBuilder.php | 8 -------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/SPC/builder/extension/mongodb.php b/src/SPC/builder/extension/mongodb.php index 7ba1ea33..745417bb 100644 --- a/src/SPC/builder/extension/mongodb.php +++ b/src/SPC/builder/extension/mongodb.php @@ -12,9 +12,9 @@ class mongodb extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - $arg = ' --enable-mongodb '; + $arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' '; $arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no '; - $arg .= ' --with-mongodb-sasl=no '; + $arg .= ' --with-mongodb-sasl=no '; if ($this->builder->getLib('openssl')) { $arg .= '--with-mongodb-ssl=openssl'; } @@ -22,6 +22,6 @@ class mongodb extends Extension $arg .= $this->builder->getLib('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no '; // $arg .= $this->builder->getLib('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no '; $arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled '; - return $arg; + return clean_spaces($arg); } } diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 58139dd1..1d1267ec 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -8,6 +8,7 @@ use SPC\builder\Extension; use SPC\exception\WrongUsageException; use SPC\store\SourcePatcher; use SPC\util\CustomExt; +use SPC\util\SPCTarget; #[CustomExt('opcache')] class opcache extends Extension @@ -46,7 +47,17 @@ class opcache extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--enable-opcache'; + $phpVersionID = $this->builder->getPHPVersionID(); + $opcache_jit = ' --enable-opcache-jit'; + if ((SPCTarget::getTargetOS() === 'Linux' && + SPCTarget::getLibc() === 'musl' && + $this->builder->getOption('enable-zts') && + $phpVersionID < 80500) || + $this->builder->getOption('disable-opcache-jit') + ) { + $opcache_jit = ' --disable-opcache-jit'; + } + return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit; } public function getDistName(): string diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index e7736852..373e1b21 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -64,10 +64,7 @@ class LinuxBuilder extends UnixBuilderBase // 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 ' : ''; @@ -115,7 +112,6 @@ class LinuxBuilder extends UnixBuilderBase ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . $config_file_path . $config_file_scan_dir . - $opcache_jit_arg . $json_74 . $zts . $maxExecutionTimers . diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 851d7de4..00c1da8c 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -90,13 +90,6 @@ class MacOSBuilder extends UnixBuilderBase $json_74 = $phpVersionID < 80000 ? '--enable-json ' : ''; $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; - $opcache_jit = !$this->getOption('disable-opcache-jit', false); - // disable opcache jit for PHP < 8.5.0 when opcache is not enabled - if ($opcache_jit && $phpVersionID < 80500 && !$this->getExt('opcache')) { - $opcache_jit = false; - } - $opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit ' : '--disable-opcache-jit '; - $config_file_path = $this->getOption('with-config-file-path', false) ? ('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : ''; $config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ? @@ -131,7 +124,6 @@ class MacOSBuilder extends UnixBuilderBase ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . ($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') . ($enableMicro ? '--enable-micro ' : '--disable-micro ') . - $opcache_jit_arg . $config_file_path . $config_file_scan_dir . $json_74 . From 866ca264d9a15bf460d2b72c045ea824b3c480fa Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 28 Aug 2025 11:35:46 +0700 Subject: [PATCH 48/53] only disable it for x86_64 --- src/SPC/builder/extension/opcache.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 1d1267ec..280a4a4d 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -52,6 +52,7 @@ class opcache extends Extension if ((SPCTarget::getTargetOS() === 'Linux' && SPCTarget::getLibc() === 'musl' && $this->builder->getOption('enable-zts') && + GNU_ARCH === 'x86_64' && $phpVersionID < 80500) || $this->builder->getOption('disable-opcache-jit') ) { From 39a9840d4970195f154004eefb26255a8e9dc0c4 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 28 Aug 2025 12:14:26 +0700 Subject: [PATCH 49/53] why is phpstan so stupid about this constant? --- src/SPC/builder/extension/opcache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 280a4a4d..cc1dfcc1 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -52,7 +52,7 @@ class opcache extends Extension if ((SPCTarget::getTargetOS() === 'Linux' && SPCTarget::getLibc() === 'musl' && $this->builder->getOption('enable-zts') && - GNU_ARCH === 'x86_64' && + arch2gnu(php_uname('m')) === 'x86_64' && $phpVersionID < 80500) || $this->builder->getOption('disable-opcache-jit') ) { From bf55db959e46c62a2c67758c4e6a999ee6f7c0fe Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 28 Aug 2025 22:35:23 +0800 Subject: [PATCH 50/53] Add swoole-hook-odbc notes --- docs/en/guide/extension-notes.md | 8 ++++++++ docs/zh/guide/extension-notes.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/docs/en/guide/extension-notes.md b/docs/en/guide/extension-notes.md index 1fa65d0e..7096c0ee 100644 --- a/docs/en/guide/extension-notes.md +++ b/docs/en/guide/extension-notes.md @@ -46,6 +46,14 @@ If you use `swoole,swoole-hook-sqlite`, you will enable the coroutine mode of Sw swoole-hook-sqlite conflicts with the `pdo_sqlite` extension. If you want to use Swoole and `pdo_sqlite`, please delete the pdo_sqlite extension and enable `swoole` and `swoole-hook-sqlite`. This extension contains an implementation of the coroutine environment for `pdo_sqlite`. +## swoole-hook-odbc + +swoole-hook-odbc is not an extension, it's a Hook feature of Swoole. +If you use `swoole,swoole-hook-odbc`, you will enable the coroutine mode of Swoole's `odbc` extension. + +swoole-hook-odbc conflicts with the `pdo_odbc` extension. If you want to use Swoole and `pdo_odbc`, please delete the `pdo_odbc` extension and enable `swoole` and `swoole-hook-odbc`. +This extension contains an implementation of the coroutine environment for `pdo_odbc`. + ## swow 1. Only PHP 8.0+ is supported. diff --git a/docs/zh/guide/extension-notes.md b/docs/zh/guide/extension-notes.md index 40744ffa..70d60d1c 100644 --- a/docs/zh/guide/extension-notes.md +++ b/docs/zh/guide/extension-notes.md @@ -43,6 +43,14 @@ swoole-hook-sqlite 不是一个扩展,而是 Swoole 的 Hook 特性。 swoole-hook-sqlite 与 `pdo_sqlite` 扩展冲突。如需使用 Swoole 和 `pdo_sqlite`,请删除 pdo_sqlite 扩展,启用 `swoole` 和 `swoole-hook-sqlite` 即可。 该扩展包含了 `pdo_sqlite` 的协程环境的实现。 +## swoole-hook-odbc + +swoole-hook-odbc 不是一个扩展,而是 Swoole 的 Hook 特性。 +如果你在编译时添加了 `swoole,swoole-hook-odbc`,你将启用 Swoole 的 `odbc` 扩展的协程模式。 + +swoole-hook-odbc 与 `pdo_odbc` 扩展冲突。如需使用 Swoole 和 `pdo_odbc`,请删除 `pdo_odbc` 扩展,启用 `swoole` 和 `swoole-hook-odbc` 即可。 +该扩展包含了 `pdo_odbc` 的协程环境的实现。 + ## swow 1. swow 仅支持 PHP 8.0+ 版本。 From 0f0050115cc9f165a016a627de36bae8a94e3eec Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 28 Aug 2025 22:35:51 +0800 Subject: [PATCH 51/53] Update cli generator, add frankenphp SAPI, add copy-to-clipboard func --- docs/.vitepress/components/CliGenerator.vue | 847 +++++++++++--------- 1 file changed, 470 insertions(+), 377 deletions(-) diff --git a/docs/.vitepress/components/CliGenerator.vue b/docs/.vitepress/components/CliGenerator.vue index f9f3613d..6cef60d0 100644 --- a/docs/.vitepress/components/CliGenerator.vue +++ b/docs/.vitepress/components/CliGenerator.vue @@ -15,9 +15,9 @@

{{ I18N[lang].selectExt }}{{ checkedExts.length > 0 ? (' (' + checkedExts.length + ')') : '' }}

- +
-
+
-
{{ I18N[lang].selectCommon }}
@@ -36,7 +35,7 @@
{{ I18N[lang].buildLibs }}{{ checkedLibs.length > 0 ? (' (' + checkedLibs.length + ')') : '' }}
-
+
@@ -49,7 +48,7 @@

{{ I18N[lang].buildTarget }}

-
+
@@ -58,7 +57,7 @@

WARNING

{{ I18N[lang].microUnavailable }}

-
+

WARNING

{{ I18N[lang].windowsSAPIUnavailable }}

@@ -81,7 +80,7 @@ {{ I18N[lang].downloadPhpVersion }} @@ -140,10 +139,17 @@

{{ I18N[lang].hardcodedINI }}