Skip to content

Commit 0b25e26

Browse files
authored
Fix bug #51558: shared readline build fails (#15242)
The 'rl_pending_input' is a variable in Readline library and checking it with PHP_CHECK_LIBRARY wouldn't find it on some systems. Library check works on most systems but not on the mentioned AIX in the bug as it exports variables and functions differently whereas the linker couldn't resolve the variable as a function. This should fix the build on systems where this caused issues, such as AIX. The <readline/readline.h> is not self-contained header and needs to also have <stdio.h> included before to have FILE type available. This fixes the issue on unpatched default readline installations, such as macOS. Checking this variable ensures that the found library is the correct library and also that it is of minimum version needed by current PHP code (https://bugs.php.net/48608). The library check: ```c | char rl_pending_input (); | int main (void) { | return rl_pending_input (); | } ``` The declaration check: ```c | #include <stdio.h> | #include <readline/readline.h> | int main (void) { | #ifndef rl_pending_input | #ifdef __cplusplus | (void) rl_pending_input; | #else | (void) rl_pending_input; | #endif | #endif | ; | return 0; | } ``` Closes https://bugs.php.net/51558
1 parent 5d9c155 commit 0b25e26

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ PHP NEWS
2424
- Random:
2525
. lcg_value() is now deprecated. (timwolla)
2626

27+
- Readline:
28+
. Fixed bug #51558 (Shared readline build fails). (Peter Kokot)
29+
2730
- Session:
2831
. INI settings session.sid_length and session.sid_bits_per_character are now
2932
deprecated. (timwolla)

ext/readline/config.m4

+14-7
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then
4646
[AC_MSG_FAILURE([The readline library not found.])],
4747
[-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS])
4848

49-
PHP_CHECK_LIBRARY([readline], [rl_pending_input],
50-
[],
51-
[AC_MSG_FAILURE([Invalid readline installation detected. Try --with-libedit instead.])],
52-
[-L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS])
53-
5449
PHP_CHECK_LIBRARY([readline], [rl_callback_read_char],
5550
[AC_DEFINE([HAVE_RL_CALLBACK_READ_CHAR], [1], [ ])],
5651
[],
@@ -72,9 +67,21 @@ if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then
7267
CFLAGS="$CFLAGS $INCLUDES"
7368
LDFLAGS="$LDFLAGS -L$READLINE_DIR/$PHP_LIBDIR"
7469
LIBS="$LIBS -lreadline"
70+
71+
dnl Sanity and minimum version check if readline library has variable
72+
dnl rl_pending_input.
73+
AC_CHECK_DECL([rl_pending_input],, [AC_MSG_FAILURE([
74+
Invalid readline installation detected. Try --with-libedit instead.
75+
])], [
76+
#include <stdio.h>
77+
#include <readline/readline.h>
78+
])
79+
7580
AC_CHECK_DECL([rl_erase_empty_line],
76-
[AC_DEFINE([HAVE_ERASE_EMPTY_LINE], [1])],,
77-
[#include <readline/readline.h>])
81+
[AC_DEFINE([HAVE_ERASE_EMPTY_LINE], [1])],, [
82+
#include <stdio.h>
83+
#include <readline/readline.h>
84+
])
7885
CFLAGS=$CFLAGS_SAVE
7986
LDFLAGS=$LDFLAGS_SAVE
8087
LIBS=$LIBS_SAVE

0 commit comments

Comments
 (0)