[phc-general] Re: Phc and readline?

Paul Biggar paul.biggar at gmail.com
Tue Feb 17 16:43:50 GMT 2009


Hi Mateusz,

On Tue, Feb 17, 2009 at 9:14 AM, Mateusz Janowski
<admin at mateuszjanowski.pl> wrote:
> Yes i did ./configure ---enable-embed --with-readline=[dir]. When i
> run php -f manually is ok.


I've managed to replicate the problem, and I don't think we can fix
it. It seems that readline is simply not available in the PHP embed
SAPI. I'm not certain this is the case, but I've traced both PHP cli
and phc's output, and they both come down to the same operation, which
is looking up "readline" in the function-table. The cli, whose
function table has 841 entries, succeeds. embed, whose function table
has 829 entries (I am assuming that just the readline ones are
missing), fails.

One clue might be this:

 $ ./configure --help | grep readline
  --with-libedit[=DIR]    Include libedit readline replacement (CLI/CGI only)
  --with-readline[=DIR]   Include readline support (CLI/CGI only)

This implies that readline is not available to embed, even though
there doesn't seem to be a good reason for this.

Looking a little bit further, there are indeed 12 methods (ie 841 -
829) that are part of readline (13 if using libedit). When running

 $ strings ../php-5.2.6-installed/lib/libphp5.so | grep readline
 './configure'  '--enable-embed' '--with-readline' '--prefix'
libreadline.so.5

vs

 $ strings ../php-5.2.6-installed/bin/php | grep readline
 './configure'  '--enable-embed' '--with-readline' '--prefix'
readline
readline_info
readline_add_history
readline_clear_history
readline_list_history
readline_read_history
readline_write_history
readline_completion_function
readline_callback_handler_install
readline_callback_read_char
readline_callback_handler_remove
readline_redisplay
readline_on_new_line
readline_name
zif_readline_add_history
readline
zif_readline_clear_history
zif_readline_read_history
zif_readline_callback_handler_install
zm_deactivate_readline
zif_readline_info
zif_readline_on_new_line
libreadline.so.5
zm_startup_readline
zif_readline_callback_read_char
zif_readline_callback_handler_remove
zif_readline_redisplay
zif_readline_completion_function
rl_readline_name
zif_readline
zif_readline_list_history
zif_readline_write_history
readline_module_entry

Since its not linked it, its not a problem that we can solve by some
extra calls into the runtime.



So how to solve this?

I would recommend filing a bug with PHP, asking for the readline
extension to be included in the embed SAPI. It seems like an oversight
rather than a feature. In addition, it might be straightforward to
create a patch to fix this yourself. I took a quick look at this, but
I couldn't find where to do this. You might have more luck.


I hope that was helpful, and I'm sorry we weren't able to solve your problem.

Paul

-- 
Paul Biggar
paul.biggar at gmail.com


More information about the phc-general mailing list