From 39aaa971abf8172118bc83ea8a243e11e95f17a9 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 19 Jun 2012 15:05:54 -0600 Subject: [PATCH 01/12] Add use of php-config to determine paths, add DEFINES to be able to set path dynamically during compile --- config.h.in | 6 ++++ configure.ac | 21 +++++------ m4/php-embed.m4 | 73 +++++++++++++++++++++++++++++---------- src/codegen/Compile_C.cpp | 15 +++++--- 4 files changed, 81 insertions(+), 34 deletions(-) diff --git a/config.h.in b/config.h.in index 61afee4db..fa35af919 100644 --- a/config.h.in +++ b/config.h.in @@ -35,3 +35,9 @@ // PHP installation path #undef PHP_INSTALL_PATH + +// PHP installation path +#undef PHP_INCLUDE_PATH + +// PHP embed lib path +#undef PHP_EMBED_PATH diff --git a/configure.ac b/configure.ac index 99af9f58a..5b2602ce1 100644 --- a/configure.ac +++ b/configure.ac @@ -46,18 +46,6 @@ AC_ARG_WITH([maketea], [AC_PATH_PROG([maketea], [maketea], [config/phc_missing maketea])] ) -# check PHP path -AC_ARG_WITH([php], - AS_HELP_STRING([--with-php=PATH], [PHP installation path (defaults to /usr/local)]), - [ - AS_IF([test "x$with_php" != xno], - [AC_CHECK_PHP([$withval])], [AS_VAR_SET([found_embed_sapi], [no])]) - ], - [ - AC_CHECK_PHP([/usr/local]) - ]) - - dnl checks for libraries AC_LANG([C++]) AC_CHECK_COVARIANCE @@ -65,6 +53,15 @@ AC_CHECK_LIB_CRUN AX_BOOST_BASE([1.35.0]) AX_BOOST_REGEX +dnl PHP +PHP_EMBED +AS_IF([test "x$PHP_INSTALL_PATH" != xno], + [AC_DEFINE([PHP_INSTALL_PATH], [$PHP_INSTALL_PATH])]) # for config.h +AS_IF([test "x$PHP_INCLUDE_PATH" != xno], + [AC_DEFINE([PHP_INCLUDE_PATH], [$PHP_INCLUDE_PATH])]) # for config.h +AS_IF([test "x$PHP_EMBED_PATH" != xno], + [AC_DEFINE([PHP_EMBED_PATH], [$PHP_EMBED_PATH])]) # for config.h + dnl Xerces AX_LIB_XERCES AC_SUBST([HAVE_XERCES], [$HAVE_XERCES]) # for autovars.php diff --git a/m4/php-embed.m4 b/m4/php-embed.m4 index 7d0891566..c3d44ba79 100644 --- a/m4/php-embed.m4 +++ b/m4/php-embed.m4 @@ -1,29 +1,69 @@ -dnl Takes a single parameter - where to look. -AC_DEFUN([AC_CHECK_PHP], [ - AC_PATH_PROG([php], [php], [], ["$1/bin"]) - # For config.h: - AC_DEFINE_UNQUOTED([PHP_INSTALL_PATH], ["$1"]) - # For autovars.php.in: - AC_SUBST([php_install_path], ["$1"]) - # For use below: - PHP_INSTALL_PATH=$1 +AC_DEFUN([PHP_EMBED], +[ + AC_ARG_WITH([php-config], + AS_HELP_STRING([--with-php-config=@<:@ARG@:>@], + [path to php-config (ARG=path)] + ), + [ + if test -f "$withval"; then + php_config="$withval" + elif test -d "$withval"; then + if test -f "$withval/php-config"; then + php_config="$withval/php-config" + fi + else + php_config="php-config" + fi + ], + [ + dnl Default behavior is implicit yes + php_config="php-config" + ] + ) + + if test -z "$php_config"; then + AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH]) + fi + + dnl For BC + PHP_CONFIG=$php_config + PHP_INSTALL_PATH=`$PHP_CONFIG --prefix 2>/dev/null` + AC_DEFINE(PHP_INSTALL_PATH, $PHP_INSTALL_PATH) + PHP_INCLUDE_PATH=`$PHP_CONFIG --include-dir 2>/dev/null` + AC_DEFINE(PHP_INCLUDE_PATH, $PHP_INCLUDE_PATH) + PHP_INCLUDES=`$PHP_CONFIG --includes 2>/dev/null` + PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null` + + for php_embed_path in ${PHP_INSTALL_PATH}/lib ${PHP_INSTALL_PATH}/lib/php ${PHP_INSTALL_PATH}/lib/php5; do + for libext in so dylib a; do + if test -f ${php_embed_path}/libphp5.${libext}; then + PHP_EMBED_PATH=${php_embed_path}; + fi + done + done + + if test -z "$PHP_EMBED_PATH"; then + AC_MSG_ERROR([Cannot find libphp5 embed.]) + fi + + AC_DEFINE(PHP_EMBED_PATH, $PHP_EMBED_PATH) dnl To check if the PHP embed SAPI has been installed, we temporarily add the dnl PHP installation path to LDFLAGS and CFLAGS, and restore it later (since dnl we do not need that path to build phc itself). AS_VAR_SET(found_embed_sapi, yes) OLD_LDFLAGS=$LDFLAGS - OLD_CFLAGS=$CFLAGS - LDFLAGS="-L${PHP_INSTALL_PATH}/lib $LDFLAGS" - CFLAGS="-isystem${PHP_INSTALL_PATH}/include/php -isystem${PHP_INSTALL_PATH}/include/php/main -isystem${PHP_INSTALL_PATH}/include/php/TSRM -isystem${PHP_INSTALL_PATH}/include/php/Zend $CFLAGS" + OLD_CPPFLAGS=$CPPFLAGS + LDFLAGS="-L${PHP_EMBED_PATH} $LDFLAGS" + CPPFLAGS="${PHP_INCLUDES} $CPPFLAGS" AC_CHECK_LIB( [php5], [zend_eval_string], [ AS_VAR_SET(found_embed_sapi, yes) AC_DEFINE(HAVE_EMBED, 1) - AC_SUBST([libphp_headers], ["-isystem${PHP_INSTALL_PATH}/include/php -isystem${PHP_INSTALL_PATH}/include/php/main -isystem${PHP_INSTALL_PATH}/include/php/TSRM -isystem${PHP_INSTALL_PATH}/include/php/Zend"]) - LIBS="-lphp5 -L${PHP_INSTALL_PATH}/lib -R${PHP_INSTALL_PATH}/lib $LIBS" + AC_SUBST([libphp_headers], ["${PHP_INCLUDES}"]) + LIBS="-lphp5 -L${PHP_EMBED_PATH} -R${PHP_EMBED_PATH} $LIBS" ], [ AS_VAR_SET(found_embed_sapi, no) @@ -36,9 +76,6 @@ AC_DEFUN([AC_CHECK_PHP], [ [AS_VAR_SET(found_embed_sapi, no)], [] ) - CFLAGS=$OLD_CFLAGS + CPPFLAGS=$OLD_CPPFLAGS LDFLAGS=$OLD_LDFLAGS ]) - - - diff --git a/src/codegen/Compile_C.cpp b/src/codegen/Compile_C.cpp index d9933b5fe..18215124a 100644 --- a/src/codegen/Compile_C.cpp +++ b/src/codegen/Compile_C.cpp @@ -47,10 +47,17 @@ void Compile_C::run (IR::PHP_script* in, Pass_manager* pm) { // Find PHP installation path const char* php_path; + const char* php_include_path; if(pm->args_info->with_php_given) php_path = pm->args_info->with_php_arg; else { + #ifdef PHP_INCLUDE_PATH + php_include_path = PHP_INCLUDE_PATH; + #else + phc_error ("PHP_INCLUDE_PATH not configured. Please use the --with-php-config flag to compile"); + assert (0); // in the case of --dont-fail, still fail here. + #endif #ifdef PHP_INSTALL_PATH php_path = PHP_INSTALL_PATH; #else @@ -63,10 +70,10 @@ void Compile_C::run (IR::PHP_script* in, Pass_manager* pm) // Argument array for gcc Vector args; new_arg (args) << "gcc"; - new_arg (args) << "-I" << php_path << "/include/php"; - new_arg (args) << "-I" << php_path << "/include/php/main"; - new_arg (args) << "-I" << php_path << "/include/php/TSRM"; - new_arg (args) << "-I" << php_path << "/include/php/Zend"; + new_arg (args) << "-I" << php_include_path"; + new_arg (args) << "-I" << php_include_path << "/main"; + new_arg (args) << "-I" << php_include_path << "/TSRM"; + new_arg (args) << "-I" << php_include_path << "/Zend"; new_arg (args) << "-L" << php_path << "/lib"; new_arg (args) << "-Wl,-R" << php_path << "/lib"; new_arg (args) << "-lphp5"; From 4c655a515a6473a144696b28c2e75e3bcbe8ab70 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 19 Jun 2012 16:32:21 -0600 Subject: [PATCH 02/12] Fix for php5.4 changes in zend_fcall_info_init --- src/embed/optimize.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/embed/optimize.cpp b/src/embed/optimize.cpp index 102c978fc..3f51aff40 100644 --- a/src/embed/optimize.cpp +++ b/src/embed/optimize.cpp @@ -218,9 +218,14 @@ PHP::get_method_info (String* name) ZVAL_STRING (&fn, const_cast (name->c_str ()), 0); + uint check_flags=0; zend_fcall_info fci; zend_fcall_info_cache fcic; - int result = zend_fcall_info_init (&fn, &fci, &fcic TSRMLS_CC); + char callable_name[124]; + char error[513]; // , void ***tsrm_ls); + char * cname = &callable_name[0]; + char * err = &error[0]; + int result = zend_fcall_info_init (&fn, check_flags, &fci, &fcic, &cname, &err TSRMLS_CC); if (result != SUCCESS) return NULL; @@ -245,7 +250,7 @@ Internal_method_info::has_implementation () bool Internal_method_info::return_by_ref () { - return func->common.return_reference; + return (func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE); } bool From 6865a035d85dcadbae43f522f4844bd8bcc3d1a9 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 19 Jun 2012 16:33:25 -0600 Subject: [PATCH 03/12] Lots Of Build Fixes for new php-config stuff --- config.h.in | 2 +- configure.ac | 6 ----- m4/php-embed.m4 | 8 +++--- src/codegen/Compile_C.cpp | 55 +++++++++++++++++++++++---------------- src/codegen/Compile_C.h | 1 + 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/config.h.in b/config.h.in index fa35af919..ce1922669 100644 --- a/config.h.in +++ b/config.h.in @@ -37,7 +37,7 @@ #undef PHP_INSTALL_PATH // PHP installation path -#undef PHP_INCLUDE_PATH +#undef PHP_INCLUDES_PATH // PHP embed lib path #undef PHP_EMBED_PATH diff --git a/configure.ac b/configure.ac index 5b2602ce1..6c74555dc 100644 --- a/configure.ac +++ b/configure.ac @@ -55,12 +55,6 @@ AX_BOOST_REGEX dnl PHP PHP_EMBED -AS_IF([test "x$PHP_INSTALL_PATH" != xno], - [AC_DEFINE([PHP_INSTALL_PATH], [$PHP_INSTALL_PATH])]) # for config.h -AS_IF([test "x$PHP_INCLUDE_PATH" != xno], - [AC_DEFINE([PHP_INCLUDE_PATH], [$PHP_INCLUDE_PATH])]) # for config.h -AS_IF([test "x$PHP_EMBED_PATH" != xno], - [AC_DEFINE([PHP_EMBED_PATH], [$PHP_EMBED_PATH])]) # for config.h dnl Xerces AX_LIB_XERCES diff --git a/m4/php-embed.m4 b/m4/php-embed.m4 index c3d44ba79..b0dda551e 100644 --- a/m4/php-embed.m4 +++ b/m4/php-embed.m4 @@ -28,9 +28,9 @@ AC_DEFUN([PHP_EMBED], dnl For BC PHP_CONFIG=$php_config PHP_INSTALL_PATH=`$PHP_CONFIG --prefix 2>/dev/null` - AC_DEFINE(PHP_INSTALL_PATH, $PHP_INSTALL_PATH) - PHP_INCLUDE_PATH=`$PHP_CONFIG --include-dir 2>/dev/null` - AC_DEFINE(PHP_INCLUDE_PATH, $PHP_INCLUDE_PATH) + AC_DEFINE_UNQUOTED(PHP_INSTALL_PATH, "${PHP_INSTALL_PATH}") + PHP_INCLUDES_PATH=`$PHP_CONFIG --include-dir 2>/dev/null` + AC_DEFINE_UNQUOTED(PHP_INCLUDES_PATH, "${PHP_INCLUDES_PATH}") PHP_INCLUDES=`$PHP_CONFIG --includes 2>/dev/null` PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null` @@ -46,7 +46,7 @@ AC_DEFUN([PHP_EMBED], AC_MSG_ERROR([Cannot find libphp5 embed.]) fi - AC_DEFINE(PHP_EMBED_PATH, $PHP_EMBED_PATH) + AC_DEFINE_UNQUOTED(PHP_EMBED_PATH, "${PHP_EMBED_PATH}") dnl To check if the PHP embed SAPI has been installed, we temporarily add the dnl PHP installation path to LDFLAGS and CFLAGS, and restore it later (since diff --git a/src/codegen/Compile_C.cpp b/src/codegen/Compile_C.cpp index 18215124a..f7d03de39 100644 --- a/src/codegen/Compile_C.cpp +++ b/src/codegen/Compile_C.cpp @@ -48,37 +48,48 @@ void Compile_C::run (IR::PHP_script* in, Pass_manager* pm) // Find PHP installation path const char* php_path; const char* php_include_path; - if(pm->args_info->with_php_given) + const char* php_embed_path; + Vector args; + new_arg (args) << "gcc"; + if(pm->args_info->with_php_given) { php_path = pm->args_info->with_php_arg; - else + + // Argument array for gcc + new_arg (args) << "-I" << php_path << "/include/php"; + new_arg (args) << "-I" << php_path << "/include/php/main"; + new_arg (args) << "-I" << php_path << "/include/php/TSRM"; + new_arg (args) << "-I" << php_path << "/include/php/Zend"; + new_arg (args) << "-L" << php_path << "/lib"; + new_arg (args) << "-Wl,-R" << php_path << "/lib"; + new_arg (args) << "-lphp5"; + new_arg (args) << "-xc"; + new_arg (args) << "-"; + } else { - #ifdef PHP_INCLUDE_PATH - php_include_path = PHP_INCLUDE_PATH; + #ifdef PHP_INCLUDES_PATH + php_include_path = PHP_INCLUDES_PATH; #else - phc_error ("PHP_INCLUDE_PATH not configured. Please use the --with-php-config flag to compile"); + phc_error ("PHP_INCLUDES_PATH not configured. Please use the --with-php-config flag to compile"); assert (0); // in the case of --dont-fail, still fail here. #endif - #ifdef PHP_INSTALL_PATH - php_path = PHP_INSTALL_PATH; + #ifdef PHP_EMBED_PATH + php_embed_path = PHP_EMBED_PATH; #else - phc_error ("PHP_INSTALL_PATH not configured. Please use the --with-php flag to compile"); + phc_error ("PHP_EMBED_PATH not configured. Please use the --with-php-config flag to compile"); assert (0); // in the case of --dont-fail, still fail here. #endif - } - - // Argument array for gcc - Vector args; - new_arg (args) << "gcc"; - new_arg (args) << "-I" << php_include_path"; - new_arg (args) << "-I" << php_include_path << "/main"; - new_arg (args) << "-I" << php_include_path << "/TSRM"; - new_arg (args) << "-I" << php_include_path << "/Zend"; - new_arg (args) << "-L" << php_path << "/lib"; - new_arg (args) << "-Wl,-R" << php_path << "/lib"; - new_arg (args) << "-lphp5"; - new_arg (args) << "-xc"; - new_arg (args) << "-"; + // Argument array for gcc + new_arg (args) << "-I" << php_include_path; + new_arg (args) << "-I" << php_include_path << "/main"; + new_arg (args) << "-I" << php_include_path << "/TSRM"; + new_arg (args) << "-I" << php_include_path << "/Zend"; + new_arg (args) << "-L" << php_embed_path; + new_arg (args) << "-Wl,-R" << php_embed_path; + new_arg (args) << "-lphp5"; + new_arg (args) << "-xc"; + new_arg (args) << "-"; + } // Add (gcc) -g and -o arguments if (strncmp (pm->args_info->optimize_arg, "0", 2) == 0) diff --git a/src/codegen/Compile_C.h b/src/codegen/Compile_C.h index cd648a349..da6fd7d80 100644 --- a/src/codegen/Compile_C.h +++ b/src/codegen/Compile_C.h @@ -8,6 +8,7 @@ #ifndef PHC_COMPILE_C #define PHC_COMPILE_C +#include "config.h" #include "pass_manager/Pass.h" class Compile_C : public Pass From 209dfd699df1b3bf34dc9af5cc1adc6b0491c3b3 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 19 Jun 2012 17:31:52 -0600 Subject: [PATCH 04/12] More Compile time fixes and Test time fixes --- m4/php-embed.m4 | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/m4/php-embed.m4 b/m4/php-embed.m4 index b0dda551e..786a49a5e 100644 --- a/m4/php-embed.m4 +++ b/m4/php-embed.m4 @@ -21,32 +21,37 @@ AC_DEFUN([PHP_EMBED], ] ) - if test -z "$php_config"; then - AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH]) - fi + if test -z "$php_config"; then + AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH]) + fi - dnl For BC - PHP_CONFIG=$php_config - PHP_INSTALL_PATH=`$PHP_CONFIG --prefix 2>/dev/null` - AC_DEFINE_UNQUOTED(PHP_INSTALL_PATH, "${PHP_INSTALL_PATH}") - PHP_INCLUDES_PATH=`$PHP_CONFIG --include-dir 2>/dev/null` - AC_DEFINE_UNQUOTED(PHP_INCLUDES_PATH, "${PHP_INCLUDES_PATH}") - PHP_INCLUDES=`$PHP_CONFIG --includes 2>/dev/null` - PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null` + dnl For BC + PHP_CONFIG=$php_config + PHP_INSTALL_PATH=`$PHP_CONFIG --prefix 2>/dev/null` + PHP_INCLUDES_PATH=`$PHP_CONFIG --include-dir 2>/dev/null` + PHP_INCLUDES=`$PHP_CONFIG --includes 2>/dev/null` + PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null` - for php_embed_path in ${PHP_INSTALL_PATH}/lib ${PHP_INSTALL_PATH}/lib/php ${PHP_INSTALL_PATH}/lib/php5; do - for libext in so dylib a; do - if test -f ${php_embed_path}/libphp5.${libext}; then - PHP_EMBED_PATH=${php_embed_path}; - fi - done - done + for php_embed_path in ${PHP_INSTALL_PATH}/lib ${PHP_INSTALL_PATH}/lib/php ${PHP_INSTALL_PATH}/lib/php5; do + for libext in so dylib a; do + if test -f ${php_embed_path}/libphp5.${libext}; then + PHP_EMBED_PATH=${php_embed_path}; + fi + done + done if test -z "$PHP_EMBED_PATH"; then AC_MSG_ERROR([Cannot find libphp5 embed.]) fi - AC_DEFINE_UNQUOTED(PHP_EMBED_PATH, "${PHP_EMBED_PATH}") + AC_PATH_PROG([php], [php], [${PHP_EXECUTABLE}], [$PATH]) + # For config.h: + AC_DEFINE_UNQUOTED([PHP_INSTALL_PATH], ["${PHP_INSTALL_PATH}"]) + AC_DEFINE_UNQUOTED([PHP_INSTALL_PATH], ["${PHP_INSTALL_PATH}"]) + AC_DEFINE_UNQUOTED([PHP_INCLUDES_PATH], ["${PHP_INCLUDES_PATH}"]) + AC_DEFINE_UNQUOTED([PHP_EMBED_PATH], ["${PHP_EMBED_PATH}"]) + # For autovars.php.in: + AC_SUBST([php_install_path], ["${PHP_INSTALL_PATH}"]) dnl To check if the PHP embed SAPI has been installed, we temporarily add the dnl PHP installation path to LDFLAGS and CFLAGS, and restore it later (since From 428389453fd518cfd15ca575f800fb0ea2fcf8be Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 13:04:54 -0600 Subject: [PATCH 05/12] Don't break older php, more php5.4 changes --- runtime/methods.c | 9 +++++++++ src/embed/optimize.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/runtime/methods.c b/runtime/methods.c index 110bab3c4..76d7df801 100644 --- a/runtime/methods.c +++ b/runtime/methods.c @@ -144,10 +144,19 @@ initialize_method_call (zend_fcall_info * fci, zend_fcall_info_cache * fcic, fcic->initialized = 1; fcic->calling_scope = obj_ce; Z_SET_OBJECT_PTR(fcic, obj); + +#if PHP_VERSION_ID > 50399 + fcic->function_handler + = Z_OBJ_HT_PP (obj)->get_method (obj, + function_name, + strlen (function_name), + NULL TSRMLS_CC); +#else fcic->function_handler = Z_OBJ_HT_PP (obj)->get_method (obj, function_name, strlen (function_name) TSRMLS_CC); +#endif if (fcic->function_handler == NULL) { diff --git a/src/embed/optimize.cpp b/src/embed/optimize.cpp index 3f51aff40..1f53cbeb9 100644 --- a/src/embed/optimize.cpp +++ b/src/embed/optimize.cpp @@ -218,14 +218,18 @@ PHP::get_method_info (String* name) ZVAL_STRING (&fn, const_cast (name->c_str ()), 0); - uint check_flags=0; zend_fcall_info fci; zend_fcall_info_cache fcic; +#if PHP_VERSION_ID > 50399 + uint check_flags=0; char callable_name[124]; char error[513]; // , void ***tsrm_ls); char * cname = &callable_name[0]; char * err = &error[0]; int result = zend_fcall_info_init (&fn, check_flags, &fci, &fcic, &cname, &err TSRMLS_CC); +#else + int result = zend_fcall_info_init (&fn, &fci, &fcic TSRMLS_CC); +#endif if (result != SUCCESS) return NULL; @@ -250,7 +254,11 @@ Internal_method_info::has_implementation () bool Internal_method_info::return_by_ref () { +#if PHP_VERSION_ID > 50399 return (func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE); +#else + return func->common.return_reference; +#endif } bool From 6fa64cec630c88ab07b7993ecdf3f3fbf5741048 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 13:54:23 -0600 Subject: [PATCH 06/12] More PHP5.4 fixes --- runtime/templates/templates_new.c | 9 ++++++++- src/codegen/Generate_C.cpp | 8 +++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/runtime/templates/templates_new.c b/runtime/templates/templates_new.c index f47dd123b..d3fb82459 100644 --- a/runtime/templates/templates_new.c +++ b/runtime/templates/templates_new.c @@ -1057,8 +1057,11 @@ arg_by_ref (node ARG) arg_info++; } else +#IF PHP_VERSION_ID > 50399 + by_ref[abr_index] = (signature->common.fn_flags & ZEND_ACC_PASS_REST_BY_REFERENCE); +#else by_ref[abr_index] = signature->common.pass_rest_by_reference; - +#endif abr_index++; @@@ @@ -1203,7 +1206,11 @@ call_function (node ATTRS, string MN, list ARGS, string FILENAME, string LINE, s // We can tell this at compile-time. return_reference_bug (node ATTRS) where ATTRS.return_reference_bug @@@ 1 @@@ return_reference_bug (node ATTRS) where ATTRS.no_return_reference_bug @@@ 0 @@@ +#if PHP_VERSION_ID > 50399 +return_reference_bug (node ATTRS) @@@ (signature->common.fn_flags |= ZEND_ACC_RETURN_REFERENCE) && signature->type != ZEND_USER_FUNCTION @@@ +#else return_reference_bug (node ATTRS) @@@ signature->common.return_reference && signature->type != ZEND_USER_FUNCTION @@@ +#end function_lhs (string USE_LHS, token LHS) where USE_LHS == "NONE" @@@@@@ diff --git a/src/codegen/Generate_C.cpp b/src/codegen/Generate_C.cpp index 8461142ac..8f3b8bdd6 100644 --- a/src/codegen/Generate_C.cpp +++ b/src/codegen/Generate_C.cpp @@ -543,9 +543,11 @@ void function_declaration_block(ostream& buf, Signature_list* methods, String* b buf << "ZEND_END_ARG_INFO()\n\n"; } - buf - << "static function_entry " << *block_name << "_functions[] = {\n" - ; +#IF PHP_VERSION_ID > 50399 + buf << "static zend_function_entry " << *block_name << "_functions[] = {\n"; +#else + buf << "static function_entry " << *block_name << "_functions[] = {\n"; +#endif foreach (Signature* s, *methods) { From b6cd81cc2a481af4ebd5dd91433e678f598c20e5 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 14:13:43 -0600 Subject: [PATCH 07/12] For now use __APPLE__ but I'm sure this will affect more then just apple --- src/codegen/Compile_C.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/codegen/Compile_C.cpp b/src/codegen/Compile_C.cpp index f7d03de39..17cb7ee8a 100644 --- a/src/codegen/Compile_C.cpp +++ b/src/codegen/Compile_C.cpp @@ -60,7 +60,9 @@ void Compile_C::run (IR::PHP_script* in, Pass_manager* pm) new_arg (args) << "-I" << php_path << "/include/php/TSRM"; new_arg (args) << "-I" << php_path << "/include/php/Zend"; new_arg (args) << "-L" << php_path << "/lib"; +#ifndef __APPLE__ new_arg (args) << "-Wl,-R" << php_path << "/lib"; +#endif new_arg (args) << "-lphp5"; new_arg (args) << "-xc"; new_arg (args) << "-"; From 83db1a1ddd50f10626e15062cf77568d9c4fe692 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 14:14:35 -0600 Subject: [PATCH 08/12] Few more tweaks, still having an issue with templates during generate, it doesn't like preprocessor code so I need to figure that out still --- runtime/templates/templates_new.c | 2 +- src/codegen/Generate_C.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/templates/templates_new.c b/runtime/templates/templates_new.c index d3fb82459..e2f0c3408 100644 --- a/runtime/templates/templates_new.c +++ b/runtime/templates/templates_new.c @@ -1057,7 +1057,7 @@ arg_by_ref (node ARG) arg_info++; } else -#IF PHP_VERSION_ID > 50399 +#if PHP_VERSION_ID > 50399 by_ref[abr_index] = (signature->common.fn_flags & ZEND_ACC_PASS_REST_BY_REFERENCE); #else by_ref[abr_index] = signature->common.pass_rest_by_reference; diff --git a/src/codegen/Generate_C.cpp b/src/codegen/Generate_C.cpp index 8f3b8bdd6..4e224058b 100644 --- a/src/codegen/Generate_C.cpp +++ b/src/codegen/Generate_C.cpp @@ -543,7 +543,7 @@ void function_declaration_block(ostream& buf, Signature_list* methods, String* b buf << "ZEND_END_ARG_INFO()\n\n"; } -#IF PHP_VERSION_ID > 50399 +#if PHP_VERSION_ID > 50399 buf << "static zend_function_entry " << *block_name << "_functions[] = {\n"; #else buf << "static function_entry " << *block_name << "_functions[] = {\n"; From b91729da7737a1b0c1ac24f55b724f7808e6bcef Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 14:38:38 -0600 Subject: [PATCH 09/12] Make sure to include php_version.h for PHP_VERSION_ID --- src/codegen/Generate_C.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/codegen/Generate_C.cpp b/src/codegen/Generate_C.cpp index 4e224058b..7b7a58a6b 100644 --- a/src/codegen/Generate_C.cpp +++ b/src/codegen/Generate_C.cpp @@ -31,6 +31,9 @@ // // So that means casts are pure. +// Needed for PHP_VERSION_ID +#include + #include #include From d92239931764bcc3d64322f8ebe501b389b83a2d Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 14:39:31 -0600 Subject: [PATCH 10/12] This is just for now, need to find a real way to check PHP_VERSION_ID, for now break sub php5.4 in template so I can finish testing. --- runtime/templates/templates_new.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runtime/templates/templates_new.c b/runtime/templates/templates_new.c index e2f0c3408..ffadc4ee5 100644 --- a/runtime/templates/templates_new.c +++ b/runtime/templates/templates_new.c @@ -1206,11 +1206,9 @@ call_function (node ATTRS, string MN, list ARGS, string FILENAME, string LINE, s // We can tell this at compile-time. return_reference_bug (node ATTRS) where ATTRS.return_reference_bug @@@ 1 @@@ return_reference_bug (node ATTRS) where ATTRS.no_return_reference_bug @@@ 0 @@@ -#if PHP_VERSION_ID > 50399 return_reference_bug (node ATTRS) @@@ (signature->common.fn_flags |= ZEND_ACC_RETURN_REFERENCE) && signature->type != ZEND_USER_FUNCTION @@@ -#else -return_reference_bug (node ATTRS) @@@ signature->common.return_reference && signature->type != ZEND_USER_FUNCTION @@@ -#end +//return_reference_bug (node ATTRS) where PHP_VERSION_ID > 50399 @@@ (signature->common.fn_flags |= ZEND_ACC_RETURN_REFERENCE) && signature->type != ZEND_USER_FUNCTION @@@ +//return_reference_bug (node ATTRS) @@@ signature->common.return_reference && signature->type != ZEND_USER_FUNCTION @@@ function_lhs (string USE_LHS, token LHS) where USE_LHS == "NONE" @@@@@@ From 4fdd860e288750960ae1914fd3999960dd5a98b7 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 14:48:16 -0600 Subject: [PATCH 11/12] Need to use -o blah not -oblah as that will fail ld: unknown option: -oinfo --- src/codegen/Compile_C.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/Compile_C.cpp b/src/codegen/Compile_C.cpp index 17cb7ee8a..121d0b727 100644 --- a/src/codegen/Compile_C.cpp +++ b/src/codegen/Compile_C.cpp @@ -115,7 +115,7 @@ void Compile_C::run (IR::PHP_script* in, Pass_manager* pm) // add -o argument if (pm->args_info->output_given) { - new_arg (args) << "-o" << pm->args_info->output_arg; + new_arg (args) << "-o " << pm->args_info->output_arg; } From 6e17ae8b5ffdb10ce10bba3c21fc598bf3ba6ee1 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 20 Jun 2012 16:12:21 -0600 Subject: [PATCH 12/12] Still shouldn't use APPLE here, but works for now --- src/codegen/Compile_C.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/codegen/Compile_C.cpp b/src/codegen/Compile_C.cpp index 121d0b727..060fa851f 100644 --- a/src/codegen/Compile_C.cpp +++ b/src/codegen/Compile_C.cpp @@ -87,7 +87,9 @@ void Compile_C::run (IR::PHP_script* in, Pass_manager* pm) new_arg (args) << "-I" << php_include_path << "/TSRM"; new_arg (args) << "-I" << php_include_path << "/Zend"; new_arg (args) << "-L" << php_embed_path; +#ifndef __APPLE__ new_arg (args) << "-Wl,-R" << php_embed_path; +#endif new_arg (args) << "-lphp5"; new_arg (args) << "-xc"; new_arg (args) << "-";