This commit is contained in:
henderkes
2026-04-27 19:35:47 +07:00
parent eff46209da
commit b536d0c694
4 changed files with 16 additions and 18 deletions

View File

@@ -15,7 +15,6 @@ use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain; use SPC\toolchain\ZigToolchain;
use SPC\util\GlobalEnvManager; use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
class Extension class Extension
{ {

View File

@@ -136,11 +136,11 @@ class LinuxBuilder extends UnixBuilderBase
$pgo = PgoManager::active(); $pgo = PgoManager::active();
$needsClean = false; $needsClean = false;
$sapiBuilds = [ $sapiBuilds = [
['cli', $enableCli, true, fn () => $this->buildCli()], ['cli', $enableCli, true, fn () => $this->buildCli()],
['fpm', $enableFpm, true, fn () => $this->buildFpm()], ['fpm', $enableFpm, true, fn () => $this->buildFpm()],
['cgi', $enableCgi, true, fn () => $this->buildCgi()], ['cgi', $enableCgi, true, fn () => $this->buildCgi()],
['micro', $enableMicro, true, fn () => $this->buildMicro()], ['micro', $enableMicro, true, fn () => $this->buildMicro()],
['embed', $enableEmbed, true, function () use ($enableMicro): void { ['embed', $enableEmbed, true, function () use ($enableMicro): void {
if ($enableMicro) { if ($enableMicro) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la');
} }

View File

@@ -162,7 +162,7 @@ class Zig extends CustomPackage
} }
$zig = "{$zig_bin_dir}/zig"; $zig = "{$zig_bin_dir}/zig";
$verLine = trim((string)shell_exec(escapeshellarg($zig) . ' cc --version 2>/dev/null')); $verLine = trim((string) shell_exec(escapeshellarg($zig) . ' cc --version 2>/dev/null'));
if (!preg_match('/clang version (\d+\.\d+\.\d+)/', $verLine, $m)) { if (!preg_match('/clang version (\d+\.\d+\.\d+)/', $verLine, $m)) {
logger()->warning('[zig] could not detect bundled clang version; skipping runtime bit build (--pgo + shared libs without __dso_handle)'); logger()->warning('[zig] could not detect bundled clang version; skipping runtime bit build (--pgo + shared libs without __dso_handle)');
return; return;
@@ -196,8 +196,7 @@ class Zig extends CustomPackage
'url' => $url, 'url' => $url,
'filename' => $tarball, 'filename' => $tarball,
]); ]);
} } catch (\Throwable $e) {
catch (\Throwable $e) {
logger()->warning("[zig] failed to download {$tarball}: {$e->getMessage()}"); logger()->warning("[zig] failed to download {$tarball}: {$e->getMessage()}");
return null; return null;
} }

View File

@@ -14,6 +14,10 @@ use SPC\store\FileSystem;
*/ */
class PgoManager class PgoManager
{ {
public const MODE_INSTRUMENT = 'instrument';
public const MODE_USE = 'use';
/** /**
* SAPIs whose clang-compiled output can be PGO'd. frankenphp is included * SAPIs whose clang-compiled output can be PGO'd. frankenphp is included
* because its cgo glue is C compiled by zig — the Go side it wraps is * because its cgo glue is C compiled by zig — the Go side it wraps is
@@ -22,18 +26,14 @@ class PgoManager
* frankenphp (because the cgo glue runs too). * frankenphp (because the cgo glue runs too).
*/ */
private const TRAINABLE = [ private const TRAINABLE = [
'cli' => BUILD_TARGET_CLI, 'cli' => BUILD_TARGET_CLI,
'micro' => BUILD_TARGET_MICRO, 'micro' => BUILD_TARGET_MICRO,
'cgi' => BUILD_TARGET_CGI, 'cgi' => BUILD_TARGET_CGI,
'fpm' => BUILD_TARGET_FPM, 'fpm' => BUILD_TARGET_FPM,
'embed' => BUILD_TARGET_EMBED, 'embed' => BUILD_TARGET_EMBED,
'frankenphp' => BUILD_TARGET_FRANKENPHP, 'frankenphp' => BUILD_TARGET_FRANKENPHP,
]; ];
public const MODE_INSTRUMENT = 'instrument';
public const MODE_USE = 'use';
private string $profileRoot; private string $profileRoot;
private string $mode; private string $mode;