From 598f6d55c5518cfe0d197af3524d1809dbfa25bb Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 4 Sep 2025 16:28:17 +0700 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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'); } }