|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-18 18:47 UTC] jani@php.net
[2009-05-18 20:05 UTC] valeriy dot zamarayev at gmail dot com
[2010-06-08 15:40 UTC] tony2001@php.net
-Status: Open
+Status: Feedback
[2010-06-08 15:40 UTC] tony2001@php.net
[2010-06-29 14:13 UTC] alexk at commandprompt dot com
[2013-02-18 00:33 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
Description: ------------ Attempting to configure and build PHP with ./configure --enable- maintainer-ztc --enable-debug --enable-embed 1) fails to build CLI 2) the resulting libphp.so cannot be loaded in Darwin due to missing 'environ' global variable. Reproduce code: --------------- Try to build on OS X 10.5.6 using # ./buildconf # ./configure --enable-maintainer-ztc --enable-debug --enable-embed # make Expected result: ---------------- The CLI binary is built successfully. The libphp5.so library can be loaded using dlopen(). Actual result: -------------- At the library link stage, multiple symbols are in conflict which have to be declared 'extern' in their '*.h' files. Unlike ELF, with Darwin's Mach-O format, common symbols are not allowed by default. So ELF is forgiving but Mach-O is not with regard to missing 'extern' specifier on global variables. This happens in multiple places in PHP code. At the CLI link stage, an attempt is made to link .o files using CC, though during the compilation libtool is used, so the .o files are hidden in .libs subdirectires, and .lo files should be used. If I correct this and do link successfully, the resulting CLI is fine, but the libphp5.so cannot be loaded on darwin because the symbol environ doesn't exist. (There is a function _NSGetEnviron() which returns it). See the patch below for more details: Index: configure.in =================================================================== RCS file: /repository/php-src/configure.in,v retrieving revision 1.579.2.52.2.77.2.51 diff -u -u -r1.579.2.52.2.77.2.51 configure.in --- configure.in 6 May 2009 18:57:45 -0000 1.579.2.52.2.77.2.51 +++ configure.in 18 May 2009 18:21:14 -0000 @@ -464,7 +464,8 @@ sys/utsname.h \ sys/ipc.h \ dlfcn.h \ -assert.h +assert.h \ +crt_externs.h ],[],[],[ #ifdef HAVE_SYS_PARAM_H #include <sys/param.h> Index: ext/spl/spl_dllist.h =================================================================== RCS file: /repository/php-src/ext/spl/spl_dllist.h,v retrieving revision 1.1.2.4 diff -u -u -r1.1.2.4 spl_dllist.h --- ext/spl/spl_dllist.h 31 Dec 2008 11:15:43 -0000 1.1.2.4 +++ ext/spl/spl_dllist.h 18 May 2009 18:21:15 -0000 @@ -24,9 +24,9 @@ #include "php.h" #include "php_spl.h" -PHPAPI zend_class_entry *spl_ce_SplDoublyLinkedList; -PHPAPI zend_class_entry *spl_ce_SplQueue; -PHPAPI zend_class_entry *spl_ce_SplStack; +extern PHPAPI zend_class_entry *spl_ce_SplDoublyLinkedList; +extern PHPAPI zend_class_entry *spl_ce_SplQueue; +extern PHPAPI zend_class_entry *spl_ce_SplStack; PHP_MINIT_FUNCTION(spl_dllist); Index: ext/spl/spl_fixedarray.h =================================================================== RCS file: /repository/php-src/ext/spl/spl_fixedarray.h,v retrieving revision 1.1.2.3 diff -u -u -r1.1.2.3 spl_fixedarray.h --- ext/spl/spl_fixedarray.h 31 Dec 2008 11:15:43 -0000 1.1.2.3 +++ ext/spl/spl_fixedarray.h 18 May 2009 18:21:15 -0000 @@ -22,7 +22,7 @@ #ifndef SPL_FIXEDARRAY_H #define SPL_FIXEDARRAY_H -PHPAPI zend_class_entry *spl_ce_SplFixedArray; +extern PHPAPI zend_class_entry *spl_ce_SplFixedArray; PHP_MINIT_FUNCTION(spl_fixedarray); Index: ext/spl/spl_heap.h =================================================================== RCS file: /repository/php-src/ext/spl/spl_heap.h,v retrieving revision 1.1.2.3 diff -u -u -r1.1.2.3 spl_heap.h --- ext/spl/spl_heap.h 31 Dec 2008 11:15:44 -0000 1.1.2.3 +++ ext/spl/spl_heap.h 18 May 2009 18:21:15 -0000 @@ -24,11 +24,11 @@ #include "php.h" #include "php_spl.h" -PHPAPI zend_class_entry *spl_ce_SplHeap; -PHPAPI zend_class_entry *spl_ce_SplMinHeap; -PHPAPI zend_class_entry *spl_ce_SplMaxHeap; +extern PHPAPI zend_class_entry *spl_ce_SplHeap; +extern PHPAPI zend_class_entry *spl_ce_SplMinHeap; +extern PHPAPI zend_class_entry *spl_ce_SplMaxHeap; -PHPAPI zend_class_entry *spl_ce_SplPriorityQueue; +extern PHPAPI zend_class_entry *spl_ce_SplPriorityQueue; PHP_MINIT_FUNCTION(spl_heap); Index: main/php.h =================================================================== RCS file: /repository/php-src/main/php.h,v retrieving revision 1.221.2.4.2.8.2.12 diff -u -u -r1.221.2.4.2.8.2.12 php.h --- main/php.h 31 Dec 2008 11:15:47 -0000 1.221.2.4.2.8.2.12 +++ main/php.h 18 May 2009 18:21:16 -0000 @@ -263,7 +263,13 @@ #if !defined(PHP_WIN32) #define PHP_SLEEP_NON_VOID #define php_sleep sleep + +#if HAVE_CRT_EXTERNS_H +#include <crt_externs.h> +#define environ (*_NSGetEnviron()) +#else extern char **environ; +#endif #endif /* !defined(PHP_WIN32) */ #ifdef PHP_PWRITE_64 Index: main/php_getopt.h =================================================================== RCS file: /repository/php-src/main/php_getopt.h,v retrieving revision 1.1.2.4 diff -u -u -r1.1.2.4 php_getopt.h --- main/php_getopt.h 31 Dec 2008 11:15:47 -0000 1.1.2.4 +++ main/php_getopt.h 18 May 2009 18:21:16 -0000 @@ -41,7 +41,7 @@ BEGIN_EXTERN_C() /* holds the index of the latest fetched element from the opts array */ -PHPAPI int php_optidx; +extern PHPAPI int php_optidx; PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start); END_EXTERN_C() Index: sapi/cli/config.m4 =================================================================== RCS file: /repository/php-src/sapi/cli/config.m4,v retrieving revision 1.22.2.1.2.1.2.1 diff -u -u -r1.22.2.1.2.1.2.1 config.m4 --- sapi/cli/config.m4 1 Sep 2008 13:15:31 -0000 1.22.2.1.2.1.2.1 +++ sapi/cli/config.m4 18 May 2009 18:21:16 -0000 @@ -20,9 +20,6 @@ BUILD_CLI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) | sed 's/\([A-Za-z0- 9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) - export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" fi ;; - *darwin*) - BUILD_CLI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_CLI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" - ;; *netware*) BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -Lnetware -lphp5lib -o \$(SAPI_CLI_PATH)" ;;