|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-02-05 08:07 UTC] 191919 at gmail dot com
Description:
------------
On my OS X Yosemite 10.10.2, gcc-4.9.2 failed to compile zend.c.
$ uname -a
Darwin localhost 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
$ /opt/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/opt/bin/gcc
COLLECT_LTO_WRAPPER=/opt/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../gcc-4.9.2/configure --prefix=/opt --enable-languages=c,c++,objc,obj-c++
Thread model: posix
$ CC=/opt/bin/gcc CFLAGS="-O3 -mssse3 -ftree-vectorize -funroll-loops -fomit-frame-pointer -fno-stack-protector -fno-exceptions" ./configure --prefix=/opt/php7
$ make
... (a lot of lines omitted) ...
/bin/sh /Users/xx/box/php-src/libtool --silent --preserve-dup-deps --mode=install cp ext/opcache/opcache.la /Users/xx/box/php-src/modules
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /Users/xx/box/php-src/modules/opcache.a(shared_alloc_shm.o) has no symbols
/bin/sh /Users/xx/box/php-src/libtool --silent --preserve-dup-deps --mode=compile /opt/bin/gcc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -IZend/ -I/Users/xx/box/php-src/Zend/ -DPHP_ATOM_INC -I/Users/xx/box/php-src/include -I/Users/xx/box/php-src/main -I/Users/xx/box/php-src -I/Users/xx/box/php-src/ext/date/lib -I/Users/xx/box/php-src/ext/ereg/regex -I/usr/local/include/libxml2 -I/Users/xx/box/php-src/ext/sqlite3/libsqlite -I/Users/xx/box/php-src/TSRM -I/Users/xx/box/php-src/Zend -I/usr/include -O3 -mssse3 -ftree-vectorize -funroll-loops -ffast-math -fomit-frame-pointer -fno-stack-protector -fno-exceptions -fvisibility=hidden -c /Users/xx/box/php-src/Zend/zend.c -o Zend/zend.lo
In file included from /Users/xx/box/php-src/Zend/zend.c:22:0:
/Users/xx/box/php-src/Zend/zend.h:86:30: error: redefinition of 'zend_error'
# define zend_error_noreturn zend_error
^
/Users/xx/box/php-src/Zend/zend.c:1214:29: note: in expansion of macro 'zend_error_noreturn'
ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...)
^
/Users/xx/box/php-src/Zend/zend.c:1205:15: note: previous definition of 'zend_error' was here
ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
^
make: *** [Zend/zend.lo] Error 1
I checked the problem lines in zend.c:
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__))
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
#elif defined(ZEND_WIN32) || defined(DARWIN)
ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
{
va_list va;
va_start(va, format);
zend_error_va_list(type, format, va);
va_end(va);
}
ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...)
{
va_list va;
va_start(va, format);
zend_error_va_list(type, format, va);
va_end(va);
}
/* }}} */
#endif
As defined in zend.h:
#ifdef HAVE_NORETURN
# if defined(ZEND_WIN32)
ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...);
# else
void zend_error_noreturn(int type, const char *format, ...) ZEND_NORETURN;
# endif
#else
# define zend_error_noreturn zend_error
#endif
`zend_error_noreturn` is defined as `zend_error`, so
ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...)
is expanded to
ZEND_API ZEND_NORETURN void zend_error(int type, const char *format, ...)
which is already defined.
Expected result:
----------------
Compilation succeeds.
Actual result:
--------------
Compilation failed.
Patchesbug68987.patch (last revision 2015-02-06 09:41 UTC by laruence@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 05:00:01 2025 UTC |
Perhaps because in OS X, the default compiler is clang or clang-gcc. In this case, gcc-4.9.2 is from my own compilation (you can see the ./configure statement in the original post). In zend_portability.h: #if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn) # define HAVE_NORETURN # define ZEND_NORETURN __attribute__((noreturn)) #elif defined(ZEND_WIN32) # define HAVE_NORETURN # define ZEND_NORETURN __declspec(noreturn) #else # define ZEND_NORETURN #endif 1. In OS X (with DARWIN defined) with clang which has __has_attribute(noreturn)'s value is true, HAVE_NORETURN is defined. 2. In OS X with gcc which does not have __has_attribute, HAVE_NORETURN is not defined. zend.h includes zend_portability.h, and in zend.h: #ifdef HAVE_NORETURN # if defined(ZEND_WIN32) ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...); # else void zend_error_noreturn(int type, const char *format, ...) ZEND_NORETURN; # endif #else # define zend_error_noreturn zend_error #endif So we have zend_error_noreturn defined as zend_error. Finally in zend.c: #if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn)); #elif defined(ZEND_WIN32) || defined(DARWIN) ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */ { va_list va; va_start(va, format); zend_error_va_list(type, format, va); va_end(va); } ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) { va_list va; va_start(va, format); zend_error_va_list(type, format, va); va_end(va); } /* }}} */ #endif Because zend_error_noreturn has been defined to zend_error, there *IS* the duplicated definition.