#48318 [NEW]: CLI doesn't build and embed SAPI doesn't load on OS X 10.5.6

From: Date: Mon, 18 May 2009 18:34:43 +0000
Subject: #48318 [NEW]: CLI doesn't build and embed SAPI doesn't load on OS X 10.5.6
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137453@lists.php.net to get a copy of this message
From: valeriy dot zamarayev at gmail dot com Operating system: OS X 10.5.6 PHP version: 5.3CVS-2009-05-18 (CVS) PHP Bug Type: *Compile Issues Bug description: CLI doesn't build and embed SAPI doesn't load on OS X 10.5.6 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)" ;; -- Edit bug report at http://bugs.php.net/?id=48318&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48318&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48318&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48318&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48318&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48318&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48318&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48318&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48318&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48318&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48318&r=support Expected behavior: http://bugs.php.net/fix.php?id=48318&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48318&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48318&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48318&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48318&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48318&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48318&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48318&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48318&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48318&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48318&r=mysqlcfg

« previous php.bugs (#137453) next »