php / php/php-src

configure does not detect GNU libiconv correctly

Open
#12,213 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Category: Build System Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

The following code:

I am running configure for compiling php 8.2.8 and, when checking if libiconv is available, I get this error message:

checking for mhash support... no
checking size of long... (cached) 8
checking if we're at 64-bit platform... yes
checking for iconv support... yes
checking for iconv... yes
checking if iconv is glibc's... no
checking if using GNU libiconv... no
checking if iconv is Konstantin Chuguev's... no
checking if using IBM iconv... no
checking if iconv supports errno... no
configure: error: iconv does not support errno

The final error message, about errno, is not really correct, since it is derived from all iconv preceeding lines failing. It seems that my iconv is not glibc, nor GNU, nor Chuguev, nor IBM. But my iconv installation is the GNU one, as shown here:

~ $ iconv --version
iconv (GNU libiconv 1.17)
Copyright (C) 2000-2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Bruno Haible.

So, since no iconv is detected, the linker does not add -liconv parameter, and the next conftest, the one about errno, fails because of link error:

configure:44279: checking if iconv supports errno
configure:44309: cc -o conftest  -I/data/data/com.termux/files/home/.termux-build/php/host-build/ext/date/lib -I/data/data/com.termux/files/home/.termux-build/php/src/ext/date/lib -g -O2 -fvisibility=hidden  -D_GNU_SOURCE   conftes
t.c -lrt -lm  >&5
ld.lld: error: undefined symbol: libiconv_open
>>> referenced by conftest.c:230
>>>               /data/data/com.termux/files/usr/tmp/conftest-a89be2.o:(main)

ld.lld: error: undefined symbol: libiconv_close
>>> referenced by conftest.c:238
>>>               /data/data/com.termux/files/usr/tmp/conftest-a89be2.o:(main)
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
configure:44309: $? = 1
configure: program exited with status 1
configure: failed program was:
[...]
| #define HAVE_UTIMES 1
| #define HAVE_STRNDUP 1
| #define SIZEOF_LONG 8
| #define HAVE_ICONV 1
| /* end confdefs.h.  */
| 
| #include <iconv.h>
| #include <errno.h>
| 
| int main() {
|   iconv_t cd;
|   cd = iconv_open( "*blahblah*", "*blahblahblah*" );
|   if (cd == (iconv_t)(-1)) {
|     if (errno == EINVAL) {
|       return 0;
|   } else {
|       return 1;
|     }
|   }
|   iconv_close( cd );
|   return 2;
| }
| 
configure:44317: result: no

Please note that there are no issues when looking for the iconv.h include file.

If I call the compiler manually, with same parameters plus -liconv then build and link are fine.

Resulted in this output:

checking for mhash support... no
checking size of long... (cached) 8
checking if we're at 64-bit platform... yes
checking for iconv support... yes
checking for iconv... yes
checking if iconv is glibc's... no
checking if using GNU libiconv... no
checking if iconv is Konstantin Chuguev's... no
checking if using IBM iconv... no
checking if iconv supports errno... no
configure: error: iconv does not support errno

But I expected this output instead:

Well, I suppose that GNU libiconv test should not fail, at very lest.

checking for mhash support... no
checking size of long... (cached) 8
checking if we're at 64-bit platform... yes
checking for iconv support... yes
checking for iconv... yes
checking if iconv is glibc's... no
checking if using GNU libiconv... yes
checking if iconv is Konstantin Chuguev's... no
checking if using IBM iconv... no
checking if iconv supports errno... no
PHP Version

8.2.8

Operating System

termux 0.118.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the configure iconv detection checks described in the issue and compare the GNU libiconv test with the shown conftest link command. Reproduce the Termux failure, then verify that GNU libiconv is recognized and the required linker flags are included without causing the errno check to fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.