php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66716 config without XPM fails
Submitted: 2014-02-14 20:52 UTC Modified: 2021-09-28 15:25 UTC
Votes:22
Avg. Score:4.3 ± 0.8
Reproduced:21 of 21 (100.0%)
Same Version:2 (9.5%)
Same OS:1 (4.8%)
From: rob dot de dot langhe at twistfare dot be Assigned:
Status: Verified Package: GD related
PHP Version: 5.5.9 OS: Solaris-10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rob dot de dot langhe at twistfare dot be
New email:
PHP Version: OS:

 

 [2014-02-14 20:52 UTC] 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 !



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-10 08:33 UTC] dzhren at gmail dot com
I have this problem, thank you for your analysis and resolution, It helps a lot!
 [2015-09-08 21:32 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2015-09-08 21:32 UTC] cmb@php.net
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>
 [2016-04-28 17:41 UTC] uncle dot ziba at gmail dot com
I ran into this in version 5.6.20 on AIX

workaround in  the main/php_config.h comment out:

#define HAVE_GD_XPM 1

make clean; make
 [2018-03-29 22:16 UTC] cmb@php.net
-Type: Feature/Change Request +Type: Bug -Package: Compile Failure +Package: GD related
 [2018-04-12 21:10 UTC] uncle dot ziba at gmail dot com
the issue exists in 5.6.35
 [2021-09-28 15:25 UTC] cmb@php.net
This issue still exists in the latest development branch. It is
somewhat unfortunate, that libgd always defines these functions,
even if their implementations may not work, and raise an error.
However, this could be ckecked by running respective programs
during PHP configuration.  Another option might be to rely on the
info provided by pck-config, presuming this information is made
available by libgd.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 09:01:28 2024 UTC