Bug #66017 [Opn->Fbk]: Linking fails when trying to use atomic_add_int and membar_producer
Edit report at https://bugs.php.net/bug.php?id=66017&edit=1
ID: 66017
Updated by: felipe@php.net
Reported by: Pete_Wall at symantec dot com
Summary: Linking fails when trying to use atomic_add_int and
membar_producer
-Status: Open
+Status: Feedback
Type: Bug
-Package: *Encryption and hash functions
+Package: Compile Failure
Operating System: Solaris 10 SPARC
PHP Version: 5.4.21
Block user comment: N
Private report: N
New Comment:
Please, provide a patch in an unified format. (diff -uwp)
Previous Comments:
------------------------------------------------------------------------
[2013-11-01 21:46:20] Pete_Wall at symantec dot com
Description:
------------
I'm trying to build PHP 5.4.21 on my Solaris 10 SPARC box, but it's failing when it tries
to link in atomic_add_int and membar_producer. Both of those functions are used in
ext/standard/php_crypt_r.c:
80 void _crypt_extended_init_r(void)
81 {
82 #ifdef PHP_WIN32
83 LONG volatile initialized = 0;
84 #elif defined(HAVE_ATOMIC_H) /* Solaris 10 defines atomic API within */
85 volatile unsigned int initialized = 0;
86 #else
87 static volatile sig_atomic_t initialized = 0;
88 #endif
89
90 #ifdef ZTS
91 tsrm_mutex_lock(php_crypt_extended_init_lock);
92 #endif
93
94 if (!initialized) {
95 #ifdef PHP_WIN32
96 InterlockedIncrement(&initialized);
97 #elif defined(HAVE_SYNC_FETCH_AND_ADD)
98 __sync_fetch_and_add(&initialized, 1);
99 #elif defined(HAVE_ATOMIC_H) /* Solaris 10 defines atomic API within */
100 membar_producer();
101 atomic_add_int(&initialized, 1);
102 #endif
103 _crypt_extended_init();
104 }
105 #ifdef ZTS
106 tsrm_mutex_unlock(php_crypt_extended_init_lock);
107 #endif
108 }
On my version of glibc, atomic_add_int() and membar_producer aren't defined.
$ nm -g /lib/libc.so.1 | grep atomic_add_int
$ nm -g /lib/libc.so.1 | grep membar_producer
Compiler and configuration info:
CFLAGS=""
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
$ 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
$ uname -a
SunOS grampa 5.10 Generic sun4u sparc SUNW,Sun-Fire-V210
Snippet from configure output:
checking atomic.h usability... yes
checking atomic.h presence... yes
checking for atomic.h... yes
Expected result:
----------------
Successful linking
Actual result:
--------------
Undefined first referenced
symbol in file
atomic_add_int ext/standard/.libs/php_crypt_r.o
membar_producer ext/standard/.libs/php_crypt_r.o
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66017&edit=1
Thread (4 messages)