From aff803f3340e4e8ab7741f6509c6c46a6aa7d862 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 1 Sep 2025 19:07:29 +0700 Subject: [PATCH 1/8] retry fetching frankenphp release info --- 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 9e96c7a2..0bf11801 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -271,6 +271,7 @@ abstract class UnixBuilderBase extends BuilderBase $releaseInfo = json_decode(Downloader::curlExec( 'https://api.github.com/repos/php/frankenphp/releases/latest', hooks: [[CurlHook::class, 'setupGithubToken']], + retries: 3, ), true); $frankenPhpVersion = $releaseInfo['tag_name']; $libphpVersion = $this->getPHPVersion(); From ddc9cc2237fcddc8dfa8513c1317358d813bba06 Mon Sep 17 00:00:00 2001 From: gemini Date: Mon, 1 Sep 2025 17:45:12 +0800 Subject: [PATCH 2/8] Fix cli generator: prefer-pre-built belongs to download-options rather than build-options --- docs/.vitepress/components/CliGenerator.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/.vitepress/components/CliGenerator.vue b/docs/.vitepress/components/CliGenerator.vue index 6cef60d0..430dec24 100644 --- a/docs/.vitepress/components/CliGenerator.vue +++ b/docs/.vitepress/components/CliGenerator.vue @@ -379,6 +379,11 @@ const craftCommandString = computed(() => { str += 'debug: true\n'; } + if (preBuilt.value) { + str += 'download-options:\n'; + str += ' prefer-pre-built: true\n'; + } + str += '{{position_hold}}'; if (enableUPX.value) { @@ -387,9 +392,6 @@ const craftCommandString = computed(() => { if (zts.value) { str += ' enable-zts: true\n'; } - if (preBuilt.value) { - str += ' prefer-pre-built: true\n'; - } if (!str.endsWith('{{position_hold}}')) { str = str.replace('{{position_hold}}', 'build-options:\n'); From 8c8aba2dd5f0e5d149995c30c1fe4e6afc32f79f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 1 Sep 2025 20:20:01 +0800 Subject: [PATCH 3/8] Fix unixodbc driver config searching path --- src/SPC/builder/unix/library/unixodbc.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index d7524bda..9a3cb63d 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -4,18 +4,29 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\WrongUsageException; use SPC\util\executor\UnixAutoconfExecutor; trait unixodbc { protected function build(): void { + $sysconf_selector = match (PHP_OS_FAMILY) { + 'Darwin' => match (GNU_ARCH) { + 'x86_64' => '/usr/local/etc', + 'aarch64' => '/opt/homebrew/etc', + default => throw new WrongUsageException('Unsupported architecture: ' . GNU_ARCH), + }, + 'Linux' => '/etc', + default => throw new WrongUsageException('Unsupported OS: ' . PHP_OS_FAMILY), + }; UnixAutoconfExecutor::create($this) ->configure( '--disable-debug', '--disable-dependency-tracking', "--with-libiconv-prefix={$this->getBuildRootPath()}", '--with-included-ltdl', + "--sysconfdir={$sysconf_selector}", '--enable-gui=no', ) ->make(); From cefb737fd288c5b0ec9ddc23e1867dc2475d4ec6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 1 Sep 2025 20:20:20 +0800 Subject: [PATCH 4/8] Update version to 2.7.3 --- src/SPC/ConsoleApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index afd6699c..c60ca4b0 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -34,7 +34,7 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const string VERSION = '2.7.2'; + public const string VERSION = '2.7.3'; public function __construct() { From a77e49cbc9cca0cccf40cd2772131159b86b981c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 1 Sep 2025 20:22:31 +0800 Subject: [PATCH 5/8] Stubborn phpstan --- phpstan.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon b/phpstan.neon index 78b72c76..a8c1c72c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,6 +9,7 @@ parameters: - '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#' - '#Function Swoole\\Coroutine\\run not found.#' - '#Static call to instance method ZM\\Logger\\ConsoleColor#' + - '#Constant GNU_ARCH not found#' dynamicConstantNames: - PHP_OS_FAMILY excludePaths: From 598f6d55c5518cfe0d197af3524d1809dbfa25bb Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 4 Sep 2025 16:28:17 +0700 Subject: [PATCH 6/8] keep retrying more --- src/SPC/builder/unix/UnixBuilderBase.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 0bf11801..af2b461e 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -268,11 +268,19 @@ 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); } - $releaseInfo = json_decode(Downloader::curlExec( - 'https://api.github.com/repos/php/frankenphp/releases/latest', - hooks: [[CurlHook::class, 'setupGithubToken']], - retries: 3, - ), true); + $releaseInfo = false; + $retries = 5; + while (!$releaseInfo && --$retries >= 0) { + try { + $releaseInfo = json_decode(Downloader::curlExec( + 'https://api.github.com/repos/php/frankenphp/releases/latest', + hooks: [[CurlHook::class, 'setupGithubToken']], + retries: 3, + ), true, 512, JSON_THROW_ON_ERROR); + } catch (\Exception) { + sleep(1); + } + } $frankenPhpVersion = $releaseInfo['tag_name']; $libphpVersion = $this->getPHPVersion(); $dynamic_exports = ''; From e44efb2a54303a437be444143a4bd96c77fb0b2a Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 4 Sep 2025 17:42:17 +0700 Subject: [PATCH 7/8] use go mod to bypass github rate limiting --- src/SPC/builder/unix/UnixBuilderBase.php | 35 ++++++++++-------------- src/globals/test-extensions.php | 2 +- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index af2b461e..f37c062e 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -143,11 +143,13 @@ abstract class UnixBuilderBase extends BuilderBase if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { if (PHP_OS_FAMILY === 'Darwin') { $ext_path = 'DYLD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$DYLD_LIBRARY_PATH '; - } else { + } + else { $ext_path = 'LD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$LD_LIBRARY_PATH '; } FileSystem::removeFileIfExists(BUILD_LIB_PATH . '/libphp.a'); - } else { + } + else { $ext_path = ''; $suffix = PHP_OS_FAMILY === 'Darwin' ? 'dylib' : 'so'; foreach (glob(BUILD_LIB_PATH . "/libphp*.{$suffix}") as $file) { @@ -268,25 +270,14 @@ 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); } - $releaseInfo = false; - $retries = 5; - while (!$releaseInfo && --$retries >= 0) { - try { - $releaseInfo = json_decode(Downloader::curlExec( - 'https://api.github.com/repos/php/frankenphp/releases/latest', - hooks: [[CurlHook::class, 'setupGithubToken']], - retries: 3, - ), true, 512, JSON_THROW_ON_ERROR); - } catch (\Exception) { - sleep(1); - } - } - $frankenPhpVersion = $releaseInfo['tag_name']; + [, $out] = shell()->execWithResult('go list -m github.com/dunglas/frankenphp@latest'); + $frankenPhpVersion = str_replace('github.com/dunglas/frankenphp v', '', $out[0]); $libphpVersion = $this->getPHPVersion(); $dynamic_exports = ''; if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { $libphpVersion = preg_replace('/\.\d+$/', '', $libphpVersion); - } else { + } + else { if ($dynamicSymbolsArgument = LinuxSystemUtil::getDynamicExportedSymbols(BUILD_LIB_PATH . '/libphp.a')) { $dynamic_exports = ' ' . $dynamicSymbolsArgument; } @@ -306,8 +297,8 @@ abstract class UnixBuilderBase extends BuilderBase $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')) && + 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'; @@ -326,7 +317,8 @@ abstract class UnixBuilderBase extends BuilderBase foreach (GoXcaddy::getEnvironment() as $key => $value) { if ($key === 'PATH') { GlobalEnvManager::addPathIfNotExists($value); - } else { + } + else { $env[$key] = $value; } } @@ -337,7 +329,8 @@ abstract class UnixBuilderBase extends BuilderBase if (!$this->getOption('no-strip', false) && file_exists(BUILD_BIN_PATH . '/frankenphp')) { if (PHP_OS_FAMILY === 'Linux') { shell()->cd(BUILD_BIN_PATH)->exec('strip --strip-unneeded frankenphp'); - } else { // macOS doesn't understand strip-unneeded + } + else { // macOS doesn't understand strip-unneeded shell()->cd(BUILD_BIN_PATH)->exec('strip -S frankenphp'); } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 764cfc7d..97eaa850 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -43,7 +43,7 @@ $no_strip = false; $upx = false; // whether to test frankenphp build, only available for macos and linux -$frankenphp = false; +$frankenphp = true; // prefer downloading pre-built packages to speed up the build process $prefer_pre_built = false; From f4b2b9ae7d7fcbfd640be397500a057cc002d87e Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 4 Sep 2025 17:45:13 +0700 Subject: [PATCH 8/8] fix cs --- src/SPC/builder/unix/UnixBuilderBase.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index f37c062e..f627d6d9 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -143,13 +143,11 @@ abstract class UnixBuilderBase extends BuilderBase if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { if (PHP_OS_FAMILY === 'Darwin') { $ext_path = 'DYLD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$DYLD_LIBRARY_PATH '; - } - else { + } else { $ext_path = 'LD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$LD_LIBRARY_PATH '; } FileSystem::removeFileIfExists(BUILD_LIB_PATH . '/libphp.a'); - } - else { + } else { $ext_path = ''; $suffix = PHP_OS_FAMILY === 'Darwin' ? 'dylib' : 'so'; foreach (glob(BUILD_LIB_PATH . "/libphp*.{$suffix}") as $file) { @@ -276,8 +274,7 @@ abstract class UnixBuilderBase extends BuilderBase $dynamic_exports = ''; if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { $libphpVersion = preg_replace('/\.\d+$/', '', $libphpVersion); - } - else { + } else { if ($dynamicSymbolsArgument = LinuxSystemUtil::getDynamicExportedSymbols(BUILD_LIB_PATH . '/libphp.a')) { $dynamic_exports = ' ' . $dynamicSymbolsArgument; } @@ -297,8 +294,8 @@ abstract class UnixBuilderBase extends BuilderBase $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')) && + 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'; @@ -317,8 +314,7 @@ abstract class UnixBuilderBase extends BuilderBase foreach (GoXcaddy::getEnvironment() as $key => $value) { if ($key === 'PATH') { GlobalEnvManager::addPathIfNotExists($value); - } - else { + } else { $env[$key] = $value; } } @@ -329,8 +325,7 @@ abstract class UnixBuilderBase extends BuilderBase if (!$this->getOption('no-strip', false) && file_exists(BUILD_BIN_PATH . '/frankenphp')) { if (PHP_OS_FAMILY === 'Linux') { shell()->cd(BUILD_BIN_PATH)->exec('strip --strip-unneeded frankenphp'); - } - else { // macOS doesn't understand strip-unneeded + } else { // macOS doesn't understand strip-unneeded shell()->cd(BUILD_BIN_PATH)->exec('strip -S frankenphp'); } }