php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51183 ext/date/php_date.c fails to compile with Sun Studio and PHP 5.2.13
Submitted: 2010-03-02 13:25 UTC Modified: 2010-12-20 12:52 UTC
Votes:6
Avg. Score:4.5 ± 0.8
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:4 (66.7%)
From: markus dot schiegl at lbbw dot de Assigned: srinatar (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.13 OS: Solaris 10 (Sparc)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: markus dot schiegl at lbbw dot de
New email:
PHP Version: OS:

 

 [2010-03-02 13:25 UTC] markus dot schiegl at lbbw dot de
Description:
------------
PHP 5.2.13 doesn't compile with Sun Studio compiler on Solaris 10 Sparc. Configure works fine (as in 5.2.12), Make fails on ext/date/php_date.c file with:

/bin/sh /opt/build/php/php-5.2.13/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/date/lib -Iext/date/ -I/opt/build/php/php-5.2.13/ext/d
ate/ -DPHP_ATOM_INC -I/opt/build/php/php-5.2.13/include -I/opt/build/php/php-5.2.13/main -I/opt/build/php/php-5.2.13 -I/opt/build/php/php-5.2.13/ext/
date/lib -I/opt/build/php/ext/libxml2/include/libxml2 -I/usr/sfw/include -I/opt/build/php/ext/curl/include -I/opt/build/php/ext/jpeg/include -I/opt/b
uild/php/ext/freetype2/include -I/opt/build/php/ext/freetype2/include/freetype2 -I/opt/build/php/ext/gettext/include -I/opt/build/php/ext/libiconv/in
clude -I/opt/build/php/php-5.2.13/ext/mbstring/oniguruma -I/opt/build/php/php-5.2.13/ext/mbstring/libmbfl -I/opt/build/php/php-5.2.13/ext/mbstring/li
bmbfl/mbfl -I/opt/build/php/ext/libmcrypt/include -I/opt/build/php/ext/freetds/include -I/opt/build/php/ext/mysql/include -I/opt/build/php/ext/instan
tclient/sdk/include -I/opt/build/php/ext/tidy/include -I/opt/build/php/ext/xmlrpc-epi/include -I/opt/build/php/ext/libxslt/include -I/opt/build/php/p
hp-5.2.13/TSRM -I/opt/build/php/php-5.2.13/Zend  -I/opt/build/php/php/ext/libiconv/include -I/opt/build/php/php/ext/gettext/include -D_POSIX_PTHREAD_
SEMANTICS  -I/opt/build/php/ext/libiconv/include -O -xs -xstrconst -zlazyload -xmemalign=8s  -c /opt/build/php/php-5.2.13/ext/date/php_date.c -o ext/
date/php_date.lo
"/opt/build/php/php-5.2.13/ext/date/php_date.c", line 38: warning: no explicit type given
"/opt/build/php/php-5.2.13/ext/date/php_date.c", line 38: syntax error before or at: long
cc: acomp failed for /opt/build/php/php-5.2.13/ext/date/php_date.c
*** Error code 1
make: Fatal error: Command failed for target `ext/date/php_date.lo'

A diff between 5.2.12 and 5.2.13 shows the culprit (php_date_llabs vs. llabs and/or ifndef HAVE_LLABS, because of bug 50266 and bug 50930)

@@ -30,14 +30,12 @@
 #include "lib/timelib.h"
 #include <time.h>

-#ifndef HAVE_LLABS
-# ifdef PHP_WIN32
-static __inline __int64 llabs( __int64 i ) { return i >= 0? i: -i; }
-# elif defined(__GNUC__) && __GNUC__ < 3
-static __inline __int64_t llabs( __int64_t i ) { return i >= 0 ? i : -i; }
-# elif defined(NETWARE) && defined(__MWERKS__)
-static __inline long long llabs( long long i ) { return i >= 0 ? i : -i; }
-# endif
+#ifdef PHP_WIN32
+static __inline __int64 php_date_llabs( __int64 i ) { return i >= 0? i: -i; }
+#elif defined(__GNUC__) && __GNUC__ < 3
+static __inline __int64_t php_date_llabs( __int64_t i ) { return i >= 0 ? i : -i; }
+#else
+static __inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i; }
 #endif

 /* {{{ arginfo */


Expected result:
----------------
successful compile

Actual result:
--------------
compile aborts with error

Patches

php_date.c.patch (last revision 2010-03-10 08:59 UTC by jose-marcio dot martins at mines-paristech dot fr)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-05 11:42 UTC] markus dot schiegl at lbbw dot de
Jose Marcio, thanks for the patch. Compiles and works fine now!
 [2010-03-05 12:09 UTC] felipe@php.net
-Status: Open +Status: Assigned
 [2010-03-08 20:26 UTC] rcshishe at cord dot edu
This also affects Solaris 10 x86 with Sun Studio compiler.
 [2010-03-10 11:02 UTC] jose-marcio dot martins at mines-paristech dot fr
I submited this patch as it's simple and will work for every combination of OS and compiler.

But the result is that php_date_llabs function isn't defined as inline. This may be an important performance issue only if this function is called very very frequently (I don't know if this hypothesis is true and I don't believe).

The correct solution could be to redefine this with some other checks in order to use the correct inline declaration syntax. Another solution, as this is a really simple function is to declare it as a macro. Something of the kind :

#define php_date_llabs(i)  ((long long) ((i) >= 0 ? (i) : -(i))
 [2010-03-15 18:16 UTC] uklaus at hgb-leipzig dot de
for the records, 

Sun Studio 11 compiler on Solaris 10 Sparc: doesn't compile
Sun Studio 12 compiler on Solaris 10 Sparc: doesn't compile
Sun Studio 12 Update 1 compiler on Solaris 10 Sparc: compiles
 [2010-05-31 17:50 UTC] srinatar@php.net
with sun studio 12 update, __inline is now recognized as synonymous for inline. this patch makes this code compilable on all platforms
[sn123202@bflat]'php-5.3.2'>diff -u ext/date/php_date.c.ORIG ext/date/php_date.c--- ext/date/php_date.c.ORIG    Mon May 31 08:38:45 2010
+++ ext/date/php_date.c Mon May 31 08:33:34 2010
@@ -36,7 +36,7 @@
 #elif defined(__GNUC__) && __GNUC__ < 3
 static __inline __int64_t php_date_llabs( __int64_t i ) { return i >= 0 ? i : -i; }
 #else
-static __inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i; }
+static inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i; }
 #endif

(C99 standard does support inline keyword)

I can commit this bug, if no one has any objections to it.
 [2010-06-08 23:26 UTC] srinatar@php.net
-Status: Assigned +Status: Closed -Assigned To: derick +Assigned To: srinatar
 [2010-06-08 23:26 UTC] srinatar@php.net
Committed revision 300294.

- Tested and verified it to compile on linux, mac and solaris.
 [2010-12-20 12:52 UTC] jani@php.net
-Package: Tidy +Package: Date/time related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC