php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41973 Configure fails with LDFLAGS="-Wl,--as-needed"
Submitted: 2007-07-11 23:54 UTC Modified: 2010-12-20 12:27 UTC
From: steffen at hauihau dot de Assigned: nlopess (profile)
Status: Closed Package: Compile Failure
PHP Version: 5.2CVS-2007-07-23 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2007-07-11 23:54 UTC] steffen at hauihau dot de
Description:
------------
I tried to emerge php 5.2.2 on gentoo with ldap support.

configure --prefix=/usr/lib/php5 --host=i686-pc-linux-gnu --mandir=/usr/lib/php5/man --infodir=/usr/lib/php5/info --sysconfdir=/etc --cache-file=./config.cache --enable-maintainer-zts --enable-cli --disable-cgi --with-config-file-path=/etc/php/cli-php5 --with-config-file-scan-dir=/etc/php/cli-php5/ext-active --without-pear --enable-bcmath=shared --with-bz2=shared --enable-calendar=shared --with-curl=shared --without-curlwrappers --disable-dbase --enable-exif=shared --without-fbsql --without-fdftk --disable-filter --enable-ftp=shared --with-gettext=shared --without-gmp --disable-json --without-kerberos --enable-mbstring=shared --with-mcrypt=shared --with-mhash=shared --without-msql --without-mssql --with-ncurses=shared --with-openssl --with-openssl-dir=/usr --disable-pcntl --disable-pdo --without-pgsql --with-pspell=shared --without-recode --disable-simplexml --disable-shmop --with-snmp=shared --enable-soap=shared --enable-sockets=shared --without-sybase --without-sybase-ct --disable-sysvmsg --disable-sysvsem --disable-sysvshm --with-tidy=shared --disable-wddx --with-xmlrpc=shared --with-xsl=shared --enable-zip=shared --with-zlib=shared --disable-debug --enable-dba=shared --without-cdb --with-db4 --without-flatfile --with-gdbm --without-inifile --without-qdbm --with-freetype-dir=/usr --with-t1lib=/usr --disable-gd-jis-conv --with-jpeg-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr/X11R6 --with-gd --with-imap=shared --with-imap-ssl --with-ldap=shared --without-ldap-sasl --with-mysql=shared,/usr --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-mysqli=shared,/usr/bin/mysql_config --with-readline --without-libedit --without-mm --with-sqlite=/usr --enable-sqlite-utf8

Configure failes with these ldap related functions:
checking for LDAP support... yes, shared
checking for LDAP Cyrus SASL support... no
checking for 3 arg ldap_set_rebind_proc... yes
checking for ldap_parse_result... no
checking for ldap_parse_reference... no
checking for ldap_start_tls_s... no
checking for ldap_bind_s... no
configure: error: LDAP build check failed. Please check config.log for more information.


In config.log it sais:
configure:67384: checking for ldap_bind_s
configure:67440: i686-pc-linux-gnu-gcc -o conftest -I/usr/include -march=pentium-m -O2 -msse3 -pipe -fomit-frame-pointer -pthread  -D_REENTRANT -I/usr/include -L/usr/lib -L/usr/lib -Wl,-O1 -Wl,--as-needed -Wl,-znow -Wl,--sort-common -s -lldap -llber  conftest.c -lt1 -lfreetype -lX11 -lXpm -lpng -lz -ljpeg -ldb-4.5 -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm -lssl -lcrypto -ldl -lxml2 -lz -lm >&5
/var/tmp/portage/dev-lang/php-5.2.2-r1/temp/ccfMyG4A.o: In function `main':
conftest.c:(.text+0xf): undefined reference to `ldap_bind_s'
collect2: ld returned 1 exit status


I tried to manually compile the failed code and get it to work when I added "-lldap" to the end of the above command. So I think "-lldap" is missing in $LIBS. I do not know if this is really a bug, but I have no idea how to fix this issue as I need ldap support in php. If you need further Information, please let me know.

Regards,
Steffen Hau


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-12 00:00 UTC] sniper@php.net
Does it work if you remove the '=shared' from the --with-ldap option..?
(remember to delete config.cache if you don't do clean build)

Also, upgrade to PHP 5.2.3 first.
 [2007-07-12 11:31 UTC] steffen at hauihau dot de
Gentoo has no ebuild for php  5.2.3, so I have to wait, until they release one. Yes, configure works, if I remove '=shared' from --with-ldap, but as I think, this is, because '-lldap' is added to $LIBS in configure when $ext_shared is not true. Removing the '=shared'  is not pratical because the change will be overriden when the next portage sync is done.

I searched for the mysql related stuff in configure to see how this is done, and there, $LIBS is expanded by '-lmysqlclient' before conftest.c gets compiled (e.g. Checking for mysql_close in -lmysqlclient).

So, I could imagine, that $LIBS should also be expanded with '-lldap' before the conftests are done. Or am I wrong?

Regards
Steffen
 [2007-07-12 11:41 UTC] jani@php.net
I can not reproduce this with latest PHP_5_2 CVS checkout.
We do not support any 3rd party "ports" either. 

Feel free to reopen this IF you can reproduce it using latest 5.2 CVS snapshot from http://snaps.php.net/

 [2007-07-16 13:26 UTC] steffen at hauihau dot de
Sorry for the late answer.

I tried to configure PHP_5_2 CVS (200707161230) and it does also complain about missing 'ldap_bind_s'.

LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-znow -Wl,--sort-common -s"
CFLAGS="-march=pentium-m -O2 -msse3 -pipe -fomit-frame-pointer"
CPPFLAGS="-march=pentium-m -O2 -msse3 -pipe -fomit-frame-pointer"

I invoked configure the same way as in my first post. The result is the same.

I found out, that configure works, if I remove '-Wl,as-needed' from my LDFLAGS. Is this flag not supported?

Regards
Steffen
 [2007-07-24 15:26 UTC] jani@php.net
Of course that flag will cause problems. And it's not something we're likely to "fix" as we link only with libs that are needed anyways and it would break every check we do in configure, as you noticed.

Feel free to provide a patch, otherwise: Don't use that flag when building PHP.
 [2007-07-24 15:51 UTC] steffen at hauihau dot de
Thanks a lot for your answer.

I'm wondering, why configure works fine with this flag set when I invoke it with '--without-ldap'. Every check works, except ldap. When I manually edit configure and add LIBS="$LIBS -ldap" before the checks for the first ldap related tests are done (before 'for ac_func in ldap_parse_result ldap_parse_reference ldap_start_tls_s') it works, and the following make succeeds.

My knowledge about compiler and linker is not that big. Would it be the wrong way, to permanently add '-ldap' to $LIBS before the tests for the ldap related functions are done? You could for example backup $LIBS in $ac_check_lib_save_LIBS before. This is only an idea, if it's definitely not possible, to workaround this issue, I will have to file a bug for this gentoo ebuild and they should discuss about this topic.

Regards,
Steffen
 [2007-07-25 13:44 UTC] nlopess@php.net
Can you please try this patch: http://gcov.php.net/~nlopess/ldap_ldflags_patch.txt
 [2007-07-28 02:40 UTC] steffen at hauihau dot de
Thanks a lot. configure succeeded with your patch. The following make also succeeds.

So, do you plan to integrate this patch in the next release of php, or should I tell the gentoo people maintaining the php ebuild, that they should integrate this patch in their ebuilds for php?

Regards,
Steffen
 [2007-07-30 00:01 UTC] jani@php.net
Nuno, just commit the patch. I'm too busy. (both HEAD and PHP_5_2)

 [2007-08-08 11:38 UTC] nlopess@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-12-20 12:27 UTC] jani@php.net
-Package: Tidy +Package: Compile Failure
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC