[PHP-DEV] Patch: PHP (cvs) on Itanium From: Steve Robb (steve <email protected>)
Date: 07/19/00

Hi there,

I've been playing with php4, and partly php3 (both recently checked out
from CVS), on an Itanium IA-64 system running a recent beta of Red Hat
Linux.

Unfortunately, there are two problems with php4, one of which is common
to php3. The two attached files are patches for php3 and php4. Without
the patches, the checks for the various crypt() functions in the
configure script fail with a segmentation fault. The compiler (gcc
2.9-ia64-000216-final) isn't happy about casting an int (4 bytes) to a
pointer with a different size (8 bytes), so ensuring the correct
prototype is used solves the problem.

After this patch, php3 configures, builds and installs as an Apache DSO
module. I haven't given it much in the way of testing beyond compilation
and installation, however.

php4 is slightly more complex. After running './configure
--with-apxs=..../bin/apxs' the rest is pretty much plain sailing until
the build process reaches Zend/zend_execute_API.c. At this point, the
compiler seems to "hang" on the file with the RSS of cc1, reported by
top, hovering around 11MB. The command line is fairly trivial:

/bin/sh ../libtool --silent --mode=compile gcc -DHAVE_CONFIG_H
-I. -I. -I.. -DXML_BYTE_ORDER=12 -g -O2 -c zend_execute_API.c

Having seen similar effects on other systems (not necessarily php or its
components), reducing the optimisation level to -O0 can sometimes help.
However, this only causes the RSS to drop back to around 8-9MB and has
little effect otherwise. After some investigation, I managed to narrow
the problem down to just two lines in the function, init_executor:

        INIT_ZVAL(EG(uninitialized_zval));
        INIT_ZVAL(EG(error_zval));

When these macros are expanded, the code looks fairly unremarkable as
far as C goes, but the compiler is trying to do something clever with it
and rapidly getting nowhere.

Adding a level of unnecessary indirection to complicate the code enables
cc1 to successfully compile the file, and the remainder of process goes
smoothly. Although I wouldn't like to see this change applied to the
Zend code (the problem clearly doesn't lie with the Zend Engine), I'm
including the hack below in case it is of any interest to people.

Cheers,
Steve

Index: zend_execute_API.c
===================================================================
RCS file: /repository/Zend/zend_execute_API.c,v
retrieving revision 1.103
diff -u -r1.103 zend_execute_API.c
--- zend_execute_API.c 2000/07/03 16:53:39 1.103
+++ zend_execute_API.c 2000/07/14 14:39:41
@@ -105,8 +105,17 @@
 
 void init_executor(CLS_D ELS_DC)
 {
+#if 0
         INIT_ZVAL(EG(uninitialized_zval));
         INIT_ZVAL(EG(error_zval));
+#else
+ zval *uzval = &executor_globals.uninitialized_zval;
+ zval *ezval = &executor_globals.error_zval;
+
+ *uzval = zval_used_for_init;
+ *ezval = zval_used_for_init;
+#endif
+
         EG(uninitialized_zval_ptr)=&EG(uninitialized_zval);
         EG(error_zval_ptr)=&EG(error_zval);
         zend_ptr_stack_init(&EG(arg_types_stack));

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>