php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50496 Use of <stdbool.h> is valid only in a c99 compilation environment.
Submitted: 2009-12-16 15:03 UTC Modified: 2010-01-12 10:21 UTC
From: alexander at skwar dot name Assigned: srinatar (profile)
Status: Closed Package: Compile Failure
PHP Version: 5.3SVN-2009-12-16 (snap) OS: Solaris 10, Sparc
Private report: No CVE-ID: None
 [2009-12-16 15:03 UTC] alexander at skwar dot name
Description:
------------
I'm trying to get php5.3-200912160730 to compile with Sun Studio 12.1 on a Solaris 10 Sparc system. It fails:

/bin/sh /export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/libtool --silent --preserve-dup-deps --mode=compile /opt/sunstudio12.1/bin/cc  -Iext/standard/ -I/export/home/user/Source/php5.3-200912160730/ext/standard/ -DPHP_ATOM_INC -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/include -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/main -I/export/home/user/Source/php5.3-200912160730 -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/ext/date/lib -I/export/home/user/Source/php5.3-200912160730/ext/date/lib -I/export/home/user/Source/php5.3-200912160730/ext/ereg/regex -I/opt/local/libxml2/include/libxml2 -I/opt/local/openssl/include -I/opt/local/pcre/include -I/opt/local/sqlite/include -I/opt/local/zlib/include -I/opt/local/curl/include -I/opt/local/gettext/include -I/opt/local/libiconv/include -I/export/home/user/Source/php5.3-200912160730/ext/mbstring/oniguruma -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/ext/mbstring/oniguruma -I/export/home/user/Source/php5.3-200912160730/ext/mbstring/libmbfl -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/ext/mbstring/libmbfl -I/export/home/user/Source/php5.3-200912160730/ext/mbstring/libmbfl/mbfl -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/ext/mbstring/libmbfl/mbfl -I/opt/local/libmcrypt/include -I/opt/local/mysql/include/mysql -I/opt/local/instantclient_11_1/32/sdk/include -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/TSRM -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/Zend -I/export/home/user/Source/php5.3-200912160730/main -I/export/home/user/Source/php5.3-200912160730/Zend -I/export/home/user/Source/php5.3-200912160730/TSRM -I/export/home/user/Source/php5.3-200912160730/build.32bit.20091216-105042/  -D_POSIX_PTHREAD_SEMANTICS  -I/opt/local/libiconv/include -xO5 -xdepend=yes -xmemalign=8s -fsimple=2 -fns=yes -ftrap=%none -xlibmil -xlibmopt -xbuiltin=%all -D__MATHERR_ERRNO_DONTCARE -fsingle -xalias_level=basic -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xarch=sparcima -xipo=1 -xmemalign=8s  -c /export/home/user/Source/php5.3-200912160730/ext/standard/crypt_sha512.c -o ext/standard/crypt_sha512.lo 
"/usr/include/stdbool.h", line 42: #error: "Use of <stdbool.h> is valid only in a c99 compilation environment."
cc: acomp failed for /export/home/user/Source/php5.3-200912160730/ext/standard/crypt_sha512.c
*** Error code 1
make: Fatal error: Command failed for target `ext/standard/crypt_sha512.lo'

The exact same "./configure [...] && make" cycle worked with 5.3.0.

I'm using a Snap because of bug #50345 - "nanosleep not detected properly on some solaris versions".

Reproduce code:
---------------
See http://bash.pastebin.com/f592ffdbf for the script which calls configure
After having run that, I did cd "$HOME/Source/php5.3-200912160730/build.32bit.20091216-105042" ; make


Expected result:
----------------
It's compiling on php-5.3.0. And so it should compile on 5.3.1 as well.


Actual result:
--------------
Doesn't compile.

Maybe it is required to compile certain parts with -xc99=all?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-16 15:24 UTC] alexander at skwar dot name
I added

 -xc99=all 

to the beginning of my CFLAGS (see http://bash.pastebin.com/pastebin.php?diff=f14d9a4ab) and this allowed me to compile (it's still compiling but I'm past that step which error out earlier).
 [2009-12-16 15:47 UTC] pajoye@php.net
It builds just fine on the test solaris system provided by Sun.

If you have a patch fixing this issue on your platform without breaking other then please post a link to it here.
 [2009-12-16 17:30 UTC] alexander at skwar dot name
Hm.

That's strange. It shouldn't be depending on the version of Solaris. In /usr/include/stdbool.h, there is:


#else /* _STDC_C99 */

#error "Use of <stdbool.h> is valid only in a c99 compilation environment."

#endif /* _STDC_C99 */

So, for some reason or the other, you had _STDC_C99 defined. This should only be defined if compiling in C99 mode.

I'm right now downloading Solaris 10 U8 to install it in a Virtual Box together with Sun Studio 12.1. I expect it to error out.

Out of curiosity: Which version of Solaris 10 are you using? U8? I'm *NOT* using OpenSolaris, BTW. And I find it quite curious that php-5.3.0 compiles and php-5.3.1+ does not. The only difference is the source code of PHP. This kinda leads me to think, that the problem is related to PHP.
 [2009-12-16 18:09 UTC] pajoye@php.net
That code is new in 5.3.1, it adds (or restore when SHA-512/256 was available on the system) features to crypt.

Ah, that could be the problem. I tested using OpenSolaris on a t2000 box. I have no solaris to test.

@srinatar, can you take a look at this issue please? That would be very helpful :)
 [2009-12-16 18:25 UTC] srinatar@php.net
yup, will look into this today.
 [2009-12-16 20:10 UTC] srinatar@php.net
Sun Studio compiler does not by default enable ANSIC C99 standard and 
its extensions and need to be explicitly enabled. !

this patch addresses this patch by enabling ANSIC99 standard. 

[sriramn@chilidev]'PHP_5_3'>svn diff acinclude.m4                                                                                                           
Index: acinclude.m4
===================================================================
--- acinclude.m4        (revision 292219)
+++ acinclude.m4        (working copy)
@@ -2780,7 +2780,7 @@
     AC_MSG_RESULT([no]),
     SUNCC="yes"
     GCC="no"
-    test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
+    test -n "$auto_cflags" && CFLAGS="-O -xc99=all -xs -xstrconst -
zlazyload"
     GCC=""
     AC_MSG_RESULT([yes])
   )

if no one has any objections, i will commit this patch

here is the complete patch
Index: trunk/acinclude.m4
===================================================================
--- trunk/acinclude.m4  (revision 292220)
+++ trunk/acinclude.m4  (working copy)
@@ -2780,7 +2780,7 @@
     AC_MSG_RESULT([no]),
     SUNCC="yes"
     GCC="no"
-    test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
+    test -n "$auto_cflags" && CFLAGS="-O -xc99=all -xs -xstrconst -
zlazyload"
     GCC=""
     AC_MSG_RESULT([yes])
   )
Index: branches/PHP_5_3/acinclude.m4
===================================================================
--- branches/PHP_5_3/acinclude.m4       (revision 292219)
+++ branches/PHP_5_3/acinclude.m4       (working copy)
@@ -2780,7 +2780,7 @@
     AC_MSG_RESULT([no]),
     SUNCC="yes"
     GCC="no"
-    test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
+    test -n "$auto_cflags" && CFLAGS="-O -xc99=all -xs -xstrconst -
zlazyload"
     GCC=""
     AC_MSG_RESULT([yes])
   )
Index: branches/PHP_5_3/NEWS
===================================================================
--- branches/PHP_5_3/NEWS       (revision 292219)
+++ branches/PHP_5_3/NEWS       (working copy)
@@ -9,6 +9,8 @@
 - Changed "post_max_size" php.ini directive to allow unlimited post 
size by
   setting it to 0. (Rasmus)
 
+- Fixed bug #50496 (Use of <stdbool.h> is valid only in a c99 
compilation 
+  environment. (Sriram)
 - Added support for SHA-256 and SHA-512 to php's crypt. (Pierre)
 - Added realpath_cache_size() and realpath_cache_get() functions. 
(Stas)
 - Added FILTER_FLAG_STRIP_BACKTICK option to the filter extension. 
(Ilia)

I will enable xc99=all option in php 5.2 branch after 5.2.12 is 
released.
 [2009-12-16 20:12 UTC] pajoye@php.net
hi,

Thanks for the quick work :)

As long as it affects only Solaris/OpenSolaris, go ahead with the commit.

It is not necessary to backport this fix to 5.2 as the crypt addition has been done only in 5.3+.
 [2009-12-16 20:45 UTC] johannes@php.net
This is changing it globally, no? - Might this have negative effects (I don't know if C99 breaks C89 code in anyway, while in general I'd like to move to C99 due to the types and some other stuff it offers)

And might we have trouble with other non-gcc platforms?
 [2009-12-16 20:49 UTC] svn@php.net
Automatic comment from SVN on behalf of srinatar
Revision: http://svn.php.net/viewvc/?view=revision&revision=292222
Log: - Fixed bug #50496 (Use of <stdbool.h> is valid only in a c99 compilation environment.)
 [2009-12-16 20:50 UTC] srinatar@php.net
[ see also bug #50497 ] 

thanks for taking time to report this issue. the fix for this issue is 
now integrated. mean while, your suggested work around (export CFLAGS=-
xc99=all) should be acceptable. 

- Sriram


 [2009-12-16 21:10 UTC] pajoye@php.net
Pls don't open another bug for the exact same problem.

If the header is only available in c99 and c99 can have bad side effects, why not define manually on Solaris what is necessary for the code to work and be done with this problem?
 [2009-12-16 21:33 UTC] svn@php.net
Automatic comment from SVN on behalf of srinatar
Revision: http://svn.php.net/viewvc/?view=revision&revision=292223
Log: - Fix NEWS for bug #50496
# Update NEWS to keep resolved bugs in decreasing order (Christopher Jones)
 [2009-12-16 22:48 UTC] srinatar@php.net
on other platforms like HP-UX and AIX as well as gcc, these types (bool, 
true,false) are defined by simply including the header file. these 
platforms do not require c99 standard to be defined as pre-requisite to 
define these macros. 

at this moment, this seems to be solaris sun studio compiler only issue. 

 [2009-12-17 05:37 UTC] alexander at skwar dot name
N?, it is not a Sun Studio Compiler issue - if you compile using gcc 
3.4.3 from /usr/sfw/bin, you will run into the same problems. At 
least on Solaris 10.
 [2010-01-11 15:06 UTC] dsp@php.net
The problem is not gcc but libc. If the libc is strict with what the ISO 
standard defines you cannot use c99 headers in non c99 code. So we have 
to either add c99/_STD_C99 globally or get rid of the c99 code. You can 
compile it with gcc and SUN libc and you will get the same error. GNU 
libc seems not to make this difference, which is why it works.
 [2010-01-11 15:41 UTC] johannes@php.net
Reopening - seems to still be broken.
 [2010-01-11 16:02 UTC] dsp@php.net
Opening again the bug as it's not fixed yet.
 [2010-01-11 16:22 UTC] svn@php.net
Automatic comment from SVN on behalf of dsp
Revision: http://svn.php.net/viewvc/?view=revision&revision=293409
Log: Fixes #50496. Drop stdbool.h dependency as it requires _STDC_C99 set on some systems.
 [2010-02-11 17:53 UTC] svn@php.net
Automatic comment from SVN on behalf of johannes
Revision: http://svn.php.net/viewvc/?view=revision&revision=294894
Log: merge r293409: Fixes #50496. Drop stdbool.h dependency as it requires _STDC_C99
set on some systems. (dsp)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC