mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-15 04:45:35 +08:00
micro patch for cross-arch 32 bit builds
This commit is contained in:
@@ -65,6 +65,7 @@ class ncurses
|
|||||||
'--without-tests',
|
'--without-tests',
|
||||||
'--without-dlsym',
|
'--without-dlsym',
|
||||||
'--without-debug',
|
'--without-debug',
|
||||||
|
'--disable-stripping',
|
||||||
'--enable-symlinks',
|
'--enable-symlinks',
|
||||||
"--with-terminfo-dirs={$terminfo_dirs}",
|
"--with-terminfo-dirs={$terminfo_dirs}",
|
||||||
"--bindir={$package->getBinDir()}",
|
"--bindir={$package->getBinDir()}",
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ trait unix
|
|||||||
// php-src patches from micro (reads SPC_MICRO_PATCHES env var)
|
// php-src patches from micro (reads SPC_MICRO_PATCHES env var)
|
||||||
SourcePatcher::patchPhpSrc();
|
SourcePatcher::patchPhpSrc();
|
||||||
|
|
||||||
|
$microFileinfo = "{$package->getSourceDir()}/sapi/micro/php_micro_fileinfo.c";
|
||||||
|
if (is_file($microFileinfo) && !str_contains((string) file_get_contents($microFileinfo), 'Elf32_Shdr')) {
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
$microFileinfo,
|
||||||
|
'typedef Elf32_Ehdr Elf_Ehdr;',
|
||||||
|
'typedef Elf32_Ehdr Elf_Ehdr; typedef Elf32_Shdr Elf_Shdr;',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// patch configure.ac for musl and musl-toolchain
|
// patch configure.ac for musl and musl-toolchain
|
||||||
$musl = SystemTarget::getTargetOS() === 'Linux' && SystemTarget::getLibc() === 'musl';
|
$musl = SystemTarget::getTargetOS() === 'Linux' && SystemTarget::getLibc() === 'musl';
|
||||||
FileSystem::backupFile(SOURCE_PATH . '/php-src/configure.ac');
|
FileSystem::backupFile(SOURCE_PATH . '/php-src/configure.ac');
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ class SourcePatcher
|
|||||||
*/
|
*/
|
||||||
public static function patchMicroPhar(int $version_id): void
|
public static function patchMicroPhar(int $version_id): void
|
||||||
{
|
{
|
||||||
|
if (file_exists(SOURCE_PATH . '/php-src/ext/phar/phar.c.bak')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
FileSystem::backupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
|
FileSystem::backupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
|
||||||
FileSystem::replaceFileStr(
|
FileSystem::replaceFileStr(
|
||||||
SOURCE_PATH . '/php-src/ext/phar/phar.c',
|
SOURCE_PATH . '/php-src/ext/phar/phar.c',
|
||||||
@@ -193,6 +196,12 @@ class SourcePatcher
|
|||||||
|
|
||||||
public static function unpatchMicroPhar(): void
|
public static function unpatchMicroPhar(): void
|
||||||
{
|
{
|
||||||
|
// Tolerate a missing .bak: both drivers call this, and the first restore
|
||||||
|
// consumes the backup. Without this guard the second call throws
|
||||||
|
// "Cannot find bak file". No .bak means the source is already pristine.
|
||||||
|
if (!file_exists(SOURCE_PATH . '/php-src/ext/phar/phar.c.bak')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
|
FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user