php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54895 Fix compiling with older gcc version without need for membar_producer macro
Submitted: 2011-05-20 21:46 UTC Modified: 2011-05-20 23:25 UTC
From: mhei at heimpold dot de Assigned: felipe
Status: Closed Package: Compile Failure
PHP Version: 5.3.6 OS: Linux (OpenWRT backfire)
Private report: No CVE-ID:
 [2011-05-20 21:46 UTC] mhei at heimpold dot de
Description:
------------
When compiling the latest php version 5.3.6 with OpenWRT backfire branch, the build fails:
-snip-
ext/standard/php_crypt_r.o: In function `_crypt_extended_init_r':
php_crypt_r.c:(.text+0x4c1): undefined reference to `membar_producer'
php_crypt_r.c:(.text+0x4cf): undefined reference to `atomic_add_int'
collect2: ld returned 1 exit status
make[3]: *** [sapi/cli/php] Error 1
-snap-

When looking into the source file I'm wondering whether the second code path with __sync_fetch_and_add could not be used.

-snip-
#ifdef PHP_WIN32
                InterlockedIncrement(&initialized);
#elif (defined(__GNUC__) && (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2))
                __sync_fetch_and_add(&initialized, 1);
#elif defined(HAVE_ATOMIC_H) /* Solaris 10 defines atomic API within */
                membar_producer();
                atomic_add_int(&initialized, 1);
#endif
-snap-

As gcc compiler version 4.1.2 has support for this function (see http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html) I suggest the attached patch to lower the GNUC_MINOR test.

Expected result:
----------------
The build completes as the gcc provided function is used.


Patches

prevent_membar_producer_gcc.4.1.2.patch (last revision 2011-05-20 19:47 UTC) by mhei at heimpold dot de)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-20 21:48 UTC] mhei at heimpold dot de
Forgot to mention that I actually tested it already: the compilation succeeded.
 [2011-05-20 23:24 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=311300
Log: - Fixed bug #54895 (Fix compiling with older gcc version without need for membar_producer macro)
  patch by: mhei at heimpold dot de
 [2011-05-20 23:25 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2011-05-20 23:25 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks for the patch!
 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ac6edb41ecb219fa399b9295b457de5c9833b7be
Log: - Fixed bug #54895 (Fix compiling with older gcc version without need for membar_producer macro)   patch by: mhei at heimpold dot de
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ac6edb41ecb219fa399b9295b457de5c9833b7be
Log: - Fixed bug #54895 (Fix compiling with older gcc version without need for membar_producer macro)   patch by: mhei at heimpold dot de
 [2013-11-17 09:38 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ac6edb41ecb219fa399b9295b457de5c9833b7be
Log: - Fixed bug #54895 (Fix compiling with older gcc version without need for membar_producer macro)   patch by: mhei at heimpold dot de
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 09:02:29 2014 UTC