Skip to content

Invalid conftest for rl_pending_input when compiling with -flto(=thin) | ext/readline/config.m4, PHP <= 8.3 #19250

@henderkes

Description

@henderkes

Description

The following code:

| char rl_pending_input ();
| int
| main (void)
| {
| return rl_pending_input ();
|   ;
|   return 0;
| }
zig-cc -o conftest -flto=thin conftest.c -lreadline >&5

Resulted in this output:

ld.lld: error: undefined symbol: rl_pending_input
>>> referenced by conftest.c:6
>>>               /home/m/.cache/zig/o/b805c69c22df553bed686894c3b10bd7/conftest.lto.conftest.o:(main)

But I expected this output instead:

configure:69337: $? = 0
configure:69347: result: yes

In my understanding, this comes down to LLVM IR code embedding type information for symbols. rl_pending_output is defined as an int. Linking against a function char rl_pending_order() works without lto because it ignores type information, but with lto it's a mismatch and the function is indeed undefined.

Passing ac_cv_lib_readline_rl_pending_input=yes to compilation works around the issue and php cli and fpm compile successfully. Embed SAPI fails, but that's for a different ticket.

PHP Version

8.3.23

Operating System

All unix systems

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions