mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-15 12:55:36 +08:00
forward-port feat/pgo fixes
Forward-port the genuinely-new fixes from feat/pgo (2026-06-09 .. 07-09) into v3's reorganized layout: - zig-cc.sh: prefix runtime-lib appends with `-x none` so the profile/crt/ cpu_model archives don't poison the following files as `-x c` sources - ZigToolchain: set ax_cv_have_func_attribute_ifunc=no under -flto (an ifunc in LTO bitcode crashes zig 0.16's lld during thin-link) - php configure: add --with-sysconfdir option; strip build-time env vars from phpinfo's "Configure Command" - ext-brotli / ext-zstd: switch to stable release/tag tarballs; brotli configures with --with-libbrotli - ext-event: patch libevent http_connection.c to use a const peer address (both static and shared builds) - ghrel downloader: prefer GitHub's /releases/latest (the semantically latest stable release) over publish-order iteration, so a newer-tagged prerelease (e.g. libevent 2.2.x-alpha) can't win over 2.1.x-stable Commits already present in v3 were skipped: protobuf-latest + libaom ENABLE_*=OFF (9398a667), the clang runtime -target flag (2adedc09), the runtime-bits fail-hard half of3823631a, and github prefer-stable's prerelease skip (incl. the ghtar /releases/latest path, already in v3).
This commit is contained in:
@@ -35,12 +35,30 @@ class event extends PhpExtensionPackage
|
||||
|
||||
#[BeforeStage('php', [php::class, 'makeForUnix'], 'ext-event')]
|
||||
#[PatchDescription('Prevent event extension compile error on macOS')]
|
||||
#[PatchDescription('Patch libevent http_connection.c to use a const peer address')]
|
||||
public function patchBeforeMake(PackageInstaller $installer): void
|
||||
{
|
||||
$php_src = $installer->getTargetPackage('php')->getSourceDir();
|
||||
// Prevent event extension compile error on macOS
|
||||
if (SystemTarget::getTargetOS() === 'Darwin') {
|
||||
$php_src = $installer->getTargetPackage('php')->getSourceDir();
|
||||
FileSystem::replaceFileRegex("{$php_src}/main/php_config.h", '/^#define HAVE_OPENPTY 1$/m', '');
|
||||
}
|
||||
$this->patchLibeventConstPeer("{$php_src}/ext/event");
|
||||
}
|
||||
|
||||
#[BeforeStage('ext-event', [PhpExtensionPackage::class, 'makeForUnix'])]
|
||||
#[PatchDescription('Patch libevent http_connection.c to use a const peer address')]
|
||||
public function patchBeforeSharedMake(PhpExtensionPackage $pkg): void
|
||||
{
|
||||
$this->patchLibeventConstPeer($pkg->getSourceDir());
|
||||
}
|
||||
|
||||
private function patchLibeventConstPeer(string $event_source_dir): bool
|
||||
{
|
||||
$file = "{$event_source_dir}/php8/classes/http_connection.c";
|
||||
if (is_file($file) && FileSystem::replaceFileRegex($file, '/^\tchar \*address;$/m', "\tconst char *address;")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ class php extends TargetPackage
|
||||
$package->addBuildOption('disable-opcache-jit', null, null, 'Disable opcache jit');
|
||||
$package->addBuildOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini', PHP_OS_FAMILY === 'Windows' ? null : '/usr/local/etc/php');
|
||||
$package->addBuildOption('with-config-file-scan-dir', null, InputOption::VALUE_REQUIRED, 'Set the directory to scan for .ini files after reading php.ini', PHP_OS_FAMILY === 'Windows' ? null : '/usr/local/etc/php/conf.d');
|
||||
$package->addBuildOption('with-sysconfdir', null, InputOption::VALUE_REQUIRED, 'Set the sysconfdir (e.g. /etc/php-zts) used by configure (not available on Windows)');
|
||||
$package->addBuildOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI');
|
||||
$package->addBuildOption('enable-zts', null, null, 'Enable thread safe support');
|
||||
$package->addBuildOption('no-smoke-test', null, InputOption::VALUE_OPTIONAL, 'Disable smoke test for specific SAPIs, or all if no value provided', false);
|
||||
|
||||
@@ -75,6 +75,7 @@ trait unix
|
||||
|
||||
#[BeforeStage('php', [self::class, 'configureForUnix'], 'php')]
|
||||
#[PatchDescription('Patch configure to use -std=gnu17 instead of -std=gnu23 for PHP <= 8.2')]
|
||||
#[PatchDescription('Strip build-time env vars from phpinfo\'s "Configure Command"')]
|
||||
public function patchBeforeConfigure(TargetPackage $package): void
|
||||
{
|
||||
if (SystemTarget::isUnix() && self::getPHPVersionID() < 80300) {
|
||||
@@ -84,6 +85,22 @@ trait unix
|
||||
"for ac_arg in '' -std=gnu17",
|
||||
);
|
||||
}
|
||||
|
||||
// strip our build-time env vars from phpinfo's "Configure Command" ('|' delimiter: PHP_BUILD_PROVIDER may contain '#')
|
||||
if (SystemTarget::isUnix()) {
|
||||
FileSystem::replaceFileStr(
|
||||
"{$package->getSourceDir()}/configure",
|
||||
'for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do',
|
||||
'for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX '
|
||||
. 'PKG_CONFIG PKG_CONFIG_PATH EXTENSION_DIR OPENSSL_LIBS '
|
||||
. 'PHP_BUILD_SYSTEM PHP_BUILD_PROVIDER PHP_BUILD_COMPILER PHP_BUILD_ARCH; do',
|
||||
);
|
||||
FileSystem::replaceFileStr(
|
||||
"{$package->getSourceDir()}/configure",
|
||||
'clean_configure_args=$(echo $clean_configure_args | $SED -e "s#\'$var=$val\'##")',
|
||||
'clean_configure_args=$(echo $clean_configure_args | $SED -e "s|\'$var=$val\'||")',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[Stage]
|
||||
@@ -125,6 +142,9 @@ trait unix
|
||||
if ($option = $package->getBuildOption('with-config-file-scan-dir', false)) {
|
||||
$args[] = "--with-config-file-scan-dir={$option}";
|
||||
}
|
||||
if ($option = $package->getBuildOption('with-sysconfdir', false)) {
|
||||
$args[] = "--sysconfdir={$option}";
|
||||
}
|
||||
// perform enable cli options
|
||||
$args[] = $installer->isPackageResolved('php-cli') ? '--enable-cli' : '--disable-cli';
|
||||
$args[] = $installer->isPackageResolved('php-fpm')
|
||||
|
||||
Reference in New Issue
Block a user