From bd815d4ea2ac70d6e6822f55b0647b70a56276fc Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Sep 2025 14:10:28 +0800 Subject: [PATCH] Fix static linux cli `-a` not working issue --- src/SPC/builder/unix/library/ncurses.php | 2 +- src/SPC/store/SourcePatcher.php | 7 ++++++ src/globals/patch/musl_static_readline.patch | 26 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/globals/patch/musl_static_readline.patch diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index 3899e559..27725c3d 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -38,7 +38,7 @@ trait ncurses ->make(); $final = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true); // Remove the new files - $new_files = array_diff($final, $filelist); + $new_files = array_diff($final, $filelist ?: []); foreach ($new_files as $file) { @unlink(BUILD_BIN_PATH . '/' . $file); } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index c08204f5..eef78654 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -23,6 +23,7 @@ class SourcePatcher FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchPhpLibxml212']); FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchGDWin32']); FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']); + FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchStaticReadline']); FileSystem::addSourceExtractHook('sqlsrv', [__CLASS__, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('yaml', [__CLASS__, 'patchYamlWin32']); @@ -500,6 +501,12 @@ class SourcePatcher return true; } + public static function patchStaticReadline(): bool + { + self::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src'); + return true; + } + public static function patchPkgConfigForGcc15(): bool { self::patchFile('pkg-config_gcc15.patch', SOURCE_PATH . '/pkg-config'); diff --git a/src/globals/patch/musl_static_readline.patch b/src/globals/patch/musl_static_readline.patch new file mode 100644 index 00000000..19611621 --- /dev/null +++ b/src/globals/patch/musl_static_readline.patch @@ -0,0 +1,26 @@ +diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c +index 31212999..d80a21c3 100644 +--- a/ext/readline/readline_cli.c ++++ b/ext/readline/readline_cli.c +@@ -739,8 +739,8 @@ typedef cli_shell_callbacks_t *(__cdecl *get_cli_shell_callbacks)(void); + } while(0) + + #else +-/* + #ifdef COMPILE_DL_READLINE ++/* + This dlsym() is always used as even the CGI SAPI is linked against "CLI"-only + extensions. If that is being changed dlsym() should only be used when building + this extension sharedto offer compatibility. +@@ -754,9 +754,9 @@ this extension sharedto offer compatibility. + (cb) = get_callbacks(); \ + } \ + } while(0) +-/*#else ++#else + #define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks() +-#endif*/ ++#endif + #endif + + PHP_MINIT_FUNCTION(cli_readline)