php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66013 Solaris build failure
Submitted: 2013-10-31 15:56 UTC Modified: 2017-10-24 10:10 UTC
Votes:21
Avg. Score:4.6 ± 0.7
Reproduced:21 of 21 (100.0%)
Same Version:8 (38.1%)
Same OS:16 (76.2%)
From: Pete_Wall at symantec dot com Assigned:
Status: Open Package: Compile Failure
PHP Version: 7 OS: Solaris 10 (x86 and SPARC)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-10-31 15:56 UTC] Pete_Wall at symantec dot com
Description:
------------
I am trying to build PHP 5.5.4 on Solaris 10 x86 and Solaris 10 SPARC and both are failing in the same spot in ext/sockets/conversions.c.  That file references parameters in the system msghdr structure that aren't defined by default.  If I add the compiler flags to define those parameters, it causes other parts of PHP to fail.

Here's the build output:
/path/to//php-5.5.4/ext/sockets/conversions.c: In function `from_zval_write_control':
/path/to//php-5.5.4/ext/sockets/conversions.c:923: warning: cast to pointer from integer of different size
/path/to//php-5.5.4/ext/sockets/conversions.c: In function `from_zval_write_control_array':
/path/to//php-5.5.4/ext/sockets/conversions.c:973: error: structure has no member named `msg_control'
/path/to//php-5.5.4/ext/sockets/conversions.c:974: error: structure has no member named `msg_controllen'
/path/to//php-5.5.4/ext/sockets/conversions.c: In function `to_zval_read_cmsg_data':
/path/to//php-5.5.4/ext/sockets/conversions.c:1003: warning: cast to pointer from integer of different size
/path/to//php-5.5.4/ext/sockets/conversions.c: In function `to_zval_read_control_array':
/path/to//php-5.5.4/ext/sockets/conversions.c:1037: warning: assignment makes pointer from integer without a cast
/path/to//php-5.5.4/ext/sockets/conversions.c:1039: warning: assignment makes pointer from integer without a cast
/path/to//php-5.5.4/ext/sockets/conversions.c: In function `from_zval_write_controllen':
/path/to//php-5.5.4/ext/sockets/conversions.c:1146: error: structure has no member named `msg_control'
/path/to//php-5.5.4/ext/sockets/conversions.c:1147: error: structure has no member named `msg_controllen'
/path/to//php-5.5.4/ext/sockets/conversions.c: In function `to_zval_read_msghdr': 
/path/to//php-5.5.4/ext/sockets/conversions.c:1248: error: structure has no member named `msg_flags'
/path/to//php-5.5.4/ext/sockets/conversions.c:1248: error: initializer element is not constant 
/path/to//php-5.5.4/ext/sockets/conversions.c:1248: error: (near initialization for `descriptors[3].field_offset')
/path/to//php-5.5.4/ext/sockets/conversions.c:1248: error: initializer element is not constant
/path/to//php-5.5.4/ext/sockets/conversions.c:1248: error: (near initialization for `descriptors[3]')
/path/to//php-5.5.4/ext/sockets/conversions.c:1249: error: initializer element is not constant
/path/to//php-5.5.4/ext/sockets/conversions.c:1249: error: (near initialization for `descriptors[4]')
/path/to//php-5.5.4/ext/sockets/conversions.c: In function `to_zval_read_fd_array':
/path/to//php-5.5.4/ext/sockets/conversions.c:1428: warning: cast to pointer from integer of different size
make: *** [ext/sockets/conversions.lo] Error 1

The ext/sockets/conversions.c code (which looks new to PHP 5.5) uses the msg_control, msg_controllen, and other fields in the msghdr structure.  This structure is defined in /usr/include/sys/socket.h:

/*
 * Message header for recvmsg and sendmsg calls.
 */
struct msghdr {
        void            *msg_name;              /* optional address */
        socklen_t       msg_namelen;            /* size of address */
        struct iovec    *msg_iov;               /* scatter/gather array */
        int             msg_iovlen;             /* # elements in msg_iov */

#if defined(_XPG4_2) || defined(_KERNEL)
        void            *msg_control;           /* ancillary data */
        socklen_t       msg_controllen;         /* ancillary data buffer len */
        int             msg_flags;              /* flags on received message */
#else
        caddr_t         msg_accrights;  /* access rights sent/received */
        int             msg_accrightslen;
#endif  /* defined(_XPG4_2) || defined(_KERNEL) */
};


So those parameters only exist on Solaris if the _XPG4_2 or _KERNEL parameters exist.  I can get those defined if I add these to CFLAGS: -D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1

However, when I do that, the typedef's of unchar, ushort, uint, and ulong don't get defined (because __XOPEN_OR_POSIX gets defined).  From /usr/include/sys/types.h:
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)

/* BEGIN CSTYLED */
typedef unsigned char   unchar;
typedef unsigned short  ushort;
typedef unsigned int    uint;
typedef unsigned long   ulong;
/* END CSTYLED */

With those typedefs missing, Lots of code in the Zend directory fails because ulong is not defined.

So, I'm in a situation if I make one section work, another section fails.  Has anybody else ran into this problem?  I am in the process of upgrading the PHP version from 5.2 to 5.5, so the config options did work in the past.


Patches

ext_socket_config.m4.patch (last revision 2014-02-06 18:17 UTC by alp at rsu dot ru)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-31 18:34 UTC] sixd@php.net
-Status: Open +Status: Feedback
 [2013-10-31 18:34 UTC] sixd@php.net
It would be helpful to list the 'configure' options and build environment (compilers etc)
 [2013-10-31 18:49 UTC] Pete_Wall at symantec dot com
-Status: Feedback +Status: Open
 [2013-10-31 18:49 UTC] Pete_Wall at symantec dot com
Both Solaris 10 x86 and Sparc:
CPPFLAGS=" -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"

./configure --disable-cgi --enable-cli --prefix="/path/to/php"
    --with-libxml-dir="/path/to/libxml" --with-openssl=shared,"/path/to/openssl"
    --with-zlib="/path/to/zlib" --with-curl=shared,"/path/to/curl"
    --with-config-file-path=/path/to/cfgfile --with-layout=GNU
    --with-regex=php --with-tsrm-pthreads --disable-rpath --disable-sysvsem --disable-sysvshm
    --disable-sysvmsg --disable-bcmath --disable-ctype --disable-exif --disable-spl --disable-ftp
    --disable-shmop --enable-tokenizer --disable-static --enable-posix=shared --enable-session=shared
    --enable-sockets=shared --enable-xml=shared --enable-pcntl=shared --enable-dom --without-mm
    --without-gettext --without-iconv --without-sqlite --without-mime-magic --without-mysql --without-sybase-ct
    --without-gdbm --without-db4 --without-cdb --without-pear --without-xsl --disable-debug
    --with-pcre-dir="/path/to/pcre" --with-pcre-regex


Solaris 10 x86:
CFLAGS=" -m64"
$ gcc -v
Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/specs
Configured with: /builds/sfw10-gate/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)


Solaris 10 Sparc:
CFLAGS=""
$ gcc -v
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.6
 [2013-11-03 11:32 UTC] phperror at kim dot net
This error occurs when compiling php 5.5.5 on Omnios which is
a continuation of OpenSolaris.
 [2013-11-03 11:40 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: cataphract
 [2013-11-29 17:09 UTC] rob dot de dot langhe at twistfare dot be
And it also happens on (true) Solaris-10 compiling PHP 5.5.6 on SPARC :

/bin/bash /our_base_dir/src/php-5.5.6/libtool --silent --preserve-dup-deps --mode=compile /our_base_dir/bin/gcc  -Iext/sockets/ -I/our_base_dir/src/php-5.5.6/ext/sockets/ -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/sockets/sockaddr_conv.c -o ext/sockets/sockaddr_conv.lo
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c: In function 'from_zval_write_control_array':
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c:973:8: error: 'struct msghdr' has no member named 'msg_control'
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c:974:8: error: 'struct msghdr' has no member named 'msg_controllen'
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c: In function 'to_zval_read_control_array':
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c:1037:12: warning: assignment makes pointer from integer without a cast [enabled by default]
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c:1039:9: warning: assignment makes pointer from integer without a cast [enabled by default]
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c: In function 'from_zval_write_controllen':
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c:1146:8: error: 'struct msghdr' has no member named 'msg_control'
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c:1147:8: error: 'struct msghdr' has no member named 'msg_controllen'
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c: In function 'to_zval_read_msghdr':
/our_base_dir/src/php-5.5.6/ext/sockets/conversions.c:1248:34: error: 'struct msghdr' has no member named 'msg_flags'

The flags used :
./configure --with-apxs2=/our_base_dir/bin/apxs --with-config-file-path=/our_base_dir/etc --prefix=/our_base_dir --with-gd=/our_base_dir --with-png-dir=/our_base_dir --with-xpm-dir=no --disable-phar --enable-sockets --with-zlib --without-pear --without-iconv
 [2014-01-10 17:48 UTC] meths at btinternet dot com
Still happens with 5.5.7 on SmartOS so is probably affecting all illumos and Solaris based systems.

Also duplicate of https://bugs.php.net/bug.php?id=65427 although the comment in this bug suggests the workaround in that bug is incorrect.
 [2014-01-16 13:26 UTC] christian dot lachner at gmail dot com
On Solaris 5.11, the problem's source is in /usr/include/sys/socket.h where the struct 'msghdr' is declared. The missing two elements '*msg_control' and 'msg_controllen' are IFDEFed out and can only be enabled by setting __lint, _XPG4_2 or _KERNEL. However, neither of these three values is set by the configure-script.

As a result, using export EXTRA_CFLAGS="-D__lint" makes socket.so as well as the rest of php build fine. Don't use EXTRA_CFLAGS="-D_XPG4_2" as it probably breaks other stuff.

Dunno about older Solaris releases though.
 [2014-01-27 19:28 UTC] rainer dot jung at kippdata dot de
My workaround is adding

#define _XOPEN_SOURCE 500
#define _XOPEN_SOURCE_EXTENDED 1
#define __EXTENSIONS__

at the top of the files ext/sockets/conversions.c and ext/sockets/sendrecvmsg.c.
 [2014-02-06 18:07 UTC] alp at rsu dot ru
One more workaround, which we use in OpenIndiana /hipster:
https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/php-5_5/patches/ext_socket_config.m4.patch
 [2015-07-17 19:02 UTC] g dot fischer at ah-consulting dot net
this is still present in 5.6.11, solaris 11.2, sunpro 5.12.
5.3.x and 5.4.x are fine so it seems it was re-introduced in 5.5.x.
also see https://bugs.php.net/bug.php?id=8468 for historical reasons.
 [2016-07-17 14:58 UTC] eugene at zhegan dot in
Still there in 5.6.21 / Solaris 11.2.
 [2016-08-04 05:39 UTC] norm dot jacobs at oracle dot com
FWIW, _XPG4_2 is an internal implementation detail in Solaris and should not be used directly, instead defining _XOPEN_SOURCE >=500 is a possible option.  See the standards(5) man page and/or sys/feature_tests.h on Solaris for more detail.
 [2017-09-21 15:53 UTC] cmb@php.net
-Status: Assigned +Status: Feedback -Assigned To: cataphract +Assigned To: cmb
 [2017-09-21 15:53 UTC] cmb@php.net
Active support for PHP 5 has ended quite a while ago. Does this issue persist
with current PHP 7 versions?
 [2017-10-24 04:20 UTC] g dot fischer at ah-consulting dot net
yes, it still happens with php 7.
 [2017-10-24 10:10 UTC] cmb@php.net
-Summary: Solaris build failure with 5.5 +Summary: Solaris build failure -Status: Feedback +Status: Open -PHP Version: 5.5.5 +PHP Version: 7 -Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 23:01:27 2019 UTC