Req #66716 [Opn->Ver]: config without XPM fails

From: Date: Tue, 08 Sep 2015 21:32:35 +0000
Subject: Req #66716 [Opn->Ver]: config without XPM fails
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195890@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66716&edit=1 ID: 66716 Updated by: cmb@php.net Reported by: rob dot de dot langhe at twistfare dot be Summary: config without XPM fails -Status: Open +Status: Verified Type: Feature/Change Request Package: Compile Failure Operating System: Solaris-10 PHP Version: 5.5.9 Block user comment: N Private report: N New Comment: The relevant check in ./configure is generated by PHP_CHECK_LIBRARY()[1], which is obviously insufficient to check for XPM support in an external libgd as elaborated by the OP. As the check does not fulfill its purpose, this is a bug. [1] <https://github.com/php/php-src/blob/php-7.0.0RC2/ext/gd/config.m4#L233> Previous Comments: ------------------------------------------------------------------------ [2014-03-10 08:33:09] dzhren at gmail dot com I have this problem, thank you for your analysis and resolution, It helps a lot! ------------------------------------------------------------------------ [2014-02-14 20:52:14] rob dot de dot langhe at twistfare dot be Description: ------------ previously filed "https://bugs.php.net/bug.php?id=66204", but that was rejected as "not a bug"... However, there is no way currently to build PHP with libgd, but without XPM. We don't want XPM, some suggested on the web to install XPM so that they could succeed building PHP. Therefor I file this 'change request': 1) when "libgd" (version 2.1.0) is 'configure'd with "--without-xpm", it will include anyhow a function "gdImageCreateFromXpm ()" from file 'src/gdxpm.c' with #ifndef HAVE_LIBXPM BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename) { (void)filename; gd_error_ex(GD_ERROR, "libgd was not built with xpm support\n"); return NULL; } #else #include <X11/xpm.h> ... 2) when "php" (version 5.5.9) is 'configure'd with "--with-xpm-dir=no" then it runs as follows: ... configure:37479: checking for the location of libXpm configure:37494: result: no ... configure:42617: checking for gdImageCreateFromXpm in -lgd configure:42642: /our_base_dir/bin/gcc -o conftest -m32 -I/our_base_dir/include -fvisibility=hidden -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -L/our_base_dir/lib -lxml2 -m32 -R/usr/ucblib -L/usr/ucblib -R/our_base_dir/lib/gcc/sparc-sun-solaris2.10/4.7.1 -L/ our_base_dir/lib/gcc/sparc-sun-solaris2.10/4.7.1 -R/our_base_dir/lib -L/our_base_dir/lib conftest.c -lgd -lgd -lpng -lz -lpng -lz -lz -lrt -lm -lnsl -lsocket -lgcc -lxml2 -lz -lm -lso cket -lnsl -lxml2 -lz -lm -lsocket -lnsl >&5 configure:42642: $? = 0 configure:42651: result: yes ... With the "conftest.c" file containing a call to that function "gdImageCreateFromXpm()", to see if the compiler finds that function in the "libgd.so.3.0.0" library, which it does despite that we disabled the support for XPM in the building of LIBGD. $ cat conftest.c #ifdef __cplusplus extern "C" #endif char gdImageCreateFromXpm (); int main () { return gdImageCreateFromXpm (); ; return 0; } After "configure" is done, the "config.status" contains the flag D["HAVE_GD_XPM"]=" 1" so that PHP will attempt to build with X11 support, and fails during compilation because we do not (and don't want) have the X11 libraries installed: ... /bin/bash /our_base_dir/php-5.5.9/libtool --silent --preserve-dup-deps --mode=link /our_base_dir/bin/gcc ... -o sapi/cli/php Undefined first referenced symbol in file XpmLibraryVersion ext/gd/.libs/gd.o ld: fatal: Symbol referencing errors. No output written to sapi/cli/php collect2: error: ld returned 1 exit status make[2]: *** [sapi/cli/php] Error 1 This is because in "ext/gd/gd.c" the code will call XpmLibraryVersion() when the flag "HAVE_GD_XPM" has value '1' : ... #if defined(HAVE_GD_XPM) php_info_print_table_row(2, "XPM Support", "enabled"); { char tmp[12]; snprintf(tmp, sizeof(tmp), "%d", XpmLibraryVersion()); php_info_print_table_row(2, "libXpm Version", tmp); } #endif ... Conclusion: the PHP configure script is not checking correctly if the libgd contains XPM or not: libgd will always contain that function gdImageCreateFromXpm(), but that function will just return a different value depending on with- or without-XPM was specified. PHP configure script should therefor test on the return value of that function gdImageCreateFromXpm(), not just if the test program can be linked correctly with the libgd library. A fix can be this: modify the line in 'configure' such that it does not only check if that function gdImageCreateFromXpm() can be found in the libgd library (because it always will be there anyhow) but call it and check if it returns NULL indicating that there is no XPM support in the libgd : in 'configure': replace this: return gdImageCreateFromXpm (); by this: if(gdImageCreateFromXpm()!=NULL){return 1;}else {return 0;} With this change, PHP builds just fine on Solaris-10, using GCC, and libgd (v2.1.0) but without any X11/XPM installed ! ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66716&edit=1

« previous php.bugs (#195890) next »