Bug #66204 [Com]: disabling XPM support in GD still enables gdImageCreateFromXpm() for PHP

From: Date: Fri, 29 Nov 2013 16:08:43 +0000
Subject: Bug #66204 [Com]: disabling XPM support in GD still enables gdImageCreateFromXpm() for PHP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183013@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66204&edit=1

 ID:                 66204
 Comment by:         rob dot de dot langhe at twistfare dot be
 Reported by:        rob dot de dot langhe at twistfare dot be
 Summary:            disabling XPM support in GD still enables
                     gdImageCreateFromXpm() for PHP
 Status:             Open
 Type:               Bug
 Package:            GD related
 Operating System:   Solaris-10
 PHP Version:        5.5.6
 Block user comment: N
 Private report:     N

 New Comment:

The "libgd" library will apparently always contain a function
"gdImageCreateFromXpm()", but which will return an error when it is called in case the
building of "libgd" was done with "--with-xpm=no" :

in ./src/gdxpm.c :
...
#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
...

So the check done by PHP with a linking of a test program to see if there is XPM support in the
"libgd" library, despite the fact that the 'configure' flags
"--without-xpm" or "--with-xpm-dir=no" were given, is incorrect. It will always
return success, because that function "gdImageCreateFromXpm()" will always be in the libgd
library file.


Previous Comments:
------------------------------------------------------------------------
[2013-11-29 15:33:36] rob dot de dot langhe at twistfare dot be

Description:
------------
We do not want to include X11 (XPM) support.

So we built the LIBGD library (version 2.1.0) with GCC (version 4.7.1) using both the flags
"--with-xpm=no --without-xpm"
However the generated library "libgd.so.3.0.0" still contains a function
"gdImageCreateFromXpm()" which is used by PHP to see if XPM is anyhow available in the
"libgd" library:

When building the PHP version 5.5.6 using the flag "--with-xpm-dir=no" gives the following
output from "configure" :
...
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:

$ make
...
/bin/bash /our_base_dir/src/php-5.5.6/libtool --silent --preserve-dup-deps --mode=compile
/our_base_dir/bin/gcc -I/our_base_dir/include -Iext/gd/ -I/our_base_dir/src/php-5.5.6/ext/gd/
-DPHP_ATOM_INC -I/our_base_dir/src/php-5.5.6/include -I/our_base_dir/src/php-5.5.6/main
-I/our_base_dir/src/php-5.5.6 -I/our_base_dir/src/php-5.5.6/ext/date/lib
-I/our_base_dir/src/php-5.5.6/ext/ereg/regex -I/usr/include/libxml2 -I/our_base_dir/include
-I/our_base_dir/src/php-5.5.6/ext/sqlite3/libsqlite -I/our_base_dir/src/php-5.5.6/TSRM
-I/our_base_dir/src/php-5.5.6/Zend  -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS
-D_REENTRANT  -m32 -I/our_base_dir/include -fvisibility=hidden -DZTS  -c
/our_base_dir/src/php-5.5.6/ext/gd/gd.c -o ext/gd/gd.lo
/bin/bash /our_base_dir/src/php-5.5.6/libtool --silent --preserve-dup-deps --mode=compile
/our_base_dir/bin/gcc -I/our_base_dir/include -Iext/gd/ -I/our_base_dir/src/php-5.5.6/ext/gd/
-DPHP_ATOM_INC -I/our_base_dir/src/php-5.5.6/include -I/our_base_dir/src/php-5.5.6/main
-I/our_base_dir/src/php-5.5.6 -I/our_base_dir/src/php-5.5.6/ext/date/lib
-I/our_base_dir/src/php-5.5.6/ext/ereg/regex -I/usr/include/libxml2 -I/our_base_dir/include
-I/our_base_dir/src/php-5.5.6/ext/sqlite3/libsqlite -I/our_base_dir/src/php-5.5.6/TSRM
-I/our_base_dir/src/php-5.5.6/Zend  -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS
-D_REENTRANT  -m32 -I/our_base_dir/include -fvisibility=hidden -DZTS  -c
/our_base_dir/src/php-5.5.6/ext/gd/gd_compat.c -o ext/gd/gd_compat.lo
/our_base_dir/src/php-5.5.6/ext/gd/gd.c:57:22: fatal error: X11/xpm.h: No such file or directory

Any idea how we can really force the disabling of XPM support in the libgd library ?


Expected result:
----------------
A way to really disable the XPM support in the libgd library.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66204&edit=1


Thread (8 messages)

« previous php.bugs (#183013) next »