Skip to content

Commit 2d5abd3

Browse files
committed
micro patch for cross-arch 32 bit builds
1 parent 69d0f9b commit 2d5abd3

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/Package/Library/ncurses.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function build(LibraryPackage $package, ToolchainInterface $toolchain): v
6565
'--without-tests',
6666
'--without-dlsym',
6767
'--without-debug',
68+
'--disable-stripping',
6869
'--enable-symlinks',
6970
"--with-terminfo-dirs={$terminfo_dirs}",
7071
"--bindir={$package->getBinDir()}",

src/Package/Target/php/unix.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public function patchBeforeBuildconf(TargetPackage $package): void
4242
// php-src patches from micro (reads SPC_MICRO_PATCHES env var)
4343
SourcePatcher::patchPhpSrc();
4444

45+
$microFileinfo = "{$package->getSourceDir()}/sapi/micro/php_micro_fileinfo.c";
46+
if (is_file($microFileinfo) && !str_contains((string) file_get_contents($microFileinfo), 'Elf32_Shdr')) {
47+
FileSystem::replaceFileStr(
48+
$microFileinfo,
49+
'typedef Elf32_Ehdr Elf_Ehdr;',
50+
'typedef Elf32_Ehdr Elf_Ehdr; typedef Elf32_Shdr Elf_Shdr;',
51+
);
52+
}
53+
4554
// patch configure.ac for musl and musl-toolchain
4655
$musl = SystemTarget::getTargetOS() === 'Linux' && SystemTarget::getLibc() === 'musl';
4756
FileSystem::backupFile(SOURCE_PATH . '/php-src/configure.ac');

src/StaticPHP/Util/SourcePatcher.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ public static function unpatchHardcodedINI(string $php_source_dir): bool
168168
*/
169169
public static function patchMicroPhar(int $version_id): void
170170
{
171+
if (file_exists(SOURCE_PATH . '/php-src/ext/phar/phar.c.bak')) {
172+
return;
173+
}
171174
FileSystem::backupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
172175
FileSystem::replaceFileStr(
173176
SOURCE_PATH . '/php-src/ext/phar/phar.c',
@@ -193,6 +196,12 @@ public static function patchMicroPhar(int $version_id): void
193196

194197
public static function unpatchMicroPhar(): void
195198
{
199+
// Tolerate a missing .bak: both drivers call this, and the first restore
200+
// consumes the backup. Without this guard the second call throws
201+
// "Cannot find bak file". No .bak means the source is already pristine.
202+
if (!file_exists(SOURCE_PATH . '/php-src/ext/phar/phar.c.bak')) {
203+
return;
204+
}
196205
FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
197206
}
198207

0 commit comments

Comments
 (0)