Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/SPC/builder/linux/LinuxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,19 @@ public function testPHP(int $build_target = BUILD_TARGET_NONE)
*/
protected function buildCli(): void
{
if ($this->getExt('readline')) {
SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src');
}
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli");

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');
}
Expand Down
2 changes: 1 addition & 1 deletion src/SPC/builder/unix/library/ncurses.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function build(): void
->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);
}
Expand Down
26 changes: 26 additions & 0 deletions src/globals/patch/musl_static_readline.patch
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'bcmath',
'Linux', 'Darwin' => 'readline',
'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip',
};

Expand Down