Skip to content

Commit e6408b4

Browse files
authored
Fix static linux cli -a not working issue (#893)
2 parents 384ba54 + be7c002 commit e6408b4

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,19 @@ public function testPHP(int $build_target = BUILD_TARGET_NONE)
169169
*/
170170
protected function buildCli(): void
171171
{
172+
if ($this->getExt('readline')) {
173+
SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src');
174+
}
172175
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
173176
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
174177
shell()->cd(SOURCE_PATH . '/php-src')
175178
->exec('sed -i "s|//lib|/lib|g" Makefile')
176179
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli");
177180

181+
if ($this->getExt('readline')) {
182+
SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src', true);
183+
}
184+
178185
if (!$this->getOption('no-strip', false)) {
179186
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-unneeded php');
180187
}

src/SPC/builder/unix/library/ncurses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function build(): void
3838
->make();
3939
$final = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true);
4040
// Remove the new files
41-
$new_files = array_diff($final, $filelist);
41+
$new_files = array_diff($final, $filelist ?: []);
4242
foreach ($new_files as $file) {
4343
@unlink(BUILD_BIN_PATH . '/' . $file);
4444
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
2+
index 31212999..d80a21c3 100644
3+
--- a/ext/readline/readline_cli.c
4+
+++ b/ext/readline/readline_cli.c
5+
@@ -739,8 +739,8 @@ typedef cli_shell_callbacks_t *(__cdecl *get_cli_shell_callbacks)(void);
6+
} while(0)
7+
8+
#else
9+
-/*
10+
#ifdef COMPILE_DL_READLINE
11+
+/*
12+
This dlsym() is always used as even the CGI SAPI is linked against "CLI"-only
13+
extensions. If that is being changed dlsym() should only be used when building
14+
this extension sharedto offer compatibility.
15+
@@ -754,9 +754,9 @@ this extension sharedto offer compatibility.
16+
(cb) = get_callbacks(); \
17+
} \
18+
} while(0)
19+
-/*#else
20+
+#else
21+
#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()
22+
-#endif*/
23+
+#endif
24+
#endif
25+
26+
PHP_MINIT_FUNCTION(cli_readline)

src/globals/test-extensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
5252
$extensions = match (PHP_OS_FAMILY) {
53-
'Linux', 'Darwin' => 'bcmath',
53+
'Linux', 'Darwin' => 'readline',
5454
'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',
5555
};
5656

0 commit comments

Comments
 (0)