diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 17bb1c5e..daa0f93b 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -170,6 +170,9 @@ class LinuxBuilder extends UnixBuilderBase */ protected function buildCli(): void { + if ($this->getExt('readline')) { + SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src'); + } $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); readline::patchCliLinux(true); $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; @@ -178,6 +181,10 @@ class LinuxBuilder extends UnixBuilderBase ->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli"); readline::patchCliLinux(false); + if ($this->getExt('readline')) { + SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src', true); + } + if (!$this->getOption('no-strip', false)) { shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-unneeded php'); } 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)