From 16e772e1a802afa52195eff0c36ae157500e095f Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 10 Mar 2026 08:42:17 +0700 Subject: [PATCH 1/6] add back in zig workaround as 0.16.x is not released yet --- src/SPC/builder/traits/UnixSystemUtilTrait.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SPC/builder/traits/UnixSystemUtilTrait.php b/src/SPC/builder/traits/UnixSystemUtilTrait.php index ff75bf7c..33f824f3 100644 --- a/src/SPC/builder/traits/UnixSystemUtilTrait.php +++ b/src/SPC/builder/traits/UnixSystemUtilTrait.php @@ -72,6 +72,10 @@ trait UnixSystemUtilTrait if (!is_file($symbol_file)) { throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available."); } + // https://github.com/ziglang/zig/issues/24662 + if (ToolchainManager::getToolchainClass() === ZigToolchain::class) { + return '-Wl,--export-dynamic'; // needs release 0.16, can be removed then + } // macOS/zig if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) { return "-Wl,-exported_symbols_list,{$symbol_file}"; From b690566b390bef49188e14341e5482aa1c919103 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 10 Mar 2026 08:43:48 +0700 Subject: [PATCH 2/6] simplify rm command --- src/SPC/builder/unix/library/postgresql.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 2ad4f51b..a3aed130 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -93,8 +93,7 @@ trait postgresql // remove dynamic libs shell()->cd($this->source_dir . '/build') - ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*") - ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so") + ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so*") ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib"); FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber'); From f93ad27c172119a38d31ca91e9112dcf46d67830 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 10 Mar 2026 08:47:38 +0700 Subject: [PATCH 3/6] allow using some libs as system provided (work around mssql linking vs system openssl) --- config/lib.json | 14 ++++++++++++++ src/SPC/builder/Extension.php | 3 ++- src/SPC/builder/LibraryBase.php | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/config/lib.json b/config/lib.json index ebbf4b87..58cbd4ba 100644 --- a/config/lib.json +++ b/config/lib.json @@ -862,6 +862,9 @@ }, "openssl": { "source": "openssl", + "pkg-configs": [ + "openssl" + ], "static-libs-unix": [ "libssl.a", "libcrypto.a" @@ -974,6 +977,11 @@ }, "unixodbc": { "source": "unixodbc", + "pkg-configs": [ + "odbc", + "odbccr", + "odbcinst" + ], "static-libs-unix": [ "libodbc.a", "libodbccr.a", @@ -1015,6 +1023,9 @@ }, "zlib": { "source": "zlib", + "pkg-configs": [ + "zlib" + ], "static-libs-unix": [ "libz.a" ], @@ -1028,6 +1039,9 @@ }, "zstd": { "source": "zstd", + "pkg-configs": [ + "libzstd" + ], "static-libs-unix": [ "libzstd.a" ], diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index f5a5d956..9077269e 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -96,7 +96,8 @@ class Extension fn ($x) => $x->getStaticLibFiles(), $this->getLibraryDependencies(recursive: true) ); - return implode(' ', $ret); + $libs = implode(' ', $ret); + return deduplicate_flags($libs); } /** diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 383faa41..0cd1c235 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -365,6 +365,24 @@ abstract class LibraryBase protected function isLibraryInstalled(): bool { + if ($pkg_configs = Config::getLib(static::NAME, 'pkg-configs', [])) { + $pkg_config_path = getenv('PKG_CONFIG_PATH') ?: ''; + $search_paths = array_unique(array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path))); + + foreach ($pkg_configs as $name) { + $found = false; + foreach ($search_paths as $path) { + if (file_exists($path . "/{$name}.pc")) { + $found = true; + break; + } + } + if (!$found) { + return false; + } + } + return true; // allow using system dependencies if pkg_config_path is explicitly defined + } foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) { if (!file_exists(BUILD_LIB_PATH . "/{$name}")) { return false; From 2277390a1abbebaf0c388f0773071b3ac4e19fa0 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 10 Mar 2026 08:49:56 +0700 Subject: [PATCH 4/6] fix removeConfigureArgs in UnixAutoconfExecutor.php --- src/SPC/util/executor/UnixAutoconfExecutor.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index e04fe4f9..9d57ef4e 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -16,12 +16,11 @@ class UnixAutoconfExecutor extends Executor protected array $configure_args = []; - protected array $ignore_args = []; - public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibraryBase $library) { parent::__construct($library); $this->initShell(); + $this->configure_args = $this->getDefaultConfigureArgs(); } /** @@ -29,19 +28,12 @@ class UnixAutoconfExecutor extends Executor */ public function configure(...$args): static { - // remove all the ignored args - $args = array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args); - $args = array_diff($args, $this->ignore_args); + $args = array_merge($args, $this->configure_args); $configure_args = implode(' ', $args); return $this->seekLogFileOnException(fn () => $this->shell->exec("./configure {$configure_args}")); } - public function getConfigureArgsString(): string - { - return implode(' ', array_merge($this->getDefaultConfigureArgs(), $this->configure_args)); - } - /** * Run make * @@ -111,7 +103,7 @@ class UnixAutoconfExecutor extends Executor */ public function removeConfigureArgs(...$args): static { - $this->ignore_args = [...$this->ignore_args, ...$args]; + $this->configure_args = array_diff($this->configure_args, $args); return $this; } @@ -133,8 +125,8 @@ class UnixAutoconfExecutor extends Executor private function getDefaultConfigureArgs(): array { return [ - '--disable-shared', '--enable-static', + '--disable-shared', "--prefix={$this->library->getBuildRootPath()}", '--with-pic', '--enable-pic', From 1edf14e64235303684b409840b9f2bd0046497d2 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 10 Mar 2026 08:52:15 +0700 Subject: [PATCH 5/6] set custom binary name for frankenphp --- src/SPC/builder/unix/UnixBuilderBase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 1b532bbc..30112192 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -458,6 +458,7 @@ abstract class UnixBuilderBase extends BuilderBase '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . '-X \'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy\' ' . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . + '-X \'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp ' . "v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . "-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, From 5d5a50a33cdf31f65f7656b5d6cc7beb585c8233 Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 10 Mar 2026 10:57:49 +0700 Subject: [PATCH 6/6] Update src/SPC/builder/LibraryBase.php Co-authored-by: Jerry Ma --- src/SPC/builder/LibraryBase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 0cd1c235..73b1f9ed 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -381,7 +381,10 @@ abstract class LibraryBase return false; } } - return true; // allow using system dependencies if pkg_config_path is explicitly defined + // allow using system dependencies if pkg_config_path is explicitly defined + if (count($search_paths) > 1) { + return true; + } } foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) { if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {