Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 364139 - dev-lang/php-5.2.14: Failed to emerge (undefined reference to `iconv')
Summary: dev-lang/php-5.2.14: Failed to emerge (undefined reference to `iconv')
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: x86 FreeBSD
: Normal normal (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords:
: 410573 (view as bug list)
Depends on:
Blocks: 401067
  Show dependency tree
 
Reported: 2011-04-19 14:51 UTC by Denis I. Polukarov
Modified: 2012-06-14 11:45 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
The complete build log (build.log.bz2,17.56 KB, application/octet-stream)
2011-04-19 14:51 UTC, Denis I. Polukarov
Details
The ebuild environment file (environment.bz2,36.29 KB, application/octet-stream)
2011-04-19 14:52 UTC, Denis I. Polukarov
Details
emerge --info =dev-lang/php-5.2.14 (info,3.93 KB, text/plain)
2011-04-19 14:52 UTC, Denis I. Polukarov
Details
emerge -pqv =dev-lang/php-5.2.14 (pqv,920 bytes, text/plain)
2011-04-19 14:52 UTC, Denis I. Polukarov
Details
php-freebsd.patch (php-freebsd.patch,1.65 KB, text/plain)
2011-11-29 10:12 UTC, Naohiro Aota
Details
php-5.4.0-libiconv.patch (file_364139.txt,498 bytes, patch)
2012-04-02 13:44 UTC, Naohiro Aota
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Denis I. Polukarov 2011-04-19 14:51:28 UTC
ext/iconv/iconv.o: In function `_php_iconv_appendl':
iconv.c:(.text+0x510): undefined reference to `iconv' ...

Reproducible: Always

Steps to Reproduce:
1. emerge =dev-lang/php-5.2.14
2.
3.
Actual Results:  
Failed to emerge.

Expected Results:  
emerged dev-lang/php
Comment 1 Denis I. Polukarov 2011-04-19 14:51:52 UTC
Created attachment 270547 [details]
The complete build log
Comment 2 Denis I. Polukarov 2011-04-19 14:52:13 UTC
Created attachment 270549 [details]
The ebuild environment file
Comment 3 Denis I. Polukarov 2011-04-19 14:52:30 UTC
Created attachment 270551 [details]
emerge --info =dev-lang/php-5.2.14
Comment 4 Denis I. Polukarov 2011-04-19 14:52:48 UTC
Created attachment 270553 [details]
emerge -pqv =dev-lang/php-5.2.14
Comment 5 Denis I. Polukarov 2011-04-19 15:11:44 UTC
Keyworded =dev-lang/php-5.3.6 failed to build on "undefined reference to 'iconv' " too.
Comment 6 Yuta SATOH 2011-04-20 16:41:46 UTC
FYI,
I corrected this problem on my overlay several days ago. However, it is still testing. 

Please check following URL if you want to test it now. 
https://github.com/nigoro/amd64-fbsd/commit/e08434015754ade48b3170495c4e73e9e7c1ca45.diff

Additionally, there are some packages where other I have not reported on the bug yet in overlay.
Please check it if you are interested.
https://github.com/nigoro/amd64-fbsd/

Thanks in advance.
Comment 7 yegle 2011-07-25 13:03:18 UTC
This problem exists in Gentoo-prefix for Linux too.
Comment 8 Naohiro Aota gentoo-dev 2011-11-10 13:26:00 UTC
PHP team, (& cc prefix team)

Could you take a look at the patch above please?  I've confirmed the
patch make it (at least) build on x86-fbsd 8.2. (It doesn't pass test
cases)
Comment 9 Naohiro Aota gentoo-dev 2011-11-29 10:12:06 UTC
Created attachment 294149 [details]
php-freebsd.patch

Rebased patch on current portage tree.
Comment 10 Naohiro Aota gentoo-dev 2011-12-18 07:56:01 UTC
(In reply to comment #9)
> Created attachment 294149 [details]
> php-freebsd.patch
> 
> Rebased patch on current portage tree.

ping! any comments?
Comment 11 Fabian Groffen gentoo-dev 2011-12-18 08:45:52 UTC
Why not enable libiconv for all platforms that don't have iconv in their libc?  (e.g. !elibc_glibc)?

My src_configure-v2.eblit already contains
phpconfutils_extension_with    "iconv"        "iconv"            0          "${EPREFIX}/usr"
(without conditional) -- maybe this is a Prefix-local change, but if not, your patch looks redundant.
Comment 12 Ole Markus With (RETIRED) gentoo-dev 2011-12-18 09:05:23 UTC
(In reply to comment #11)
> Why not enable libiconv for all platforms that don't have iconv in their libc? 
> (e.g. !elibc_glibc)?
> 
> My src_configure-v2.eblit already contains
> phpconfutils_extension_with    "iconv"        "iconv"            0         
> "${EPREFIX}/usr"
> (without conditional) -- maybe this is a Prefix-local change, but if not, your
> patch looks redundant.

We do not have this line in gentoo-x86. Besides, the newer src_configure eblits use $(use_with iconv iconv ) instead of the custom function from phpconfutils.

Just let me know what lines I should add and I can review/fix it asap.
Comment 13 Naohiro Aota gentoo-dev 2012-04-02 13:44:22 UTC
Created attachment 307489 [details, diff]
php-5.4.0-libiconv.patch

I got the real problem. This shoud be PHP configure bug.

php-5.4.0/acinclude.m4:
  dnl
  dnl Check libc first if no path is provided in --with-iconv
  dnl
  if test "$PHP_ICONV" = "yes"; then
    AC_CHECK_FUNC(iconv, [
      found_iconv=yes
    ],[
      AC_CHECK_FUNC(libiconv,[
        PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
        AC_DEFINE(HAVE_LIBICONV, 1, [ ])
        found_iconv=yes
      ])
    ])
  fi

This code actually check iconv or libiconv not only for libc, but also
$LIBS already set.

As Denis and I enabled libxml2, php added `xml2-config --libs` to
$LIBS, leading to confuse the test above.

Once $found_iconv set to "yes", php skip the test below and
ICONV_ALIASED_LIBICONV undefined.

php-5.4.0/acinclude.m4:
  dnl
  dnl Check external libs for iconv funcs
  dnl
  if test "$found_iconv" = "no"; then
<snip>
      PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
        found_iconv=yes
        PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
        AC_DEFINE(HAVE_LIBICONV,1,[ ])
        PHP_DEFINE([ICONV_ALIASED_LIBICONV],1,[ext/iconv])
        AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv])
      ], [
        PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
          found_iconv=yes
        ], [], [
<snip>
  fi

OTOTH it should be defined and have the effect to replace iconv(...)
to libiconv(...) for proper libiconv linking. (libiconv has function
named libiconv() not iconv())

php-5.4.0/ext/iconv/iconv.c:
#if defined(HAVE_LIBICONV) && defined(ICONV_ALIASED_LIBICONV)
#define iconv libiconv
#endif

I've applied attached patch and it get built fine.
Comment 14 Naohiro Aota gentoo-dev 2012-04-02 15:26:44 UTC
*** Bug 410573 has been marked as a duplicate of this bug. ***
Comment 15 Naohiro Aota gentoo-dev 2012-04-02 15:31:11 UTC
(In reply to comment #13)
> This code actually check iconv or libiconv not only for libc, but also
> $LIBS already set.
> 
> As Denis and I enabled libxml2, php added `xml2-config --libs` to
> $LIBS, leading to confuse the test above.

It lacked some description. xml2-config --libs return "-L/usr/lib -lxml2 -lz -lpthread -liconv -lm", so that the test pass with linking libiconv() using -liconv.
Comment 16 Alexis Ballier gentoo-dev 2012-04-02 15:43:14 UTC
(In reply to comment #15)
> (In reply to comment #13)
> > This code actually check iconv or libiconv not only for libc, but also
> > $LIBS already set.
> > 
> > As Denis and I enabled libxml2, php added `xml2-config --libs` to
> > $LIBS, leading to confuse the test above.
> 
> It lacked some description. xml2-config --libs return "-L/usr/lib -lxml2 -lz
> -lpthread -liconv -lm", so that the test pass with linking libiconv() using
> -liconv.

it would make sense to use libxml-2.0.pc instead of xml2-config imho, the former supports Libs.private for static linking, while the latter seems to provide them regardless and produces overlinking (and, as a consequence, this problem).
Comment 17 Naohiro Aota gentoo-dev 2012-04-13 22:41:00 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > (In reply to comment #13)
> > > This code actually check iconv or libiconv not only for libc, but also
> > > $LIBS already set.
> > > 
> > > As Denis and I enabled libxml2, php added `xml2-config --libs` to
> > > $LIBS, leading to confuse the test above.
> > 
> > It lacked some description. xml2-config --libs return "-L/usr/lib -lxml2 -lz
> > -lpthread -liconv -lm", so that the test pass with linking libiconv() using
> > -liconv.
> 
> it would make sense to use libxml-2.0.pc instead of xml2-config imho, the
> former supports Libs.private for static linking, while the latter seems to
> provide them regardless and produces overlinking (and, as a consequence,
> this problem).

Yes, but there's a lot of tests that can add -liconv... :(

anyway, upstream already patched their source to reset LIBS. I'll apply this patch and re-KEYWORD ~x86-fbsd.

http://git.php.net/?p=php-src.git;a=commitdiff;h=a6c95c8a00e9286ccc662e9682f9254e153d6833;hp=8684fb7facd8f5c1589996c1ebfd782f77c245ff
Comment 18 Naohiro Aota gentoo-dev 2012-04-19 11:59:34 UTC
I've stacked with adding patch. I think, it would be better to have the patch in php-patches-*.tar.bz2. I don't have access permission for the files.
Could you add the patch to the files please?
Comment 19 Ole Markus With (RETIRED) gentoo-dev 2012-04-19 12:11:40 UTC
As I understand this thread, the patch is applied upstream. If so, it means it will be in the next version of PHP 5.x, which will hopefully be released next week.
Comment 20 Naohiro Aota gentoo-dev 2012-04-19 22:25:07 UTC
(In reply to comment #19)
> As I understand this thread, the patch is applied upstream. If so, it means
> it will be in the next version of PHP 5.x, which will hopefully be released
> next week.

OK, then I wait for it. Thanks.
Comment 21 Naohiro Aota gentoo-dev 2012-04-27 11:59:52 UTC
It's not in -5.3.11 and -5.4.1 :( It seems it will be in -5.3.12 maybe. Would it come some time soon?
Comment 22 Ole Markus With (RETIRED) gentoo-dev 2012-04-27 12:40:09 UTC
(In reply to comment #21)
> It's not in -5.3.11 and -5.4.1 :( It seems it will be in -5.3.12 maybe.
> Would it come some time soon?

The micro versions are typically released once a month. Depends on how many bugs they discover in the rc phase.

If this patch is not in 5.3.12_rc1 when released, let me know and I will add it to our patchset. Now it is unfortunately too late, since 5.3.12 will probably be released before I can do an -r1
Comment 23 Naohiro Aota gentoo-dev 2012-05-25 20:00:57 UTC
(In reply to comment #22)
> If this patch is not in 5.3.12_rc1 when released, let me know and I will add
> it to our patchset. Now it is unfortunately too late, since 5.3.12 will
> probably be released before I can do an -r1

It's not in -5.3.13 nor -5.4.3.
Comment 24 Ole Markus With (RETIRED) gentoo-dev 2012-05-29 18:42:24 UTC
(In reply to comment #23)
> (In reply to comment #22)
> > If this patch is not in 5.3.12_rc1 when released, let me know and I will add
> > it to our patchset. Now it is unfortunately too late, since 5.3.12 will
> > probably be released before I can do an -r1
> 
> It's not in -5.3.13 nor -5.4.3.

These two versions are emergency security fixes. However, rc's are already out for .14 and .4, and as far as I can tell, the patch (or its equivalent) is there: 
http://git.php.net/?p=php-src.git;a=blob;f=acinclude.m4;h=adb9599ce4887b0a56852a91f255bf65e703fae5;hb=refs/heads/PHP-5.4#l2449
Comment 25 Alexis Ballier gentoo-dev 2012-05-29 18:52:42 UTC
FWIW: I've keyworded php 5.3.13 and 5.4.3 ~amd64-fbsd and masked php[iconv] on amd64-fbsd profiles
Comment 26 Naohiro Aota gentoo-dev 2012-06-14 11:45:26 UTC
Now it get fixed. ~x86-fbsd added.