How to install pecl-apd with PHP 5.5 on FreeBSD
October 2014.
This was written on 2014-10-05.
Fetch source (revision was 297236 at the time).
# svn co http://svn.php.net/repository/pecl/apd/trunk
Apply the following patch:
diff --git a/php_apd.c b/php_apd.c
index 9d7f238..3b1fe7e 100644
--- a/php_apd.c
+++ b/php_apd.c
@@ -56,11 +56,19 @@
#undef TRACE_ZEND_COMPILE /* define to trace all calls to zend_compile_file */
ZEND_DLEXPORT zend_op_array* apd_compile_file(zend_file_handle* TSRMLS_DC);
ZEND_DLEXPORT zend_op_array* (*old_compile_file)(zend_file_handle* TSRMLS_DC);
+#if PHP_VERSION_ID < 50500
ZEND_DLEXPORT void apd_execute(zend_op_array *op_array TSRMLS_DC);
#if ZEND_EXTENSION_API_NO >= 20020731
ZEND_DLEXPORT void apd_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
#endif
ZEND_DLEXPORT void (*old_execute)(zend_op_array *op_array TSRMLS_DC);
+#else
+ZEND_DLEXPORT void apd_execute_ex(zend_execute_data *execute_data TSRMLS_DC);
+#if ZEND_EXTENSION_API_NO >= 20020731
+ZEND_DLEXPORT void apd_execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
+#endif
+ZEND_DLEXPORT void (*old_execute_ex)(zend_execute_data *execute_data TSRMLS_DC);
+#endif
ZEND_DLEXPORT void onStatement(zend_op_array *op_array);
ZEND_DECLARE_MODULE_GLOBALS(apd);
@@ -337,7 +345,7 @@ char *apd_get_active_function_name(zend_op_array *op_array TSRMLS_DC)
}
}
else {
- switch (execd->opline->op2.u.constant.value.lval) {
+ switch (execd->opline->extended_value) {
case ZEND_EVAL:
funcname = estrdup("eval");
break;
@@ -441,8 +449,8 @@ static void log_time(TSRMLS_D)
if(utime || stime || rtime) {
int lineno = 0;
if(EG(active_op_array)) {
- if(EG(active_op_array)->start_op) {
- lineno = EG(active_op_array)->start_op->lineno;
+ if(EG(start_op)) {
+ lineno = EG(start_op)->lineno;
} else if(EG(active_op_array)->opcodes) {
lineno = EG(active_op_array)->opcodes->lineno;
}
@@ -510,28 +518,46 @@ PHP_MINIT_FUNCTION(apd)
{
ZEND_INIT_MODULE_GLOBALS(apd, php_apd_init_globals, NULL)
REGISTER_INI_ENTRIES();
+
+#if PHP_VERSION_ID < 50500
old_execute = zend_execute;
zend_execute = apd_execute;
+#else
+ old_execute_ex = zend_execute_ex;
+ zend_execute_ex = apd_execute_ex;
+#endif
+
zend_execute_internal = apd_execute_internal;
return SUCCESS;
}
-
-ZEND_API void apd_execute(zend_op_array *op_array TSRMLS_DC)
-{
+#if PHP_VERSION_ID < 50500
+ZEND_DLEXPORT void apd_execute (zend_op_array *op_array TSRMLS_DC) {
+#else
+ZEND_DLEXPORT void apd_execute_ex (zend_execute_data *execute_data TSRMLS_DC) {
+ zend_op_array *op_array = execute_data->op_array;
+#endif
char *fname = NULL;
fname = apd_get_active_function_name(op_array TSRMLS_CC);
trace_function_entry(EG(function_table), fname, ZEND_USER_FUNCTION,
zend_get_executed_filename(TSRMLS_C),
EG(in_execution)?zend_get_executed_lineno(TSRMLS_C):0);
- old_execute(op_array TSRMLS_CC);
+#if PHP_VERSION_ID < 50500
+ old_execute(op_array TSRMLS_CC);
+#else
+ old_execute_ex(execute_data TSRMLS_CC);
+#endif
trace_function_exit(fname);
efree(fname);
apd_interactive();
}
+#if PHP_VERSION_ID < 50500
ZEND_API void apd_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC)
+#else
+ZEND_API void apd_execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC)
+#endif
{
char *fname = NULL;
zend_execute_data *execd;
@@ -541,7 +567,11 @@ ZEND_API void apd_execute_internal(zend_execute_data *execute_data_ptr, int retu
trace_function_entry(EG(function_table), fname, ZEND_INTERNAL_FUNCTION,
zend_get_executed_filename(TSRMLS_C),
EG(in_execution)?zend_get_executed_lineno(TSRMLS_C):0);
- execute_internal(execute_data_ptr, return_value_used TSRMLS_CC);
+#if PHP_VERSION_ID < 50500
+ execute_internal(execute_data_ptr, return_value_used TSRMLS_CC);
+#else
+ execute_internal(execute_data_ptr, fci, return_value_used TSRMLS_CC);
+#endif
trace_function_exit(fname);
efree(fname);
apd_interactive();
If you don't, you'll have the following error output:
cc -I. -I/root/apdgit/apd2/trunk -DPHP_ATOM_INC -I/root/apdgit/apd2/trunk/include -I/root/apdgit/apd2/trunk/main -I/root/apdgit/apd2/trunk -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/apdgit/apd2/trunk/php_apd.c -fPIC -DPIC -o .libs/php_apd.o
/root/apdgit/apd2/trunk/php_apd.c:206:36: warning: format string is not a string literal (potentially insecure)
[-Wformat-security]
fprintf(APD_GLOBALS(pprof_file), newStr);
^~~~~~
/root/apdgit/apd2/trunk/php_apd.c:318:12: warning: assigning to 'char *' from 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
tmpfname = execd->function_state.function->common.function_name;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/apdgit/apd2/trunk/php_apd.c:322:15: warning: assigning to 'char *' from 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
classname = Z_OBJCE(*execd->object)->name;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/apdgit/apd2/trunk/php_apd.c:329:15: warning: assigning to 'char *' from 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
classname = execd->function_state.function->common.scope->name;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/apdgit/apd2/trunk/php_apd.c:340:31: error: no member named 'u' in 'union _znode_op'
switch (execd->opline->op2.u.constant.value.lval) {
~~~~~~~~~~~~~~~~~~ ^
/root/apdgit/apd2/trunk/php_apd.c:444:29: error: no member named 'start_op' in 'struct _zend_op_array'
if(EG(active_op_array)->start_op) {
~~~~~~~~~~~~~~~~~~~ ^
/root/apdgit/apd2/trunk/php_apd.c:445:36: error: no member named 'start_op' in 'struct _zend_op_array'
lineno = EG(active_op_array)->start_op->lineno;
~~~~~~~~~~~~~~~~~~~ ^
/root/apdgit/apd2/trunk/php_apd.c:506:35: warning: 'memset' call operates on objects of type 'zend_apd_globals'
(aka 'struct _zend_apd_globals') while the size is based on a different type 'zend_apd_globals *'
(aka 'struct _zend_apd_globals *') [-Wsizeof-pointer-memaccess]
memset(apd_globals, 0, sizeof(apd_globals));
~~~~~~~~~~~ ^~~~~~~~~~~
/root/apdgit/apd2/trunk/php_apd.c:506:35: note: did you mean to dereference the argument to 'sizeof' (and multiply it
by the number of elements)?
memset(apd_globals, 0, sizeof(apd_globals));
^~~~~~~~~~~
/root/apdgit/apd2/trunk/php_apd.c:514:15: error: non-object type 'void (zend_op_array *)' is not assignable
zend_execute = apd_execute;
~~~~~~~~~~~~ ^
/root/apdgit/apd2/trunk/php_apd.c:515:24: warning: incompatible pointer types assigning to 'void
(*)(zend_execute_data *, struct _zend_fcall_info *, int)' from 'void (zend_execute_data *, int)'
[-Wincompatible-pointer-types]
zend_execute_internal = apd_execute_internal;
^ ~~~~~~~~~~~~~~~~~~~~
/root/apdgit/apd2/trunk/php_apd.c:544:64: error: too few arguments to function call, expected 3, have 2
execute_internal(execute_data_ptr, return_value_used TSRMLS_CC);
~~~~~~~~~~~~~~~~ ^
/usr/local/include/php/Zend/zend_execute.h:62:1: note: 'execute_internal' declared here
ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_...
^
/usr/local/include/php/main/../main/php_config.h:6:19: note: expanded from macro 'ZEND_API'
# define ZEND_API __attribute__ ((visibility("default")))
^
/root/apdgit/apd2/trunk/php_apd.c:724:11: warning: assigning to 'char *' from 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
filename = zend_get_executed_filename(TSRMLS_C);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 warnings and 5 errors generated.
*** Error code 1
Configure and build:
# phpize
# ./configure
# make
Install:
# make install
Load:
zend_extension = "/usr/local/lib/php/20121212/apd.so"
apd.dumpdir="/var/tmp/apd"
Check:
# php -v
PHP 5.5.13 (cli) (built: Jun 11 2014 11:54:41)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
with Advanced PHP Debugger (APD) v1.0.2-dev, , by George Schlossnagle
You'll find patched version of the project here:
Github: ZeWaren/pecl-apd (https://github.com/ZeWaren/pecl-apd).